Hornetq2.2.2 client failed to create session factory to connect on server
geek_nissa Jul 20, 2011 5:29 AMhello
I am an issue with hornetq 2.2.2 integrate in Jboss 6.0AS. I deployed EAR project in Jboss6.0 with EJB 2.1 and work fine but not messaging echange with HornetQ after migration from JMS to HornetQ
HornetQ 2.2.2 is integrate in Jboss, is the server that waits message send by HornetQ client installed stand-alone on another computer
The problem is on the client :
javax.jms.JMSException: Failed to create session factory
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:605)
at org.hornetq.jms.client.HornetQConnectionFactory.createQueueConnection(HornetQConnectionFactory.java:131)
at org.hornetq.jms.client.HornetQConnectionFactory.createQueueConnection(HornetQConnectionFactory.java:126)
at com.equant.nms.ums.core.Messaging.open(Messaging.java:187)
at com.equant.nms.ums.core.Messaging.setup(Messaging.java:268)
at com.equant.nms.ums.core.Messaging.<init>(Messaging.java:102)
at com.equant.nms.ums.core.Messaging.getMessaging(Messaging.java:111)
at com.equant.nms.ums.NMSums.NMSrun(NMSums.java:238)
at com.equant.nms.ums.NMSums.main(NMSums.java:386)
Caused by: HornetQException[errorCode=2 message=Cannot connect to server(s). Tried with all available servers.]
at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:619)
at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:601)
The JAVA class Messaging.java uses the file to recover the connectionFactoryName and configuration for the connection :
core.message.connectionFactoryName=ConnectionFactory
core.message.factory=org.jnp.interfaces.NamingContextFactory
core.message.url=jnp://cmprod:11099
try {
InitialContext initialContext = createInitialContext(factory, url);
QueueConnectionFactory queueConnectionFactory =
(QueueConnectionFactory) initialContext.lookup(connectionFactoryName);
187 queueConnection = queueConnectionFactory.createQueueConnection();
queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue requestQueue = (Queue) initialContext.lookup(REQUEST_QUEUE_NAME);
receiver = queueSession.createReceiver(requestQueue, selector);
Queue replyQueue = (Queue) initialContext.lookup(REPLY_QUEUE_NAME);
replier = queueSession.createSender(replyQueue);
replier.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
if (ttl > 0)
replier.setTimeToLive(ttl);
queueConnection.start();
} catch (NamingException e) {
log.trace("messaging service setup failed", e);
close();
throw (JMSException) new JMSException("Naming lookup failure.").initCause(e);
} catch (JMSException e) {
log.trace("messaging service setup failed", e);
close();
throw e;
}
log.info("messaging service set up, selector=" + selector);
I configured HornetQ server in Jboss with netty connector and acceptor because client and server are not on the same JVM :
-hornetq-configurations.xml to configure connector and acceptor on the same port
<connectors>
<connector name="netty">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
<param key="host" value="${jboss.bind.address:0.0.0.0}"/>
<param key="port" value="${hornetq.remoting.netty.port:5445}"/>
</connector>
<acceptors>
<acceptor name="netty">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
<param key="host" value="${jboss.bind.address:0.0.0.0}"/>
<param key="port" value="${hornetq.remoting.netty.port:5445}"/>
</acceptor>
-hornetq-jms.xml to specify use netty for connectionFactory
<connection-factory name="ConnectionFactory">
<connectors>
<connector-ref connector-name="netty"/>
</connectors>
<entries>
<entry name="/ConnectionFactory"/>
<entry name="/XAConnectionFactory"/>
</entries>
</connection-factory>
-bindingservice.beans to specify the port use by HornetQ
<!-- ********************* HornetQ **************** -->
<bean class="org.jboss.services.binding.ServiceBindingMetadata">
<property name="serviceName">HornetQ</property>
<property name="bindingName">netty-port</property>
<property name="port">5445</property>
<property name="description">Socket for HornetQ</property>
</bean>
So the client can't send message to the server but i don't see why !!!!
Thanks for your help and have a good day.