You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by sameeh harfoush <sa...@hotmail.com> on 2006/11/23 08:05:51 UTC
ClassCastException when deserializing complex java objects (VOs)
I am building a prototype that covers Spring webservices implementation.
I have a SpringProducer web application that provide services and a
SpringConsumer web application
that uses these services.
everything is working just fine except a ClassCastException when
deserializing complex java objects that had been serialized by axis.
Also the same error appears when serializing any complex java objects method
parameters.
I provided in this mail with all the details and classes used including the
exception stack trace.
My progress is blocked with this error.
NB: i am using asis1.4 (axis release and related jars that came with
spring-framework-2.0-m4-with-dependencies.zip)
Thank you.
[server-config.xml]
<service name="EmployeeService" provider="java:RPC" style="rpc"
use="encoded">
<parameter name="allowedMethods" value="*"/>
<parameter name="scope" value="Session"/>
<parameter name="className"
value="com.softsolutions.springproducer.remote.emp.impl.RemoteEmployeeBOImpl"/>
<beanMapping qname="SpringProducerServices:EmployeeVO"
xmlns:SpringProducerServices="http://www.softsolutions.fr"
languageSpecificType="java:com.softsolutions.springproducer.vo.emp.EmployeeVO"/>
</service>
[Service interface]
package com.softsolutions.springproducer.bo.emp;
import com.softsolutions.springproducer.vo.emp.EmployeeVO;
import com.softsolutions.springproducer.vo.emp.*;
public interface EmployeeBO
{
EmployeeVO getEmptyEmployee();
}
[Service interface implementation]
package com.softsolutions.springproducer.bo.emp.impl;
import java.util.*;
import com.softsolutions.common.base.*;
import com.softsolutions.springproducer.bo.emp.*;
import com.softsolutions.springproducer.dao.emp.*;
import com.softsolutions.springproducer.vo.emp.*;
public class EmployeeBOImpl
extends BaseBO implements EmployeeBO
{
private EmployeeDAO employeeDAO;
public EmployeeVO getEmptyEmployee()
{
//dummy application no DB access
return new EmployeeVO();
}
public void setEmployeeDAO(EmployeeDAO employeeDAO)
{
this.employeeDAO = employeeDAO;
}
public EmployeeDAO getEmployeeDAO()
{
return employeeDAO;
}
}
[Remote interface:]
package com.softsolutions.springproducer.remote.emp;
import java.rmi.*;
import com.softsolutions.springproducer.vo.emp.EmployeeVO;
public interface RemoteEmployeeBO
extends Remote
{
EmployeeVO getEmptyEmployee()
throws RemoteException;
}
[Remote interface implementation]
package com.softsolutions.springproducer.remote.emp.impl;
import org.springframework.remoting.jaxrpc.ServletEndpointSupport;
import com.softsolutions.springproducer.remote.emp.RemoteEmployeeBO;
import com.softsolutions.springproducer.vo.emp.EmployeeVO;
import java.rmi.RemoteException ;
import com.softsolutions.springproducer.bo.emp.EmployeeBO;
import org.springframework.context.ApplicationContext;
public class RemoteEmployeeBOImpl
extends ServletEndpointSupport implements RemoteEmployeeBO
{
private EmployeeBO employeeBO = null;
ApplicationContext appContext = null;
protected void onInit()
{
appContext = getApplicationContext();
employeeBO = (EmployeeBO) appContext.getBean("employeeBO");
}
public EmployeeVO getEmptyEmployee()
throws RemoteException
{
return employeeBO.getEmptyEmployee();
}
}
[EmployeeVO Class:]
package com.softsolutions.springproducer.vo.emp;
import java.util.*;
import java.io.Serializable;
public class EmployeeVO implements Serializable
{
private Integer id;
private String name;
private String address;
private Date applicationDate;
private String telephone;
public Integer getId()
{
return id;
}
public String getName()
{
return name;
}
public String getAddress()
{
return address;
}
public Date getApplicationDate()
{
return applicationDate;
}
public String getTelephone()
{
return telephone;
}
public void setId(Integer id)
{
this.id = id;
}
public void setName(String name)
{
this.name = name;
}
public void setAddress(String address)
{
this.address = address;
}
public void setApplicationDate(Date applicationDate)
{
this.applicationDate = applicationDate;
}
public void setTelephone(String telephone)
{
this.telephone = telephone;
}
}
[BO bean in client BOContext.xml]
<bean id="employeeBORPC"
class="com.softsolutions.springconsumer.proxy.EmployeeRpcProxyFactoryBean">
<property name="wsdlDocumentUrl">
<value>http://10.1.6.109:7003/SpringProducer/services/EmployeeService?wsdl</value>
</property>
<property name="namespaceUri">
<value>http://10.1.6.109:7003/SpringProducer/services/EmployeeService</value>
</property>
<property name="serviceName">
<value>RemoteEmployeeBOImplService</value>
</property>
<property name="portName">
<value>EmployeeService</value>
</property>
<property name="serviceInterface">
<value>com.softsolutions.springproducer.bo.emp.EmployeeBO</value>
</property>
<property name="portInterface">
<value>com.softsolutions.springproducer.remote.emp.RemoteEmployeeBO
</value>
</property>
</bean>
[Registering complex types]
package com.softsolutions.springconsumer.proxy;
import org.springframework.remoting.jaxrpc.*;
import javax.xml.rpc.Service;
import javax.xml.namespace.QName;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory ;
import javax.xml.rpc.encoding.TypeMapping;
import javax.xml.rpc.encoding.TypeMappingRegistry;
import com.softsolutions.springproducer.vo.emp.EmployeeVO;
public class EmployeeRpcProxyFactoryBean
extends JaxRpcPortProxyFactoryBean
{
protected void postProcessJaxRpcService(Service service)
{
TypeMappingRegistry registry = service.getTypeMappingRegistry ();
TypeMapping mapping = registry.createTypeMapping();
registerBeanMapping(mapping, EmployeeVO.class, "EmployeeVO");
registry.register("http://schemas.xmlsoap.org/soap/encoding/ ", mapping);
}
protected void registerBeanMapping(TypeMapping mapping, Class type, String
name)
{
QName qName = new QName("http://www.softsolutions.fr", name);
mapping.register (type, qName,
new BeanSerializerFactory(type, qName),
new BeanDeserializerFactory(type, qName));
}
}
I am injecting the employeeBORPC bean as
com.softsolutions.springproducer.bo.emp.EmployeeBO
and when calling the getEmptyEmployee() method the following error is
generated
java.lang.ClassCastException
at
weblogic.xml.schema.binding.RuntimeUtils.getDeserializer(RuntimeUtils.java:363)
at
weblogic.xml.schema.binding.RuntimeUtils.invoke_deserializer(RuntimeUtils.java:425)
at
weblogic.xml.schema.binding.RuntimeUtils.invoke_deserializer(RuntimeUtils.java:328)
at weblogic.webservice.core.DefaultPart.toJava(DefaultPart.java:384)
at weblogic.webservice.core.DefaultMessage.toJava
(DefaultMessage.java:484)
at
weblogic.webservice.core.ClientDispatcher.receive(ClientDispatcher.java:325)
at
weblogic.webservice.core.ClientDispatcher.dispatch(ClientDispatcher.java:144)
at
weblogic.webservice.core.DefaultOperation.invoke(DefaultOperation.java:457)
at
weblogic.webservice.core.DefaultOperation.invoke(DefaultOperation.java:443)
at weblogic.webservice.core.rpc.StubImpl._invoke (StubImpl.java:303)
at weblogic.webservice.core.rpc.StubImpl.invoke(StubImpl.java:247)
at $Proxy10.getEmptyEmployee(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 java.lang.reflect.Method.invoke (Method.java:324)
at
org.springframework.remoting.rmi.RmiClientInterceptorUtils.doInvoke(RmiClientInterceptorUtils.java:103)
at
org.springframework.remoting.rmi.RmiClientInterceptorUtils.invoke(RmiClientInterceptorUtils.java
:71)
at
org.springframework.remoting.jaxrpc.JaxRpcPortClientInterceptor.invoke(JaxRpcPortClientInterceptor.java:530)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java
:170)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy11.getEmptyEmployee(Unknown Source)
at
com.softsolutions.springconsumer.web.struts.emp.action.EmployeeGridAction.loadEmpList
(EmployeeGridAction.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
at com.softsolutions.common.base.BaseAction.dispatchMethod
(BaseAction.java:533)
at
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
at
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost
(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:1006)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6718)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3764)
at weblogic.servlet.internal.ServletRequestImpl.execute
(ServletRequestImpl.java:2644)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
Deployment order under BEA8.1 SP4:
....
axis.jar
jaxrpc.jar
wsdl4j-1.5.1.jar
webservices.jar
.....
Note that this order is set in class path of startWebLogic.cmd
_________________________________________________________________
Don't just search. Find. Check out the new MSN Search!
http://search.msn.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org