4 Replies Latest reply on Jul 22, 2005 1:57 PM by Thomas Diesler

    java.lang.ClassCastException: org.jboss.axis.message.RPCPara

    Barry Sheward Newbie

      Hi,

      I think I'm finally getting the hang of things, but I'm having some weird behaviour.

      I have been able to return an array of TestValueObject objects from a web services server and the client was able to work with the returned array just fine. The client code (a JUnit test) is:

       public void testObjectArray() throws Exception {
       Service service = getService();
       WebServicesTest svc = (WebServicesTest) service.getPort(WebServicesTest.class);
       TestValueObject[] tvoa = svc.getValueObjectArray();
       System.out.println( "WebServicesTest.getValueObjectArray() returned:" + tvoa.toString() );
       assertNotNull( tvoa );
       assertEquals( WebServicesTestBean.TEST_VALUE_OBJECT_ARRAY.length, tvoa.length );
       for( int i = 0; i < tvoa.length; i++ ) {
       System.out.println( " Testing element " + i + " " +
       WebServicesTestBean.TEST_VALUE_OBJECT_ARRAY[ i ] + " = " +
       tvoa[ i ] );
       TestValueObject tvo = tvoa[ i ];
       assertEquals( WebServicesTestBean.TEST_VALUE_OBJECT_ARRAY[ i ], tvo );
       }
       }
      


      The fact that this works surprised me, because almost identical code which works with a scalar TestValueObject fails with an exception!

      The code for working with a scalar TestValueObject is:

       public void testObjectResult() throws Exception {
       Service service = getService();
       WebServicesTest svc = (WebServicesTest) service.getPort(WebServicesTest.class);
       TestValueObject tvo = svc.getValueObject();
       System.out.println( "WebServicesTest.getValueObject() returned:" + tvo.toString() );
       assertNotNull( tvo );
       assertEquals( WebServicesTestBean.TEST_VALUE_OBJECT, tvo );
       }
      


      The exception which gets thrown is shown below:

      There was 1 error:
      1) testObjectResult(com.cybertrust.rmp2.test.wsee.WebServicesTestClient)java.rmi.RemoteException: org.jboss.axis.message.RPCParamElementImpl; nested exception is:
       java.lang.ClassCastException: org.jboss.axis.message.RPCParamElementImpl
       at org.jboss.webservice.client.PortProxy.invoke(PortProxy.java:176)
       at $Proxy1.getValueObject(Unknown Source)
       at com.cybertrust.rmp2.test.wsee.WebServicesTestClient.testObjectResult(WebServicesTestClient.java:149)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at com.cybertrust.rmp2.test.wsee.WebServicesTestClient.main(WebServicesTestClient.java:188)
      Caused by: java.lang.ClassCastException: org.jboss.axis.message.RPCParamElementImpl
       at $Proxy0.getValueObject(Unknown Source)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at org.jboss.webservice.client.PortProxy.invoke(PortProxy.java:105)
       ... 20 more
      
      FAILURES!!!
      Tests run: 6, Failures: 0, Errors: 1
      


      If anyone could help me diagnose this problem, I'd really appreciate it!

      Thanks and Regards,

      Barry


        • 1. Re: java.lang.ClassCastException: org.jboss.axis.message.RPC
          Barry Sheward Newbie

          In case it is relevant, my implementation of getService() is:

           protected Service getService( ) throws MalformedURLException, ServiceException {
           URL wsdlLocation = new URL( urlstr );
           URL mappingLocation = this.getClass().getClassLoader().getResource( "META-INF/jaxrpc-mapping.xml" );
           URL ws4eeMetaData = null;
           QName serviceName = new QName( serviceUrn, this.serviceName );
           String portName = null;
          
           org.jboss.webservice.client.ServiceFactoryImpl factory = (org.jboss.webservice.client.ServiceFactoryImpl) ServiceFactory.newInstance();
           Service service = factory.createService( wsdlLocation, mappingLocation, ws4eeMetaData, serviceName, portName);
          
           return service;
           }
          


          • 2. Re: java.lang.ClassCastException: org.jboss.axis.message.RPC
            Barry Sheward Newbie

            This strange behaviour does not just happen with returned values, I also have problems when passing parameters. Parameters which are arrays of objects work fine, but parameters which are scalar objects fail.

            For example, the following code fails:

             public void testObjectParam() throws Exception {
             Service service = getService();
             WebServicesTest svc = (WebServicesTest) service.getPort(WebServicesTest.class);
             TestValueObject tvo = svc.getValueObjectParam( new TestValueObject() );
             System.out.println( "WebServicesTest.getValueObjectParam() returned:" + tvo.toString() );
             assertNotNull( tvo );
             }
            


            While this test case works:

             public void testObjectArrayParam() throws Exception {
             Service service = getService();
             WebServicesTest svc = (WebServicesTest) service.getPort(WebServicesTest.class);
            
             TestValueObject[] tvoa = new TestValueObject[ 3 ];
             for( int i=0; i < tvoa.length; i++ ) {
             tvoa[ i ] = new TestValueObject();
             tvoa[ i ].setInt( i );
             tvoa[ i ].setString( "Element " + i );
             }
             TestValueObject[] tvoa2 = svc.getValueObjectArrayParam( tvoa );
             for( int i=0; i < tvoa2.length; i++ ) {
             System.out.println( "WebServicesTest.getValueObjectArrayParam() [" + i + "] returned:" + tvoa2.toString() );
             }
             assertNotNull( tvoa2 );
             }
            


            The server throws the following exception message:


            10:43:11,873 ERROR [RPCInvocation] org.xml.sax.SAXException: Deserializing parameter 'testValueObject': could not find deserializer for type {http://www.w3.org/2001/XMLSchema}anyType
            org.xml.sax.SAXException: Deserializing parameter 'testValueObject': could not find deserializer for type {http://www.w3.org/2001/XMLSchema}anyType
            at org.jboss.axis.message.RPCHandler.onStartChild(RPCHandler.java:326)
            at org.jboss.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:1168)
            at org.jboss.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:244)
            at org.jboss.axis.message.SOAPElementAxisImpl.publishToHandler(SOAPElementAxisImpl.java:1386)
            at org.jboss.axis.message.RPCElement.deserialize(RPCElement.java:262)
            at org.jboss.axis.message.RPCElement.getParams(RPCElement.java:396)
            at org.jboss.axis.providers.java.RPCInvocation.prepareFromRequestEnvelope(RPCInvocation.java:235)
            at org.jboss.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:103)
            at org.jboss.axis.providers.java.JavaProvider.invoke(JavaProvider.java:358)
            at org.jboss.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:73)
            at org.jboss.axis.SimpleChain.doVisiting(SimpleChain.java:160)
            at org.jboss.axis.SimpleChain.invoke(SimpleChain.java:123)
            at org.jboss.axis.handlers.soap.SOAPService.invoke(SOAPService.java:560)
            at org.jboss.webservice.server.ServerEngine.invokeInternal(ServerEngine.java:200)
            at org.jboss.webservice.server.ServerEngine.invoke(ServerEngine.java:89)
            at org.jboss.axis.transport.http.AxisServlet.doPost(AxisServlet.java:905)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
            at org.jboss.axis.transport.http.AxisServletBase.service(AxisServletBase.java:370)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
            at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
            at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
            at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
            at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
            at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
            at java.lang.Thread.run(Thread.java:595)


            My w4ee-deployment.xml file looks like:

            <deployment
             xmlns='http://xml.apache.org/axis/wsdd/'
             xmlns:java='http://xml.apache.org/axis/wsdd/providers/java'
             xmlns:soap='http://schemas.xmlsoap.org/soap/encoding/'
             xmlns:xsi='http://www.w3.org/2000/10/XMLSchema-instance'
             xmlns:xsd='http://www.w3.org/2001/XMLSchema'
             xmlns:ns2='http://interfaces.rmp2.cybertrust.com/types'
             xmlns:ns3='urn-com-cybertrust-rmp2-session'>
            
             <typeMapping
             qname='ns2:TestValueObject'
             type='java:com.cybertrust.rmp2.vo.TestValueObject'
             serializer='org.jboss.webservice.encoding.ser.MetaDataBeanSerializerFactory'
             deserializer='org.jboss.webservice.encoding.ser.MetaDataBeanDeserializerFactory'
             encodingStyle=''>
             <typeDesc>
             <elementDesc fieldName='int' xmlName='int'/>
             <elementDesc fieldName='string' xmlName='string'/>
             <elementOrder>
             <element name='int'/>
             <element name='string'/>
             </elementOrder>
             </typeDesc>
             </typeMapping>
            
            </deployment>
            


            Any assistance would be appreciated!

            Thanks and Regards,

            Barry


            • 3. Re: java.lang.ClassCastException: org.jboss.axis.message.RPC
              Gene Gotimer Newbie

              Try delaying a few seconds (say 5), and then close the stream. That will flush the pipe.

              We had this same problem with OracleAS a while back.

              • 4. Re: java.lang.ClassCastException: org.jboss.axis.message.RPC
                Thomas Diesler Master

                Can you create a simple test deployment that reproduces what you are seeing and attach it to a JIRA issue?