Hello All,
I'm trying to get my head round OpenEJB and unsure what I'm currently
missing in my test projects.

Basically, I've created a Java project with the necessary libraries (mainly
pointing at OpenEJB/lib) with a Remote interface and an implementation.
I'm actually using CalculatorRemote and CalculatorImpl from the supplied
examples.
Compiled and exported to an EJB3 Jar (MyEJB.jar)

I've got OpenEJB3 working with Tomcat6 - installation is successful and all
tests return OK.
Hence, I've deployed MyEJB.jar using openejb.xml:
<Deployments dir="/Developer/OpenEJB3/apps/" /> (the jar file is in there).

Booted Tomcat within Eclipse and verified openejb.log. Success: MyEJB.jar is
picked up and added.
Extract:
2009-08-02 20:40:43,501 - INFO  - Assembling app:
/Developer/OpenEJB3/apps/MyEJB.jar
2009-08-02 20:40:43,590 - INFO  - Jndi(name=CalculatorImplRemote) -->
Ejb(deployment-id=CalculatorImpl)
2009-08-02 20:40:43,596 - INFO  - Created Ejb(deployment-id=CalculatorImpl,
ejb-name=CalculatorImpl, container=My Stateless Container)
2009-08-02 20:40:43,596 - INFO  - Deployed
Application(path=/Developer/OpenEJB3/apps/MyEJB.jar)

Now this is where I got in trouble:
The docs seem to imply that from there on, my webapps should be able to use
any EJB that OpenEJB3 found and initialized.
Hence I created a Dynamic Web Project on the same Tomcat server with a very
simple servlet called TestServlet and tried to inject the EJB as follows:

@EJB private CalculatorRemote calc;

The servlet is otherwise 'empty'.
I restart Tomcat after after my new Web Project as module. Upon initialising
my project it bombs out. The error log seems to indicate OpenEJB is having
trouble finding the right class (or something like that...).

context path = /MyWeb
java.lang.reflect.InvocationTargetException
        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 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.NoClassDefFoundError: Could not fully load class:
com.riaz.TestServlet
 due to:Lfarm/web/CalculatorRemote;
 in classLoader: 
org.apache.openejb.core.tempclassloa...@5332f20b
        at org.apache.xbean.finder.ClassFinder.<init>(ClassFinder.java:177)
        at
org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.createInheritedClassFinder(AnnotationDeployer.java:2958)
        at
org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.deploy(AnnotationDeployer.java:909)
        at
org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:198)
        at
org.apache.openejb.tomcat.catalina.TomcatWebAppBuilder.createWebModule(TomcatWebAppBuilder.java:662)
        at
org.apache.openejb.tomcat.catalina.TomcatWebAppBuilder.loadApplication(TomcatWebAppBuilder.java:541)
        at
org.apache.openejb.tomcat.catalina.TomcatWebAppBuilder.start(TomcatWebAppBuilder.java:242)
        at
org.apache.openejb.tomcat.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:58)
        at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4252)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at 
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at 
org.apache.catalina.core.StandardService.start(StandardService.java:516)
        at 
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
        ... 6 more

I've read the Geronimo Server docs and know it uses a deployment plan
strategy to make the webapp 'aware' of the EJB.
Is there something similar I need to do when using OpenEJB with Tomcat?

Any help would be much much appreciated - thank you.

Riaz


-- 
View this message in context: 
http://www.nabble.com/Failing-to-inject-%40EJB-into-a-servlet-tp24781514p24781514.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to