activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AlexP <activ...@standardset.com>
Subject Accessing ws:// in embedded ActiveMQ 5.8.0 produces NullPointerException
Date Sat, 24 Aug 2013 19:32:16 GMT
Dear ActiveMQ Users:

I am trying to embed the broker in my Java web application.  Using Spring
@Configuration, I create a broker and register some connectors:

        //Create Broker
        final BrokerService broker = new BrokerService();

        //Create the network connector
        //
        final TransportConnector
            tcpConnector =
                broker.addConnector(tcpURI),
            stompConnector =
                broker.addConnector(stompURI),
            wsConnector =
                broker.addConnector("ws://0.0.0.0:61633");

        //Start broker
        broker.start();

Broker starts without any exceptions or issues.  The TCP connector seems to
be working OK.  I am able to connect and send messages.  However, when I try
to connect to the ws://localhost:61633 via a WebSocket, I get this
exception:

12:17:31.494 engine [qtp131915922-54] WARN  ServletHandler - /
java.lang.NullPointerException: null
	at
org.apache.activemq.transport.ws.StompServlet.doGet(StompServlet.java:47)
~[activemq-optional-5.7.0.jar:5.7.0]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
~[servlet-api-3.0.20100224.jar:na]
	at
org.eclipse.jetty.websocket.WebSocketServlet.service(WebSocketServlet.java:86)
~[jetty-websocket-8.0.0.M2.jar:8.0.0.M2]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
~[servlet-api-3.0.20100224.jar:na]
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652)
~[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:447)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1038)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:374)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:972)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at org.eclipse.jetty.server.Server.handle(Server.java:363)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at
org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:483)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at
org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:920)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at
org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:982)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:627)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:51)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
[jetty-all-server-7.6.7.v20120910.jar:8.0.0.M2]
	at java.lang.Thread.run(Thread.java:680) [na:1.6.0_41]

The error occurs in this method:

    protected void doGet(HttpServletRequest request, HttpServletResponse
response)
        throws ServletException ,IOException  {
       
getServletContext().getNamedDispatcher("default").forward(request,response);
    }

It turns out, that  getServletContext().getNamedDispatcher("default")
returns a Null, so the forward gets a NullPointerException.

It seems that performing a broker.start(), does not start something, or
perhaps I am missing some configuration.  I am not quite sure.  It feels
like my Servlet context is not properly initialized or something when
broker.start() is called.

My application is a Web Application (.war) hosted by Jetty.  So, it does
seem that I am starting a Jetty inside of Jetty, but this should not be an
issue due to class-path isolation (I think).

Obviously, I tried this in stand alone version of ActiveMQ and it works
perfectly.  So, something is missing from my startup in an embedded
configuration.

I know this is a very specific question, but I would love to have the broker
running embedded and handling the ws:// requests.

If you have some experience with this, please let me know what I could try
to work around this issue.

Thanks.
-AP_

     






--
View this message in context: http://activemq.2283324.n4.nabble.com/Accessing-ws-in-embedded-ActiveMQ-5-8-0-produces-NullPointerException-tp4670657.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message