2

我尝试了一个带有 websocket + jms 2.0 和 ejb 3.1 的演示项目。在 wildfly 8.0.0 Alpha3 上部署失败。

EJB 豆:

@Stateless
public class QueueSenderSessionBean {

    @Resource(lookup = "queue/myQueue")
    private Queue myQueue;
    @Inject
    private JMSContext jmsContext;

    public void sendMessage(String message) {
        jmsContext.createProducer().send(myQueue, message);
    System.out.println("sendMessage");
    }
}

JMS 豆:

@MessageDriven(activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/myQueue") })
public class WebSocketMDB implements MessageListener {

    @Inject
    @WSJMSMessage
    Event<Message> jmsEvent;

    @Override
    public void onMessage(Message msg) {
        System.out.println("Message " + msg);
        jmsEvent.fire(msg);
    }
}

我正在为 jms 使用standalone-full.xml,并将代码添加到standalone-full.xml 中:

<jms-destinations>
                    <jms-queue name="WebSocketMDBQueue">
                        <entry name="queue/myQueue"/>
                    </jms-queue>
                </jms-destinations>

我在错误消息中看到并发现存在双重上下文根“javaee7-jms-websocket-example-1.0-SNAPSHOT”。但为什么?

jboss.naming.context.java.module.\"javaee7-jms-websocket-example-1.0-SNAPSHOT\".\"javaee7-jms-websocket-example-1.0-SNAPSHOT\".env.queue.myQueue

堆栈跟踪:

15:56:11,932 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221000: live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=/home/argonist/om-umgebung/wildfly-8.0.0.Alpha3/standalone/data/messagingjournal,bindingsDirectory=/home/argonist/om-umgebung/wildfly-8.0.0.Alpha3/standalone/data/messagingbindings,largeMessagesDirectory=/home/argonist/om-umgebung/wildfly-8.0.0.Alpha3/standalone/data/messaginglargemessages,pagingDirectory=/home/argonist/om-umgebung/wildfly-8.0.0.Alpha3/standalone/data/messagingpaging)
15:56:11,935 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221006: Waiting to obtain live lock
15:56:12,024 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221013: Using NIO Journal
15:56:12,124 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-7) JBAS015012: Started FileSystemDeploymentService for directory /home/argonist/om-umgebung/wildfly-8.0.0.Alpha3/standalone/deployments
15:56:12,126 INFO  [org.jboss.as.remoting] (MSC service thread 1-8) JBAS017100: Listening on 127.0.0.1:9999
15:56:12,139 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015876: Starting deployment of "javaee7-jms-websocket-example-1.0-SNAPSHOT.war" (runtime-name: "javaee7-jms-websocket-example-1.0-SNAPSHOT.war")
15:56:12,162 INFO  [org.jboss.as.jacorb] (MSC service thread 1-2) JBAS016330: CORBA ORB Service started
15:56:12,206 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221034: Waiting to obtain live lock
15:56:12,206 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221035: Live Server Obtained live lock
15:56:12,312 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
15:56:12,382 INFO  [org.jboss.as.jacorb] (MSC service thread 1-7) JBAS016328: CORBA Naming Service started
15:56:12,630 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221020: Started Netty Acceptor version 3.6.2.Final-c0d783c 127.0.0.1:5445 for CORE protocol
15:56:12,633 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221020: Started Netty Acceptor version 3.6.2.Final-c0d783c 127.0.0.1:5455 for CORE protocol
15:56:12,637 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221020: Started Netty Acceptor version 3.6.2.Final-c0d783c org.hornetq.default.servlet:5445 for CORE protocol
15:56:12,638 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221007: Server is now live
15:56:12,639 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221001: HornetQ Server version 2.3.1.Final (Wild Hornet, 123) [a6f1e08d-fd95-11e2-be04-2f639dab68d8] 
15:56:12,676 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 56) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/ServletConnectionFactory
15:56:12,682 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 58) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory
15:56:12,683 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 59) JBAS011601: Bound messaging object to jndi name java:/ConnectionFactory
15:56:12,684 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 59) JBAS011601: Bound messaging object to jndi name java:jboss/DefaultJMSConnectionFactory
15:56:12,685 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 57) HQ221003: trying to deploy queue jms.queue.WebSocketMDBQueue
15:56:12,700 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 57) JBAS011601: Bound messaging object to jndi name queue/myQueue
15:56:12,709 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) JBAS018210: Register web context: /hornetq-server
15:56:12,732 INFO  [org.jboss.as.connector.deployment] (MSC service thread 1-7) JBAS010406: Registered connection factory java:/JmsXA
15:56:12,748 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016002: Processing weld deployment javaee7-jms-websocket-example-1.0-SNAPSHOT.war
15:56:12,763 INFO  [org.hornetq.ra] (MSC service thread 1-7) HornetQ resource adaptor started
15:56:12,763 INFO  [org.jboss.as.connector.services.resourceadapters.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-7) IJ020002: Deployed: file://RaActivatorhornetq-ra
15:56:12,766 INFO  [org.jboss.as.connector.deployment] (MSC service thread 1-7) JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]
15:56:12,780 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-6) HV000001: Hibernate Validator 5.0.1.Final
15:56:12,851 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-6) JNDI bindings for session bean named QueueSenderSessionBean in deployment unit deployment "javaee7-jms-websocket-example-1.0-SNAPSHOT.war" are as follows:

    java:global/javaee7-jms-websocket-example-1.0-SNAPSHOT/QueueSenderSessionBean!org.glassfish.samples.javaee7.websocketjms.QueueSenderSessionBean
    java:app/javaee7-jms-websocket-example-1.0-SNAPSHOT/QueueSenderSessionBean!org.glassfish.samples.javaee7.websocketjms.QueueSenderSessionBean
    java:module/QueueSenderSessionBean!org.glassfish.samples.javaee7.websocketjms.QueueSenderSessionBean
    java:global/javaee7-jms-websocket-example-1.0-SNAPSHOT/QueueSenderSessionBean
    java:app/javaee7-jms-websocket-example-1.0-SNAPSHOT/QueueSenderSessionBean
    java:module/QueueSenderSessionBean

