Не удалось создать удаленное соединение в Jboss-eap 6.4 HornetQ.

Мне нужна помощь в создании удаленных подключений в Jboss-eap 6.4 HornetQ

У меня есть этот код:

import java.util.Hashtable;
import javax.jms.*;
import javax.naming.*;

public class QueueSend {
    private final static String JNDI_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
    private final static String JMS_FACTORY = "jms/RemoteConnectionFactory";
    private final static String QUEUE = "jms/queue/test";
    private final static String jbossUrl = "remote://localhost:4447";

private static InitialContext getInitialContext() throws NamingException {
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
    env.put(Context.PROVIDER_URL, jbossUrl);
    env.put(Context.SECURITY_PRINCIPAL, "appuser"); // <-- username
    env.put(Context.SECURITY_CREDENTIALS, "appuser_2015"); // <-- password

    return new InitialContext(env);
}

public static void main(String[] args) throws Exception {
    InitialContext ic = getInitialContext();
    QueueConnectionFactory qconFactory = 
        (QueueConnectionFactory)ic.lookup(JMS_FACTORY);
    QueueConnection qcon = 
        qconFactory.createQueueConnection("appuser","appuser_2015");
    QueueSession qsession = qcon.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
    Queue queue = (Queue)ic.lookup(QUEUE);
    QueueSender qsender =  qsession.createSender(queue);

    qcon.start();

    TextMessage msg = qsession.createTextMessage();;
    msg.setText("HelloWorld");
    qsender.send(msg);    

    qsender.close();
    qsession.close();
    qcon.close();
    System.out.println("Message Sent!");
}
}

И когда я запустил этот код, он отображает ошибку:

Exception in thread "main" javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.ExceptionInInitializerError]
at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)
at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:121)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at com.wendell.QueueSend.getInitialContext(QueueSend.java:28)
at com.wendell.QueueSend.main(QueueSend.java:32)
Caused by: java.lang.ExceptionInInitializerError
at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.sendVersionHeader(RemoteNamingStoreV1.java:69)
at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.start(RemoteNamingStoreV1.java:64)
at org.jboss.naming.remote.protocol.v1.VersionOne.getRemoteNamingStore(VersionOne.java:45)
at org.jboss.naming.remote.protocol.Versions.getRemoteNamingStore(Versions.java:49)
at org.jboss.naming.remote.client.RemoteContextFactory.createVersionedStore(RemoteContextFactory.java:68)
at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:60)
at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateCachedNamingStore(InitialContextFactory.java:166)
at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:139)
at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:104)
... 6 more
Caused by: java.lang.RuntimeException: Could not find a marshaller factory for river marshalling strategy
at org.jboss.naming.remote.protocol.v1.WriteUtil.<clinit>(WriteUtil.java:50)
... 15 more

Я не знаю, в чем проблема, я что-то пропустил? Где я неправ?

Пожалуйста помоги. Спасибо


person Ormocanon    schedule 16.09.2015    source источник


Ответы (1)


У вас может быть jboss-marshalling-xxxx.jar, но отсутствует jboss-marshalling-river-xxxx.jar в пути к классам вашего клиента.

Добавьте файл jar jboss-marshalling-river-xxxx.jar в свой путь к классам.

В моем случае у меня было jboss-marshalling-1.4.11.Final.jar, но отсутствовало jboss-marshalling-river-1.4.11.Final.jar в моем пути к классам.

После этого мой клиент смог выполнять удаленные вызовы EJB к wildfly.

Мне немного помогла ссылка эта.

person mwangi    schedule 06.11.2016