axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Schweisguth <>
Subject ClassCastException with dynamic proxies and bean mapping?
Date Wed, 08 Oct 2003 22:00:52 GMT
Dear axis-users,

I'm able to call a service which returns a bean via Call, but not via
dynamic proxies. In the following test code, the block of code which uses
Call succeeds but the following block, which uses a Stub, fails with a

      // Create the service
      Service service = ServiceFactory.newInstance().createService(
         new URL(wsdlURL), new QName(serviceNamespaceURI, wsdlServiceName));

      // Register the type mapping
      TypeMappingRegistry typeMappingRegistry =
      TypeMapping typeMapping = typeMappingRegistry.getTypeMapping(
      QName type = new QName("urn:Echo", StringWrapper.class.getName());
      typeMapping.register(StringWrapper.class, type,
         new BeanSerializerFactory(StringWrapper.class, type),
         new BeanDeserializerFactory(StringWrapper.class, type));

      // Make the call via Call
      Call call = service.createCall();
         new QName(serviceNamespaceURI, "echoStringWrapper"));
      call.invoke(new Object[] { new StringWrapper("Hi Mom!") });

      // Make the call via Stub
      Stub stub = (Stub) service.getPort(Echo.class);
      ((Echo) stub).echoStringWrapper(new StringWrapper("Hi Mom!"));

StringWrapper is a test bean with a single String member. Note that in
both cases I'm ignoring the actual return value; the ClassCastException
in the latter occurs before the return. Here it is:

1) testEchoStringWrapperCall(Test)java.lang.ClassCastException
    at $Proxy0.echoStringWrapper(Unknown Source)
    at Test.testEchoStringWrapperCall(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at com.intellij.rt.execution.junit.TextTestRunner.main(

I inspected the return value in a debugger before it returned from the
InvocationHandler implementation. It appears to be a correctly initialized
StringWrapper, with the same ClassLoader as the StringWrapper in my test
code. Nonetheless, the error occurs. Can anyone suggest a solution?


| Dave Schweisguth              |
| Home:          Work: |
| For compliance with the NJ Right to Know Act: Contents partially unknown |

View raw message