4 Replies Latest reply on May 2, 2006 10:45 PM by spicagao

    java.lang.ClassCastException: org.jboss.axis.Message

    greenbean

      We are using jboss 4.03SP1. We are receiving JMS messages using Activemq/spring/jencks. The onMessage acts as a web service client to call a server. We generate the client from the wsdl using jwsdp-1.6. When a message is received, the onMessage throws this exception. It is not clear what the relationship is between AXIS and jaxrpc, and why I am getting this error. Any suggestions?

      java.lang.ClassCastException: org.jboss.axis.Message
      at com.sun.xml.rpc.client.StubBase._postSendingHook(StubBase.java:231)
      at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:324)
      at xxx.xxxPortType_Stub.xxx(xxxPortType_Stub.java:69)
      at xxx.onMessage(xxxBean.java:64)
      at org.jencks.XAEndpoint.onMessage(XAEndpoint.java:126)
      at org.apache.activemq.ra.MessageEndpointProxy$MessageEndpointAlive.onMessage(MessageEndpointProxy.java:120)
      at org.apache.activemq.ra.MessageEndpointProxy.onMessage(MessageEndpointProxy.java:60)
      at org.apache.activemq.ActiveMQSession.run(ActiveMQSession.java:664)
      at org.apache.activemq.ra.ServerSessionImpl.run(ServerSessionImpl.java:163)
      at org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:291)
      at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
      at java.lang.Thread.run(Thread.java:595)

        • 1. Re: java.lang.ClassCastException: org.jboss.axis.Message
          rmerry72

          This seems to be caused by the Sun StubBase class is casting the response message to com.sun.xml.messaging.saaj.soap.MessageImpl as per the decomiled code snippet below:

          MessageImpl response = (MessageImpl)state.getResponse().getMessage();
          if(!useFastInfoset() && response.isFastInfoset())
          _properties.put("com.sun.xml.rpc.client.ContentNegotiation", "optimistic");

          Since JBoss uses an axis message factory the response message is in fact not an instance of MessageImpl but rather org.jboss.axis.Message. Seems to be a very presumptuous cast and all itisdoing isattempting to use FastInfoSet.

          I've yet to find a work around, as this code is part of Sun'sJAX-RPC implementation and the stubs are generated by the developers kit.

          • 2. Re: java.lang.ClassCastException: org.jboss.axis.Message
            rmerry72

            Found a work around. Nasty as it is it does work :-)

            The solution is to override the offending method in the generated stub:

            protected void _postSendingHook(StreamingSenderState state)
             throws Exception
             {
             Object maintainSession = _getProperty("javax.xml.rpc.session.maintain");
             if (maintainSession != null && maintainSession.equals(((Object) (Boolean.TRUE))))
             {
             Object cookieJar = _getProperty("com.sun.xml.rpc.client.http.CookieJar");
             if (cookieJar == null)
             {
             SOAPMessageContext messageContext = state.getMessageContext();
             cookieJar = messageContext.getProperty("com.sun.xml.rpc.client.http.CookieJar");
             _setProperty("com.sun.xml.rpc.client.http.CookieJar", cookieJar);
             }
             }
            // MessageImpl response = (MessageImpl)state.getResponse().getMessage();
            // if(!useFastInfoset() && response.isFastInfoset())
            // _properties.put("com.sun.xml.rpc.client.ContentNegotiation", "optimistic");
             }
            


            This can only be done after the service stub has been generated by wscompile, so you'll have to modify your build to recompile this class after you've generated it. Easy to do every so often if your service doesn' cange much and you can modify it manually every so often. Hard to do automatically as part of a full build from sratch.

            Hope this helps,
            Rick

            • 3. Re: java.lang.ClassCastException: org.jboss.axis.Message
              jordan.rivington

              Could you please explain the work around in a little more detail. Where should this method override go as far as code location? Must I rebuild the library file for axis from source? I dont think so, but I am a little confused. If I put this in my client code, there are access issues with _setProperty and such.

              I always the only stupid question is the one left unasked.

              Thanks for the help.

              Jordan Rivington

              • 4. Re: java.lang.ClassCastException: org.jboss.axis.Message
                spicagao

                Hi

                I get the same problem on 4.0.3 with jwsdp1.6 and workaround it by overwrite _postSendingHook.

                It does work to me but it not a good solution. Since JBoss 4.0.3 still use Axis, how about the JBossWS on 4.0.4?
                Also how about the jwsdp2.0?