jBoss部署消息驱动的bean规范违规 [英] jBoss deployment of message-driven bean spec violation
问题描述
WARN [org.jboss.ejb.deployers.EjbDeployer.verifier] EJB规范违规:
...
消息驱动的bean必须声明一个onMessage()方法。
...
org.jboss.deployers.spi.DeploymentException:企业Bean的验证失败,请参阅上面的错误消息。
但是我的bean有onMessage方法!它不会在jboss 4上工作。
为什么我会收到此错误?
编辑:
有关类看起来像这样
package ...
imports ...
public class MyMDB实现MessageDrivenBean,MessageListener {
AnotherSessionBean a;
OneMoreSessionBean b;
public MyMDB(){}
public void onMessage(message message){
if(message instanceof TextMessage){
try {
//通过jndi查找sessionBeans,创建它们
lookupABean();
//检查消息类型,然后调用
a.handle(message);
// else
b.handle(message);
} catch(SomeException e){
//处理它
}
}
}
public void lookupABean ){
try {
//查找会话bean并创建代码。
} catch(CreateException e){//处理它并捕获NamingException}
}
}
编辑2:
这是jboss.xml的相关部分
<消息驱动>
< ejb-name> MyMDB< / ejb-name>
< destination-jndi-name> topic / A_Topic< / destination-jndi-name>
< local-jndi-name> A_Topic< / local-jndi-name>
< mdb-user> user< / mdb-user>
< mdb-passwd> pass< / mdb-passwd>
< mdb-client-id> MyMessageBean< / mdb-client-id>
< mdb-subscription-id> subid< / mdb-subscription-id>
< resource-ref>
< res-ref-name> jms / TopicFactory< / res-ref-name>
< jndi-name> jms / TopicFactory< / jndi-name>
< / resource-ref>
< / message-driven>
编辑3:
$ b $我刚刚从项目中删除了所有的jar,只重新添加了相关的jar(从新的版本),抛出NoClassDefFound错误。
仍然存在问题。
编辑:
任何方向,我应该看看哪个区域?我的项目,或jboss配置,或部署设置?
org.jboss。 ejb.deployers.EjbDeployer.verifier
寻找
public void onMessage(javax.jms.Message)
通过这样的代码(这是从JBoss5):
/ **
*检查给定的消息是否为onMessage()方法
* /
public boolean isOnMessageMethod(Method m)
{
if(onMessage.equals(m.getName()))
{
Class [] paramTypes = m.getParameterTypes();
if(paramTypes.length == 1)
{
if(Message.class.equals(paramTypes [0]))
return true;
}
}
return false;
}
重要的是参数类型是 javax。 jms.Message
,没有别的,例如一些子类或超类或一些实现类。
您的签名是 public void onMessage(消息消息)
一见钟情。
A Class
仅在其 ClassLoader
中相等。如果由于某些原因,在同一个JVM中的不同类加载器中可以使用javax.jms.Message ,根据EjbDeployer.verifier的ClassLoader,可能会发生奇怪的事情。也许EjbDeployer.verifer可以访问另一个ClassLoader中的 javax.jms.Message
作为 MyMDB
。结果, javax.jms.Message
两者之间不是相等的,尽管它们是相同的字节码,而且字面上存在。 EjbVerifier将警告关于缺少 onMessage
,因为ClassLoader A上的 javax.jms.Message
不等于 javax.jms.Message
在ClassLoader B上。
当具有 javax.jms的库时,可能会发生这种情况。消息
被复制在JBoss AS上的错误位置。所以我猜 - 从远处来看,在JBoss或EAR的错误地方有一些jar包含 javax.jms.Message
。例如EAR中的一些错误的jbossallclient.jar。
I have an java EE application which has one message-driven bean and it runs fine on JBoss 4, however when I configure the project for JBoss 6 and deploy on it, I get this error;
WARN [org.jboss.ejb.deployers.EjbDeployer.verifier] EJB spec violation:
...
The message driven bean must declare one onMessage() method.
...
org.jboss.deployers.spi.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.
But my bean HAS the onMessage method! It would not have worked on jboss 4 either then.
Why do I get this error!?
Edit:
The class in question looks like this
package ...
imports ...
public class MyMDB implements MessageDrivenBean, MessageListener {
AnotherSessionBean a;
OneMoreSessionBean b;
public MyMDB() {}
public void onMessage(Message message) {
if (message instanceof TextMessage) {
try {
//Lookup sessionBeans by jndi, create them
lookupABean();
// check message-type, then invokie
a.handle(message);
// else
b.handle(message);
} catch (SomeException e) {
//handling it
}
}
}
public void lookupABean() {
try {
// code to lookup session beans and create.
} catch (CreateException e) { // handling it and catching NamingException too }
}
}
Edit 2: And this is the jboss.xml relevant parts
<message-driven>
<ejb-name>MyMDB</ejb-name>
<destination-jndi-name>topic/A_Topic</destination-jndi-name>
<local-jndi-name>A_Topic</local-jndi-name>
<mdb-user>user</mdb-user>
<mdb-passwd>pass</mdb-passwd>
<mdb-client-id>MyMessageBean</mdb-client-id>
<mdb-subscription-id>subid</mdb-subscription-id>
<resource-ref>
<res-ref-name>jms/TopicFactory</res-ref-name>
<jndi-name>jms/TopicFactory</jndi-name>
</resource-ref>
</message-driven>
Edit 3:
I just removed all my jars from the project, and only re-added relevant ones (from new versions also) to put out NoClassDefFound errors. Still the problem remains.
Edit: Any directions, what area should I look at? My project, or jboss-configration, or the deployment settings??
org.jboss.ejb.deployers.EjbDeployer.verifier
looks for
public void onMessage(javax.jms.Message)
via some code like this (this is from JBoss5):
/**
* Check if the given message is the onMessage() method
*/
public boolean isOnMessageMethod(Method m)
{
if ("onMessage".equals(m.getName()))
{
Class[] paramTypes = m.getParameterTypes();
if (paramTypes.length == 1)
{
if (Message.class.equals(paramTypes[0]))
return true;
}
}
return false;
}
It is important that the parameter type is javax.jms.Message
and nothing else, for example some subclass or superclass or some implementing class.
Your signature is public void onMessage(Message message)
which looks ok on first sight.
A Class
is equal only in its ClassLoader
. If for some reasons javax.jms.Message
is available in different classloaders in the same JVM, strange things can happen, depending on the ClassLoader of the EjbDeployer.verifier. Maybe the EjbDeployer.verifer has a access to javax.jms.Message
in another ClassLoader as MyMDB
. As result, both javax.jms.Message
are not equal to each other, although they are the same byte-code and literally exists. The EjbVerifier will warn about missing onMessage
, because javax.jms.Message
on ClassLoader A is not equal to javax.jms.Message
on ClassLoader B.
This can happen when libraries with javax.jms.Message
is copied on wrong places on the JBoss AS. So I guess - from a distance - that there is some jars containing javax.jms.Message
in wrong places on the JBoss or the EAR. For example some wrong jbossallclient.jar in the EAR.
这篇关于jBoss部署消息驱动的bean规范违规的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!