我在Jboss EAP 7.0.6 GA,IBM MQ 9上有一个MDB用于消费队列消息
  


    包com.ryzorbent.demo.jms;

    导入javax.ejb.ActivationConfigProperty;
    导入javax.ejb.MessageDriven;
    导入javax.ejb.TransactionAttribute;
    导入javax.jms.JMSException;

    导入javax.jms.Message;
    导入javax.jms.MessageListener;
    导入javax.jms.TextMessage;

    导入org.jboss.ejb3.annotation.ResourceAdapter;

    @MessageDriven(name =“ EFRSTestMDB”,activationConfig = {
            @ActivationConfigProperty(propertyName =“ destinationType”,propertyValue =“ javax.jms.Queue”),
            @ActivationConfigProperty(propertyName =“ useJNDI”,propertyValue =“ false”),
            @ActivationConfigProperty(propertyName =“ hostName”,propertyValue =“ localhost”),
            @ActivationConfigProperty(propertyName =“ port”,propertyValue =“ 1414”),
            @ActivationConfigProperty(propertyName =“ channel”,propertyValue =“ SYSTEM.DEF.SVRCONN”),
            @ActivationConfigProperty(propertyName =“ queueManager”,propertyValue =“ EFRS_UAT”),
            @ActivationConfigProperty(propertyName =“ destination”,propertyValue =“ jms / queue / QUEUE”),
            @ActivationConfigProperty(propertyName =“ transportType”,propertyValue =“ CLIENT”)
        })

    @ResourceAdapter(值=“ wmq.jmsra.rar”)
    // @ TransactionAttribute(value =“ NoTransaction”)

    公共类EFRSTestMDB实现MessageListener {


        @Override
        公共无效onMessage(Message inMessage){
            TextMessage消息=(TextMessage)inMessage;
            尝试{
                System.out.println(String.format(“ Hello,%s”,message.getText()));
            } catch(JMSException e){
                e.printStackTrace();
            }
        }

    }



  
  我将wmq.jmsra.rar复制到了../standalone/deployments
  在standalone-full.xml中添加了队列,通道等的资源适配器子系统
  但我得到以下错误
  


java.lang.NoClassDefFoundError:无法链接com / ryzorbent / demo / jms / EFRSTestMDB(服务模块加载程序中的模块“ deployment.TestJbossMDB.jar:main”):javax / jms / MessageListener

最佳答案

wmq.jmsra.rar不包含来自您的错误的JMS API类,例如javax/jms/MessageListener。在Limitations and Known Problems中说:


  IBMWebSphere®MQ 7.5资源适配器的部署不会为您的部署加载javax.jms.api模块。它还不支持新的Jave EE 7注释,例如@ JMSConnectionFactoryDe​​finitions,@ JMSDestinationDefinition。必须在配置中具有messaging-activemq子系统才能启用它。如果您不希望启动JBoss EAP消息服务器,请添加一个空的messages-activemq子系统。


因此,您必须像上述一样添加JMS api jar。

08-18 13:36