Wildfly 10 default ActiveMQ client cannot connect to server
shell-software Jan 27, 2016 3:16 PMHi all,
I'm new to Java EE and I'm working on my JMS test application
I'm using default messaging-activemq in standalone-full.xml
Here is what I have in jndi.properties:
java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
java.naming.provider.url=http-remoting://centos:8080
java.naming.security.principal=shell
java.naming.security.credentials=123456
jboss.naming.client.ejb.context=true
java.naming.factory.url.pkgs=org.jboss.ejb.client.naming
And here is how I call it:
public static void main(String[] args) throws NamingException, IOException {
Properties properties = new Properties();
properties.load(new FileInputStream(new File("jndi.properties")));
Context context = new InitialContext(properties);
ConnectionFactory factory =
(ConnectionFactory) context.lookup("jms/RemoteConnectionFactory");
Destination topic = (Destination) context.lookup("jms/topic/ItemsTopic");
Item item = new Item("PSV", "Sony PlayStation Vita", 4000);
sendMessage(factory, topic, item);
}
private static void sendMessage(ConnectionFactory factory, Destination destination, Serializable message) {
try (JMSContext jmsContext = factory.createContext()) {
jmsContext.createProducer().send(destination, message);
}
}
As a result I'm getting the following stacktrace:
січ. 27, 2016 9:28:17 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.1.Final
січ. 27, 2016 9:28:17 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.1.Final
січ. 27, 2016 9:28:17 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.9.Final
січ. 27, 2016 9:28:19 PM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: EJBCLIENT000017: Received server version 2 and marshalling strategies [river]
січ. 27, 2016 9:28:19 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@3a883ce7, receiver=Remoting connection EJB receiver [connection=Remoting connection <6d998ce2>,channel=jboss.ejb,nodename=localhost]} on channel Channel ID 8882c853 (outbound) of Remoting connection 6895a785 to centos/172.20.12.9:8080
січ. 27, 2016 9:28:20 PM org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 2.1.3.Final
Exception in thread "main" javax.jms.JMSRuntimeException: Failed to create session factory
at org.apache.activemq.artemis.jms.client.JmsExceptionUtils.convertToRuntimeException(JmsExceptionUtils.java:88)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createContext(ActiveMQConnectionFactory.java:267)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createContext(ActiveMQConnectionFactory.java:253)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createContext(ActiveMQConnectionFactory.java:243)
at com.software.shell.javaee.jms.item.ItemProducer.sendMessage(ItemProducer.java:36)
at com.software.shell.javaee.jms.item.ItemProducer.main(ItemProducer.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: javax.jms.JMSException: Failed to create session factory
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:735)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createContext(ActiveMQConnectionFactory.java:260)
... 9 more
Caused by: ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ119007: Cannot connect to server(s). Tried with all available servers.]
at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:792)
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:732)
... 10 more
I searched in this error and found that there was an issue in ActiveMQhttps://issues.apache.org/jira/browse/ARTEMIS-290, but it seems it was fixed in Wildfly 7 EAP and I am using ver. 10
Any ideas?
Thanks!