tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject java.lang.ClassCastException: $Proxy8
Date Mon, 02 Feb 2009 10:01:49 GMT

I am trying to run a simple OpenEJB project using JSP and Tomcat. I could not find a proper
way to reference EJB from JSP so I tired using the same code that works fine in a unit test,
but not in JSP.

        Properties p = new Properties();
	p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
	InitialContext initialContext = new InitialContext( p );
	Object o = initialContext.lookup("SayHelloLocal");
	SayHelloLocal local = (SayHelloLocal)o;

However, during the cast operation on the last line above, the class loader throws java.lang.ClassCastException:
$Proxy8. This seems to happen when JasperClassLoader trying to load the SayHelloLocal class.

I am using the latest OpenEJB release so I only have the ejb-jar.xml file and I use annotations
to discover and load EJBs. This works fine during unit testing.

Is there a correct way to reference the EJB from JSP using JNDI name that works with OpenEJB?
Did I not set the classpath correctly for Tomcat? I am using Tomcat 6.0. The below output
is from Console window within Eclipse 3.4.


Feb 2, 2009 10:40:21 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source'
to 'org.eclipse.jst.jee.server:SayHelloWeb' did not find a matching property.
Feb 2, 2009 10:40:21 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production
environments was not found on the java.library.path: /usr/java/jdk1.5.0_16/jre/lib/i386/client:/usr/java/jdk1.5.0_16/jre/lib/i386:/usr/java/jdk1.5.0_16/jre/../lib/i386:/opt/MozillaFirefox/lib
Feb 2, 2009 10:40:21 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Feb 2, 2009 10:40:21 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1004 ms
Feb 2, 2009 10:40:21 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Feb 2, 2009 10:40:22 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
Feb 2, 2009 10:40:23 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Feb 2, 2009 10:40:23 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /
Feb 2, 2009 10:40:24 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/124  config=null
Feb 2, 2009 10:40:24 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2163 ms
Apache OpenEJB 3.1    build: 20081009-03:31
INFO - openejb.home = /home/aglabek
INFO - openejb.base = /home/aglabek
INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default
Security Service)
INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default
Transaction Manager)
INFO - Found EjbModule in classpath: /home/aglabek/.eclipse/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/SayHelloWeb/WEB-INF/lib/SayHello.jar
INFO - Beginning load: /home/aglabek/.eclipse/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/SayHelloWeb/WEB-INF/lib/SayHello.jar
INFO - Configuring enterprise application: classpath.ear
INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default
Stateless Container)
INFO - Auto-creating a container for bean SayHello: Container(type=STATELESS, id=Default Stateless
INFO - Enterprise application "classpath.ear" loaded.
INFO - Assembling app: classpath.ear
INFO - Jndi(name=SayHelloLocal) --> Ejb(deployment-id=SayHello)
INFO - Jndi(name=SayHelloRemote) --> Ejb(deployment-id=SayHello)
INFO - Created Ejb(deployment-id=SayHello, ejb-name=SayHello, container=Default Stateless
INFO - Deployed Application(path=classpath.ear)
Feb 2, 2009 10:40:30 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.ClassCastException: $Proxy8
	at org.apache.jsp.index_jsp._jspService(
	at org.apache.jasper.runtime.HttpJspBase.service(
	at javax.servlet.http.HttpServlet.service(
	at org.apache.jasper.servlet.JspServletWrapper.service(
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(
	at org.apache.jasper.servlet.JspServlet.service(
	at javax.servlet.http.HttpServlet.service(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at org.apache.catalina.core.StandardWrapperValve.invoke(
	at org.apache.catalina.core.StandardContextValve.invoke(
	at org.apache.catalina.core.StandardHostValve.invoke(
	at org.apache.catalina.valves.ErrorReportValve.invoke(
	at org.apache.catalina.core.StandardEngineValve.invoke(
	at org.apache.catalina.connector.CoyoteAdapter.service(
	at org.apache.coyote.http11.Http11Processor.process(
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(

View raw message