WAS 7.0.0.23 - 具有激活规范的MDB中的默认拦截器抛出classcastexception

时间:2013-05-10 15:25:44

标签: java ejb websphere interceptor

我在Websphere中面临MDB拦截器的问题。 我使用ActivationSpec为MDB配置了defaultInterceptor,而在WAS 7.0.0.23中没有为listerner端口配置。我收到了ClassCastException。相同的配置适用于SessionBean。

<assembly-descriptor><interceptor-binding>
<ejb-name>*</ejb-name>
    <interceptor-class>com.LoggingInterceptor</interceptor-class>
</interceptor-binding></assembly-descriptor>

例外:LocalExceptio E CNTR0019E: EJB threw an unexpected (non-declared) exception during invocation of method "onMessage". Exception data: javax.ejb.EJBException: Injection failure; nested exception is: java.lang.IllegalArgumentException: java.lang.ClassCastException

http://www-01.ibm.com/support/docview.wss?uid=swg1PM53989 此链接表示仅当我们使用侦听器端口时才会发生此问题 - 但我们使用的是激活规范。

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

此错误消息很差,但这意味着您有方法注入,但目标类型(查找)与代码中的类型不匹配。例如,如果您有:

@Resource
public void setQueue(QueueConnectionFactory qcf) { ... }

...但您已为此资源指定了指向数据源的绑定,然后您将获得ClassCastException。我建议删除所有注入(可能来自您的拦截器或其超类,因为只有在添加它时才会出现错误),然后慢慢重新添加它们,直到找到问题为止。