-
Bug
-
Resolution: Can't Do
-
Major
-
None
-
None
-
None
Hi,
I am currently experimenting with EJB.
I receive java.lang.ClassCastException: $Proxy489 cannot be cast to com.jbossatwork.ejb.InventoryFacadeLocalHome
error when I cast the EJBLocalHome object to the Class InventoryFacadeLocalHome.
My JNDI look up is OK.
what could be my problem.
Context c = new InitialContext();
System.out.println( "lookupInventoryFacadeBean");
Object localObj = c.lookup("java:comp/env/ejb/InventoryFacadeLocal");
System.out.println( "1. class name [" +localObj.toString()+"]");
EJBLocalHome localHome = null;
localHome = (EJBLocalHome) localObj;
if (localHome != null) {
System.out.println("localHome is not null");
} else {
System.out.println("localHome is null");
}
System.out.println("2. class name [" + localHome.toString() + "]");
InventoryFacadeLocalHome rv = (InventoryFacadeLocalHome)localHome;
System.out.println("3. class name [" + localHome.toString() + "]");
my output is
15:33:10,015 INFO [EARDeployer] Init J2EE application: file:/C:/Program Files/jboss-4.0.5.GA/server/default/deploy/DreamPlay.ear
15:33:10,656 INFO [EjbModule] Deploying InventoryFacadeBean
15:33:10,656 INFO [EjbModule] Deploying FiboBean
15:33:10,687 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'InventoryFacadeBean' to jndi 'InventoryFacadeLocal'
15:33:10,687 INFO [ProxyFactory] Bound EJB Home 'InventoryFacadeBean' to jndi 'InventoryFacadeRemote'
15:33:10,687 INFO [ProxyFactory] Bound EJB Home 'FiboBean' to jndi 'FiboRemote'
15:33:10,687 INFO [EJBDeployer] Deployed: file:/C:/Program Files/jboss-4.0.5.GA/server/default/tmp/deploy/tmp31233DreamPlay.ear-contents/DreamPlay-ejb.jar
15:33:11,015 INFO [TomcatDeployer] deploy, ctxPath=/DreamPlay, warUrl=.../tmp/deploy/tmp31233DreamPlay.ear-contents/DreamPlay-webapp-exp.war/
15:33:11,077 INFO [EARDeployer] Started J2EE application: file:/C:/Program Files/jboss-4.0.5.GA/server/default/deploy/DreamPlay.ear
15:33:13,999 INFO [STDOUT] lookupInventoryFacadeBean
15:33:13,999 INFO [STDOUT] 1. class name [InventoryFacadeLocalHome]
15:33:13,999 INFO [STDOUT] localHome is not null
15:33:13,999 INFO [STDOUT] 2. class name [InventoryFacadeLocalHome]
15:33:13,999 ERROR [[Controller]] Servlet.service() for servlet Controller threw exception
java.lang.ClassCastException: $Proxy513 cannot be cast to com.jbossatwork.ejb.InventoryFacadeLocalHome
at ControllerServlet.lookupInventoryFacadeBean2(ControllerServlet.java:456)
at ControllerServlet.processRequest(ControllerServlet.java:163)
at ControllerServlet.doGet(ControllerServlet.java:145)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
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:96)
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.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
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:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
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:619)