简体   繁体   English

JMS在Jboss 5.1.0 GA中不起作用

[英]JMS not working in Jboss 5.1.0 GA

I am using jboss 5.1.0 GA. 我正在使用jboss 5.1.0 GA。 I am trying to create a helloworldjMS.java. 我正在尝试创建helloworldjMS.java。 The code is as follows, 代码如下,

    import java.util.Hashtable;
    import javax.jms.Connection;
    import javax.jms.ConnectionFactory;
    import javax.jms.Message;
    import javax.jms.MessageConsumer;
    import javax.jms.MessageProducer;
    import javax.jms.Queue;
    import javax.jms.Session;
    import javax.jms.TextMessage;
    import javax.naming.Context;
    import javax.naming.InitialContext;

    public class HelloWorldJMS {

    public static void main(String[] args) {

        try { 
            Hashtable env = new Hashtable();

            env.put(Context.INITIAL_CONTEXT_FACTORY,
                    "org.jnp.interfaces.NamingContextFactory");

            env.put(Context.PROVIDER_URL, "jnp://localhost:1099");

            env.put(Context.URL_PKG_PREFIXES,
                    "org.jboss.naming:org.jnp.interfaces");

            // Create the initial context

            Context ctx = new InitialContext(env);

            // Lookup the JMS connection factory from the JBoss 5.1 object store

            ConnectionFactory connectionFactory = (ConnectionFactory) ctx
                    .lookup("ConnectionFactory");

            // Lookup a queue from the JBoss 5.1 object store

            Queue queue = (javax.jms.Queue) ctx.lookup("/queue/DLQ");

            // Create a connection to the JBoss 5.1 Message Service

            Connection connection = connectionFactory.createConnection();

            // Create a session within the connection

            Session session = connection.createSession(false,
                    Session.AUTO_ACKNOWLEDGE);

            // Create a message producer to put messages on the queue

            MessageProducer messageProducer = session.createProducer(queue);

            // Create and send a message to the queue

            TextMessage textMessage = session.createTextMessage();

            textMessage.setText("Hello World");

            System.out.println("Sending Message: " + textMessage.getText());

            messageProducer.send(textMessage);

            // Create a message consumer

            MessageConsumer messageConsumer = session.createConsumer(queue);

            // Start the Connection created

            connection.start();

            // Receive a message from the queue.

            Message msg = messageConsumer.receive();

            // Retrieve the contents of the message.

            if (msg instanceof TextMessage) {

                TextMessage txtMsg = (TextMessage) msg;

                System.out.println("Read Message: " + txtMsg.getText());

            }

            // Close the session and connection resources.

            session.close();

            connection.close();

        } catch (Exception ex) {

            ex.printStackTrace();

        }
    }

    }

I am getting the following error, 我收到以下错误,

        org.jboss.jms.exception.MessagingNetworkFailureException
            at org.jboss.jms.client.delegate.DelegateSupport.handleThrowable(DelegateSupport.java:245)
            at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.org$jboss$jms$client$delegate$ClientConnectionFactoryDelegate$createConnectionDelegate$aop(ClientConnectionFactoryDelegate.java:187)
            at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate$createConnectionDelegate_N3019492359065420858.invokeNext(ClientConnectionFactoryDelegate$createConnectionDelegate_N3019492359065420858.java)
            at org.jboss.jms.client.container.StateCreationAspect.handleCreateConnectionDelegate(StateCreationAspect.java:83)
            at org.jboss.aop.advice.org.jboss.jms.client.container.StateCreationAspect_z_handleCreateConnectionDelegate_328011903.invoke(StateCreationAspect_z_handleCreateConnectionDelegate_328011903.java)
            at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate$createConnectionDelegate_N3019492359065420858.invokeNext(ClientConnectionFactoryDelegate$createConnectionDelegate_N3019492359065420858.java)
            at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.createConnectionDelegate(ClientConnectionFactoryDelegate.java)
            at org.jboss.jms.client.JBossConnectionFactory.createConnectionInternal(JBossConnectionFactory.java:205)
            at org.jboss.jms.client.JBossConnectionFactory.createConnection(JBossConnectionFactory.java:87)
            at org.jboss.jms.client.JBossConnectionFactory.createConnection(JBossConnectionFactory.java:82)
            at HelloWorldJMS.main(HelloWorldJMS.java:67)
        Caused by: org.jboss.remoting.ConnectionFailedException: Timed out trying to create control socket
            at org.jboss.remoting.transport.bisocket.BisocketClientInvoker.handleConnect(BisocketClientInvoker.java:276)
            at org.jboss.remoting.MicroRemoteClientInvoker.connect(MicroRemoteClientInvoker.java:309)
            at org.jboss.remoting.Client.connect(Client.java:1612)
            at org.jboss.remoting.Client.connect(Client.java:515)
            at org.jboss.remoting.callback.ServerInvokerCallbackHandler.connect(ServerInvokerCallbackHandler.java:168)
            at org.jboss.remoting.ServerInvoker.getCallbackHandler(ServerInvoker.java:2064)
            at org.jboss.remoting.ServerInvoker.handleInternalInvocation(ServerInvoker.java:1646)
            at org.jboss.remoting.transport.bisocket.BisocketServerInvoker.handleInternalInvocation(BisocketServerInvoker.java:863)
            at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:878)
            at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:744)
            at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:697)
            at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:551)
            at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:232)
            at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:163)
            at org.jboss.remoting.Client.invoke(Client.java:1550)
            at org.jboss.remoting.Client.addCallbackListener(Client.java:1619)
            at org.jboss.remoting.Client.addListener(Client.java:913)
            at org.jboss.jms.client.remoting.JMSRemotingConnection.addInvokerCallbackHandler(JMSRemotingConnection.java:230)
            at org.jboss.jms.client.remoting.JMSRemotingConnection.start(JMSRemotingConnection.java:340)
            at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.org$jboss$jms$client$delegate$ClientConnectionFactoryDelegate$createConnectionDelegate$aop(ClientConnectionFactoryDelegate.java:154)
            ... 9 more

I have the following jars, concurrent.jar,javassist-3.10.0.GA.jar,jboss-aop-client.jar,jboss-common-core-2.2.10.GA.jar,jboss-common.jar, jboss-j2ee.jar , jboss-mdr-2.0.1.GA.jar, jboss-messaging-client.jar, jboss-remoting.jar, jbossmq.jar, jetty-session-redis-2.3.ga-serialjboss.jar, jnpserver.jar. 我有以下jar,current.jar,javassist-3.10.0.GA.jar,jboss-aop-client.jar,jboss-common-core-2.2.10.GA.jar,jboss-common.jar,jboss- j2ee.jar,jboss-mdr-2.0.1.GA.jar,jboss-messaging-client.jar,jboss-remoting.jar,jbossmq.jar,jetty-session-redis-2.3.ga-serialjboss.jar,jnpserver。罐。

I know this is very old jboss questions. 我知道这是非常老的jboss问题。 But I tried various suggestions, could not find any way. 但是我尝试了各种建议,找不到任何方法。 So, i am posting the question. 所以,我要发布问题。 So kindly provide some suggestions. 因此,请提供一些建议。

Thanks 谢谢

删除jboss-remoting.jar并添加jboss-remoting-4.2.2.GA.jar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM