Re: EJB Injection
Florent BENOIT <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.jonas |
|---|---|
| Message-ID | <[email protected]> |
Hi, If your EJB have two interfaces (local and remote) then the mappedName is applying to both... Then, I think that it tries to inject the remote interface into the servlet which is failing. Why do you need to specify a JNDI name ? You can use @EJB on the client side too when running the client in the client container. It will then inject remote proxy on the client side and the local proxy in the web side. Regards, Florent [email protected] wrote: > > Hello, > > I'm having problems w/EJB injection. > > In my session bean implementation I annotate like this: > > @Stateless(name="fm") > > and I consume this in a servlet like this: > > @EJB(name="fm") > private FrameMakerLocal fm; > > This works fine. But now I want to define the remote name of the EJB > so I changed the bean annotation to this (leaving the servlet > injection unchanged): > > @Stateless(name="fm", mappedName="com.myco.FrameMaker") > > Now I get an exception on the injection in the servlet: > > java.lang.IllegalArgumentException: Can not set > com.aviall.frame.FrameMakerLocal field > com.aviall.servlet.StartupShutdown.com$aviall$servlet$StartupShutdown$$fm > to $Proxy50 > at > sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146) > > at > sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150) > > at > sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63) > > at java.lang.reflect.Field.set(Field.java:657) > at > org.apache.catalina.util.DefaultAnnotationProcessor.lookupFieldResource(DefaultAnnotationProcessor.java:297) > > at > org.apache.catalina.util.DefaultAnnotationProcessor.processAnnotations(DefaultAnnotationProcessor.java:177) > > at > org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3881) > > at > org.apache.catalina.core.StandardContext.start(StandardContext.java:4429) > at > org.ow2.jonas.web.tomcat6.JOnASStandardContext.start(JOnASStandardContext.java:281) > > at > org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) > > at > org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) > at > org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526) > at > org.ow2.jonas.web.tomcat6.Tomcat6Service.__doRegisterWar(Tomcat6Service.java:699) > > at > org.ow2.jonas.web.tomcat6.Tomcat6Service.doRegisterWar(Tomcat6Service.java) > > at > org.ow2.jonas.web.base.BaseWebContainerService.registerWar(BaseWebContainerService.java:918) > > at > org.ow2.jonas.web.base.BaseWebContainerService.deployWars(BaseWebContainerService.java:1538) > > at > org.ow2.jonas.ear.internal.EarDeployer.deployWARs(EarDeployer.java:1081) > at > org.ow2.jonas.ear.internal.EarDeployer.doDeploy(EarDeployer.java:785) > at > org.ow2.util.ee.deploy.impl.deployer.AbsDeployer$1.execute(AbsDeployer.java:96) > > at > org.ow2.util.ee.deploy.impl.deployer.AbsDeployer$1.execute(AbsDeployer.java:95) > > at > org.ow2.util.execution.helper.RunnableHelper.execute(RunnableHelper.java:77) > > at > org.ow2.util.ee.deploy.impl.deployer.AbsDeployer.deploy(AbsDeployer.java:94) > > at > org.ow2.util.ee.deploy.impl.deployer.DeployerManager.deploy(DeployerManager.java:129) > > at > org.ow2.jonas.deployablemonitor.DeployableMonitor.detectNewArchives(DeployableMonitor.java:443) > > at > org.ow2.jonas.deployablemonitor.DeployableMonitor.checkNewArchives(DeployableMonitor.java:265) > > at > org.ow2.jonas.deployablemonitor.DeployableMonitor.run(DeployableMonitor.java:175) > > > Any ideas? > What I'm trying to do is this: Directly inject my local EJB into a > war (packaged in same EAR as my ejb.jar file) and also publish the > remote EJB interface with a given JNDI name (overriding Jonas default > naming). > Thanks, > Greg > > "If I had asked my customers what they wanted, they would have said 'A > faster horse'" -- Henry Ford