15:56:13,010 INFO  [org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016005: Starting Services for CDI deployment: javaee7-jms-websocket-example-1.0-SNAPSHOT.war
15:56:13,041 INFO  [org.jboss.weld.Version] (MSC service thread 1-4) WELD-000900 2.0.2 (Final)
15:56:13,060 INFO  [org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016008: Starting weld service for deployment javaee7-jms-websocket-example-1.0-SNAPSHOT.war
15:56:13,094 INFO  [org.jboss.as.ejb3] (MSC service thread 1-7) JBAS014142: Started message driven bean 'WebSocketMDB' with 'hornetq-ra' resource adapter
15:56:13,247 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "javaee7-jms-websocket-example-1.0-SNAPSHOT.war")]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.\"javaee7-jms-websocket-example-1.0-SNAPSHOT\".\"javaee7-jms-websocket-example-1.0-SNAPSHOT\".env.\"org.glassfish.samples.javaee7.websocketjms.QueueSenderSessionBean\".myQueue is missing [jboss.naming.context.java.module.\"javaee7-jms-websocket-example-1.0-SNAPSHOT\".\"javaee7-jms-websocket-example-1.0-SNAPSHOT\".env.queue.myQueue]"]}
15:56:13,287 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 30) JBAS018559: Deployed "javaee7-jms-websocket-example-1.0-SNAPSHOT.war" (runtime-name : "javaee7-jms-websocket-example-1.0-SNAPSHOT.war")
15:56:13,291 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
      service jboss.naming.context.java.module."javaee7-jms-websocket-example-1.0-SNAPSHOT"."javaee7-jms-websocket-example-1.0-SNAPSHOT".env.queue.myQueue (missing) dependents: [service jboss.naming.context.java.module."javaee7-jms-websocket-example-1.0-SNAPSHOT"."javaee7-jms-websocket-example-1.0-SNAPSHOT".env."org.glassfish.samples.javaee7.websocketjms.QueueSenderSessionBean".myQueue] 

15:56:13,314 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
15:56:13,316 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
15:56:13,317 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: WildFly 8.0.0.Alpha3 "WildFly" started (with errors) in 4007ms - Started 264 of 318 services (21 services failed or missing dependencies, 71 services are lazy, passive or on-demand)
4

1 回答 1

0

在 JMS 2.0 中,提供了一个默认的连接工厂。因此,它的 JNDI 条目必须与服务器 XML 中列出的连接工厂一起提供。

请参阅以下链接: https ://docs.jboss.org/author/display/WFLY8/Messaging+configuration

从 JMS 2.0 开始,EE 应用程序可以在 JNDI 名称 java:comp/DefaultJMSConnectionFactory 下访问默认 JMS 连接工厂。WildFly 消息传递子系统定义了一个池连接工厂,用于提供此默认连接工厂。任何在 JNDI 名称 java:comp/DefaultJMSConnectionFactory 下查找默认 JMS 提供程序的 EE 应用程序都将考虑此 pooled-connection-factory 上的任何参数更改。

<pooled-connection-factory name="hornetq-ra">
            <transaction mode="xa"/>
            <connectors>
               <connector-ref connector-name="in-vm"/>
            </connectors>
            <entries>
               <entry name="java:/JmsXA"/>
               <!-- Global JNDI entry used to provide a default JMS Connection factory to EE application -->
               <entry name="java:jboss/DefaultJMSConnectionFactory"/>
            </entries>
         </pooled-connection-factory>
于 2015-07-03T12:42:26.440 回答