1 Reply Latest reply on Aug 2, 2010 3:03 PM by tomj

    NullPointerException using java to send message

    dave.brininstool

      I have a flex application using 3.x and BlazeDS 3.x that calls a servlet. In the servlet I have the following

                  MessageBroker msgBroker = MessageBroker.getMessageBroker(null);

                  msgBroker.addDefaultChannel("my-channel");

       

                  AsyncMessage msg = new AsyncMessage();

                  msg.setDestination("vle_topic");

                  String clientID = UUIDUtils.createUUID();

                  msg.setClientId(request.getSession().getId()); //clientID);

                  msg.setMessageId(UUIDUtils.createUUID());

                  msg.setTimestamp(System.currentTimeMillis());

                  msg.setBody("servlet example event");

                  msgBroker.routeMessageToService(msg, null);

      When the servlet is called, I get a NullPointerException with the following output in the tomcat log:
      [BlazeDS] 06/23/2010 16:44:12.254 [ERROR] [Message.General] Exception when invoking service: message-service
        with message: Flex Message (flex.messaging.messages.AsyncMessage)
          clientId = 8539568E76F27D9B515F9947CFC30545
          correlationId = null
          destination = vle_topic
          messageId = 146C4633-321A-3920-1CE7-E5E9DB212EA6
          timestamp = 1277333052242
          timeToLive = 0
          body = servlet example event
        exception: java.lang.NullPointerException
      at flex.messaging.FlexContext.isPerClientAuthentication(FlexContext.java:264)
      at flex.messaging.FlexContext.getUserPrincipal(FlexContext.java:279)
      at flex.messaging.security.LoginManager.getCurrentPrincipal(LoginManager.java:348)
      at flex.messaging.security.LoginManager.checkConstraint(LoginManager.java:291)
      at flex.messaging.MessageBroker.inspectOperation(MessageBroker.java:1683)
      at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1406)
      at com.sun.vle.bui.vmvc.AddVmvcsServlet.doPost(AddVmvcsServlet.java:52)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j ava:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:567)
      at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:421)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.ja va:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
      at java.lang.Thread.run(Thread.java:637)
      Anybody know what is wrong? I suspect it has do with the security setup in the application. We use a custom realm and require a user to login to access the application.
      Thanks,
      Dave Brininstool