[jboss-user] [EJB 3.0] - War to remote EJB fails with ClassCastException

iwalberg do-not-reply at jboss.com
Sat Oct 18 00:45:03 EDT 2008


I'm playing with the Jython/ZK framework, trying to set an application up to get information from an existing Session Bean on a remote server.

I successfully receive the session EJB back from the InitialContext lookup, but when I call any method on it that returns an object, it gets ClassCastException (even if I don't save the result), e.g.:            projectService.getProject(new Long(2));
  |  gets java.lang.ClassCastException: com.comp.data.ProjectDTO cannot be cast to com.comp.data.ProjectDTO, where ProjectDTO is the object passed back from the Session Bean (see log below for stack trace.)
 
If I run the same class outside of a web app (i.e. via its main method) it works.  If I call a method with no return value (i.e. void) it works.  I'm guessing a ClassLoader issue, but I can't for the life of me figure out how (see from the log below, I dumped some classloader info but didn't really know what to look for).

The jar that holds the ProjectDTO class and the service interface is in the war only once in WEB-INF/lib (and I did notice that the path to this jar is not listed in the classloader as a repository).

JBoss-4.2.2.GA on both machines running Linux.
App being developed under NetBeans with Maven plugin.

Any ideas on how to fix this?

23:57:16,690 INFO  [STDOUT] InitialContext Type: javax.naming.InitialContext
23:57:16,690 INFO  [STDOUT] Returned Object Type: $Proxy59
23:57:16,690 INFO  [STDOUT] ClassLoader of Type: WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
java.net.FactoryURLClassLoader at 10e0904
23:57:16,691 INFO  [STDOUT] ClassLoader of This: WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
java.net.FactoryURLClassLoader at 10e0904
23:57:16,691 INFO  [STDOUT] ClassLoader of Thread: WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
java.net.FactoryURLClassLoader at 10e0904
23:57:16,974 ERROR [[zkLoader]] Servlet.service() for servlet zkLoader threw exception
java.lang.ClassCastException: com.comp.data.ProjectDTO cannot be cast to com.comp.data.ProjectDTO
        at $Proxy59.getProject(Unknown Source)
        at com.comp.demo.ProjectManager.getProjects(ProjectManager.java:74)
        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:597)
        at bsh.Reflect.invokeMethod(Unknown Source)
        at bsh.Reflect.invokeObjectMethod(Unknown Source)
        at bsh.Name.invokeMethod(Unknown Source)
        at bsh.BSHMethodInvocation.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHAssignment.eval(Unknown Source)
        at bsh.Interpreter.eval(Unknown Source)
        at bsh.Interpreter.eval(Unknown Source)
        at org.zkoss.zk.scripting.bsh.BSHInterpreter.exec(BSHInterpreter.java:100)
        at org.zkoss.zk.scripting.util.GenericInterpreter.interpret(GenericInterpreter.java:292)
        at org.zkoss.zk.ui.impl.PageImpl.interpret(PageImpl.java:858)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execNonComponent(UiEngineImpl.java:728)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:547)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:492)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:612)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:581)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:525)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:492)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:374)
        at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:296)
        at org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:230)
        at org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:167)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValalve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
        at java.lang.Thread.run(Thread.java:619)

TIA,
Ilane

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4183012#4183012

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4183012



More information about the jboss-user mailing list