3 Replies Latest reply on May 2, 2012 9:19 AM by sandeep chaturvedi

    Unable to post message usinng activemq REST API

    sandeep chaturvedi Newbie

      I am seeing below exception when trying to post message to fusesource ESB 4.4.1

      default broker:

       

      08:01:38,449 | WARN  | tp1229308168-230 | log                              | 116 - org.eclipse.jetty.util - 7.4.5.fuse20111017 | /activemqweb/send/test

      javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused: connect

           at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:35)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:290)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:234)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:182)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.web.WebClient.getConnection(WebClient.java:247)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.web.WebClient.createSession(WebClient.java:349)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.web.WebClient.getSession(WebClient.java:240)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.web.MessageServletSupport.getDestination(MessageServletSupport.java:319)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.web.MessageServletSupport.getDestinationFromURI(MessageServletSupport.java:290)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.web.MessageServletSupport.getDestination(MessageServletSupport.java:261)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.web.MessageServlet.doPost(MessageServlet.java:110)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)[122:org.apache.geronimo.specs.geronimo-servlet_2.5_spec:1.1.2]

           at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)[122:org.apache.geronimo.specs.geronimo-servlet_2.5_spec:1.1.2]

           at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:538)[113:org.eclipse.jetty.servlet:7.4.5.fuse20111017]

           at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1352)[113:org.eclipse.jetty.servlet:7.4.5.fuse20111017]

           at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:83)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1323)[113:org.eclipse.jetty.servlet:7.4.5.fuse20111017]

           at org.apache.activemq.web.filter.ApplicationContextFilter.doFilter(ApplicationContextFilter.java:81)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1323)[113:org.eclipse.jetty.servlet:7.4.5.fuse20111017]

           at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1323)[113:org.eclipse.jetty.servlet:7.4.5.fuse20111017]

           at org.ops4j.pax.web.service.internal.WelcomeFilesFilter.doFilter(WelcomeFilesFilter.java:169)[158:org.ops4j.pax.web.pax-web-runtime:1.0.3]

           at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1323)[113:org.eclipse.jetty.servlet:7.4.5.fuse20111017]

           at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:476)[113:org.eclipse.jetty.servlet:7.4.5.fuse20111017]

           at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)[160:org.ops4j.pax.web.pax-web-jetty:1.0.3]

           at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)[115:org.eclipse.jetty.server:7.4.5.fuse20111017]

           at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:480)[112:org.eclipse.jetty.security:7.4.5.fuse20111017]

           at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225)[115:org.eclipse.jetty.server:7.4.5.fuse20111017]

           at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:937)[115:org.eclipse.jetty.server:7.4.5.fuse20111017]

           at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:116)[160:org.ops4j.pax.web.pax-web-jetty:1.0.3]

           at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)[113:org.eclipse.jetty.servlet:7.4.5.fuse20111017]

           at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)[115:org.eclipse.jetty.server:7.4.5.fuse20111017]

           at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:871)[115:org.eclipse.jetty.server:7.4.5.fuse20111017]

           at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)[115:org.eclipse.jetty.server:7.4.5.fuse20111017]

           at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:72)[160:org.ops4j.pax.web.pax-web-jetty:1.0.3]

           at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)[115:org.eclipse.jetty.server:7.4.5.fuse20111017]

           at org.eclipse.jetty.server.Server.handle(Server.java:346)[115:org.eclipse.jetty.server:7.4.5.fuse20111017]

           at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:438)[115:org.eclipse.jetty.server:7.4.5.fuse20111017]

           at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:922)[115:org.eclipse.jetty.server:7.4.5.fuse20111017]

           at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:780)[110:org.eclipse.jetty.http:7.4.5.fuse20111017]

           at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:220)[110:org.eclipse.jetty.http:7.4.5.fuse20111017]

           at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:43)[115:org.eclipse.jetty.server:7.4.5.fuse20111017]

           at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:538)[111:org.eclipse.jetty.io:7.4.5.fuse20111017]

           at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:43)[111:org.eclipse.jetty.io:7.4.5.fuse20111017]

           at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:529)[116:org.eclipse.jetty.util:7.4.5.fuse20111017]

           at java.lang.Thread.run(Thread.java:662)[:1.6.0_22]

      Caused by: java.net.ConnectException: Connection refused: connect

           at java.net.PlainSocketImpl.socketConnect(Native Method)[:1.6.0_22]

           at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)[:1.6.0_22]

           at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)[:1.6.0_22]

           at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)[:1.6.0_22]

           at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)[:1.6.0_22]

           at java.net.Socket.connect(Socket.java:529)[:1.6.0_22]

           at org.apache.activemq.transport.tcp.TcpTransport.connect(TcpTransport.java:497)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:460)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:54)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.transport.AbstractInactivityMonitor.start(AbstractInactivityMonitor.java:121)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:72)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:270)[273:org.apache.activemq.activemq-web-console:5.5.1.fuse-03-06]

           ... 46 more

       

       

      Below is the client which is trying to post message to broker queue:

       

            URL u = new URL("http://localhost:8181/activemqweb/send/test?readTimeout=1000&type=queue"); 

                           HttpURLConnection conn = (HttpURLConnection) u.openConnection();  

                           conn.setDoOutput(true);  

                           OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());  

                           wr.write(xmlstr);  

                           wr.flush();  

                               

                           // Get the response  

                           BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));  

                           String line;  

                           while ((line = rd.readLine()) != null) {  

                               // Process line...

                                System.out.println(line);

                           }  

                           wr.close();  

                           rd.close();  

                           conn.disconnect();

       

      Edited by: sandeep16 on Apr 27, 2012 3:32 PM