users@glassfish.java.net

Unable to connect to OpenMQ embedded broker

From: <glassfish_at_javadesktop.org>
Date: Tue, 14 Sep 2010 03:14:37 PDT

Hi!

I have Glassfish server with JMS service. I'm connecting with my standalone jms client directly to OpenMQ. I need to test some classes interacting with OpenMQ through Maven tests. I've found https://mq.dev.java.net/4.4-content/embedded-example.html paper and tryed to run OpenMQ inside JUnit test. BrokerEventListener informs me that broker started, but when i'm trying to connect to it java.net.ConnectException: Connection refused exception raised. It seems that broker don't actually open port for incoming connections.

You can see my application in attached files.
Place defined in lib/dir.txt libraries from OpenMQ distribution to lib directory.

Detailed exception:


  <testcase time="0.128" classname="bulatnig.openmqtest.EmbeddedBrokerTest" name="constructor">
    <error message="[C4003]: Error occurred on connection creation [localhost:7676]. - cause: java.net.ConnectException: Connection refused" type="com.sun.me
ssaging.jms.JMSException">com.sun.messaging.jms.JMSException: [C4003]: Error occurred on connection creation [localhost:7676]. - cause: java.net.ConnectExcep
tion: Connection refused
        at com.sun.messaging.jmq.jmsclient.ExceptionHandler.throwConnectionException(ExceptionHandler.java:274)
        at com.sun.messaging.jmq.jmsclient.ExceptionHandler.handleConnectException(ExceptionHandler.java:220)
        at com.sun.messaging.jmq.jmsclient.PortMapperClient.readBrokerPorts(PortMapperClient.java:241)
        at com.sun.messaging.jmq.jmsclient.PortMapperClient.init(PortMapperClient.java:150)
        at com.sun.messaging.jmq.jmsclient.PortMapperClient.&lt;init&gt;(PortMapperClient.java:84)
        at com.sun.messaging.jmq.jmsclient.protocol.tcp.TCPConnectionHandler.&lt;init&gt;(TCPConnectionHandler.java:124)
        at com.sun.messaging.jmq.jmsclient.protocol.tcp.TCPStreamHandler.openConnection(TCPStreamHandler.java:130)
        at com.sun.messaging.jmq.jmsclient.ConnectionInitiator.openConnection(ConnectionInitiator.java:412)
        at com.sun.messaging.jmq.jmsclient.ConnectionInitiator.createConnectionOld(ConnectionInitiator.java:362)
        at com.sun.messaging.jmq.jmsclient.ConnectionInitiator.createConnection(ConnectionInitiator.java:210)
        at com.sun.messaging.jmq.jmsclient.ConnectionInitiator.createConnection(ConnectionInitiator.java:158)
        at com.sun.messaging.jmq.jmsclient.ProtocolHandler.init(ProtocolHandler.java:836)
        at com.sun.messaging.jmq.jmsclient.ProtocolHandler.&lt;init&gt;(ProtocolHandler.java:1528)
        at com.sun.messaging.jmq.jmsclient.ConnectionImpl.openConnection(ConnectionImpl.java:2366)
        at com.sun.messaging.jmq.jmsclient.ConnectionImpl.init(ConnectionImpl.java:1047)
        at com.sun.messaging.jmq.jmsclient.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:433)
        at com.sun.messaging.jmq.jmsclient.UnifiedConnectionImpl.&lt;init&gt;(UnifiedConnectionImpl.java:60)
        at com.sun.messaging.jmq.jmsclient.QueueConnectionImpl.&lt;init&gt;(QueueConnectionImpl.java:59)
        at com.sun.messaging.ConnectionFactory.createQueueConnection(ConnectionFactory.java:98)
        at com.sun.messaging.ConnectionFactory.createQueueConnection(ConnectionFactory.java:83)
        at bulatnig.openmqtest.EmbeddedBrokerTest.constructor(EmbeddedBrokerTest.java:58)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)

        at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
        at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
        at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at java.net.Socket.connect(Socket.java:478)
        at java.net.Socket.&lt;init&gt;(Socket.java:375)
        at java.net.Socket.&lt;init&gt;(Socket.java:189)
        at com.sun.messaging.jmq.jmsclient.PortMapperClient.makeSocketWithTimeout(PortMapperClient.java:268)
        at com.sun.messaging.jmq.jmsclient.PortMapperClient.readBrokerPorts(PortMapperClient.java:220)
        ... 46 more
</error>
    <system-err>14.09.2010 13:32:36 com.sun.messaging.jmq.jmsclient.ExceptionHandler throwConnectionException
WARNING: [C4003]: Error occurred on connection creation [localhost:7676]. - cause: java.net.ConnectException: Connection refused
</system-err>
  </testcase>
[Message sent by forum member 'bulatka']

http://forums.java.net/jive/thread.jspa?messageID=482700