Question

I'v deployed a web application (jms-api.war) in JBoss, and I want to get a JMS connection factory via JNDI from it, Is it possible without any configuration (like this)? I tried to use JNDI without any configuration:

my connection factory in standalone.xml:

<jms-connection-factories>
    <connection-factory name="InVmConnectionFactory">
        <connectors>
            <connector-ref connector-name="in-vm"/>
        </connectors>
        <entries>
            <entry name="java:/ConnectionFactory"/>
        </entries>
    </connection-factory>
</jms-connection-factories>

And in my application i have this spring bean to access connection factory (It's working in my tests with embedded hornetq):

<bean id="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="/ConnectionFactory" />
    <property name="resourceRef" value="true"/>
</bean>

In jboss startup i get this error, how can i solve it?:

JBAS014775:    New missing/unsatisfied dependencies:
      service jboss.naming.context.java.jboss.resources.jms.ConnectionFactory (missing) dependents: [service jboss.naming.context.java.module.jms-api.jms-api.env.jms.ConnectionFactory] 

Jboss log (hornetq start part):

11:00:32,689 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 50) HQ221000: live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=C:\Users\Mojtaba\workspace-hornetq\build\appserver\jboss\standalone\data\../../../hornetqdata/journal,bindingsDirectory=C:\Users\Mojtaba\workspace-hornetq\build\appserver\jboss\standalone\data\../../../hornetqdata/bindings,largeMessagesDirectory=C:\Users\Mojtaba\workspace-hornetq\build\appserver\jboss\standalone\data\../../../hornetqdata/large-message,pagingDirectory=C:\Users\Mojtaba\workspace-hornetq\build\appserver\jboss\standalone\data\../../../hornetqdata/paging)
11:00:32,691 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 50) HQ221006: Waiting to obtain live lock
11:00:32,723 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 50) HQ221013: Using NIO Journal
11:00:32,840 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 50) HQ221034: Waiting to obtain live lock
11:00:32,841 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 50) HQ221035: Live Server Obtained live lock
11:00:33,041 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on 127.0.0.1:9999
11:00:33,777 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 50) HQ221020: Started Netty Acceptor version 3.6.6.Final-redhat-1-fd3c6b7 0.0.0.0:5445 for CORE protocol
11:00:33,779 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 50) HQ221007: Server is now live
11:00:33,780 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 50) HQ221001: HornetQ Server version 2.3.12.Final (2.3.12, 123) [c0d4ec44-d8d5-11e3-afd6-5372513ac770] 
11:00:33,786 INFO  [org.hornetq.jms.server] (ServerService Thread Pool -- 50) HQ121005: Invalid "host" value "0.0.0.0" detected for "netty" connector. Switching to "Mojtaba-PC". If this new address is incorrect please manually configure the connector to use the proper one.
11:00:33,811 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 50) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory
11:00:33,812 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 50) JBAS011601: Bound messaging object to jndi name java:/RemoteConnectionFactory
11:00:33,815 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 52) JBAS011601: Bound messaging object to jndi name java:/ConnectionFactory
11:00:33,816 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 51) HQ221003: trying to deploy queue jms.queue.testQueue
11:00:34,115 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 51) JBAS011601: Bound messaging object to jndi name java:/queue/testQueue
11:00:34,116 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 51) JBAS011601: Bound messaging object to jndi name java:jboss/exported/queues/testQueue
11:00:34,195 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 27) JBAS018559: Deployed "jms-api.war" (runtime-name : "jms-api.war")
11:00:34,199 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
      service jboss.naming.context.java.jboss.resources.jms.ConnectionFactory (missing) dependents: [service jboss.naming.context.java.module.jms-api.jms-api.env.jms.ConnectionFactory] 

(jboss eap 6.2.0, hornetq 2.3.12.Final)

Was it helpful?

Solution 3

I defined this connection-factory on my messaging subsystem:

<connection-factory name="RemoteConnectionFactory">
    <connectors>
    <connector-ref connector-name="netty"/>
    </connectors>
    <entries>
        <entry name="java:jboss/exported/jms/ConnectionFactory"/>
    </entries>
</connection-factory>

and in my webapp spring bean configuration (the jndiName should be started with java:/):

<bean id="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:/jboss/exported/jms/ConnectionFactory" />
    <property name="lookupOnStartup" value="false"/>
    <property name="proxyInterface" value="javax.jms.ConnectionFactory"/>
</bean>

And no changes or configs in web.xml (e.g. no need for resource-ref in web.xml)!

OTHER TIPS

Though I have not yet worked with v6.2 but you can try this. The error was unable to find your connection factory via JNDI tree. So, add below in your already listed entry:

<entries>
  <entry name="java:/ConnectionFactory"/>
  <!-- Add this -->
  <entry name="java:jboss/exported/ConnectionFactory"/>
</entries>

And change connector ref from in-vm to netty

The easiest solution is to change your bean configuration:

<bean id="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:/ConnectionFactory" />
    <property name="resourceRef" value="false"/>
</bean>

If resourceRef is true, then Spring will attempt to look up "java:comp/env/ConnectionFactory", (or perhaps even "java:comp/env//ConnectionFactory"), because that is what correct resource references look like to all JavaEE containers (not just JBoss).

If you want to use resource references, you must declare them in your web.xml file and map them in a jboss-web.xml file.

You would typically do this when you're trying to write code that must be portable between different JavaEE server implementations. They all have their own variation of jboss-web.xml to map between the constant resource reference name and the physical resource name in the server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top