aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB access from within a EJB using @EJB is failing in Sun Application Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB access from within a EJB using @EJB is failing in Sun Application Server" Watch "EJB access from within a EJB using @EJB is failing in Sun Application Server" New topic
Author

EJB access from within a EJB using @EJB is failing in Sun Application Server

Bidyut Majumdar
Greenhorn

Joined: Aug 13, 2009
Posts: 2
Problem statement:

We have two session beans in two different EJB modules deployed in Sun Java Application Server 9.1.

The name of the session bean are as follows:

Source Session Bean EJB Module contains:

1>SourceSessionBean
2>SourceSessionBeanRemote
3>SourceSessionBeanLocal

Target Session Bean EJB Module contains:
1>TargetSession Bean
2>TargetSession BeanRemote
3>TargetSession BeanLocal

We are trying to access the Target Session bean through it's Remote Interface from the Source Session Bean using dependency injection with the annotation as follows:

@EJB TargetSessionBeanRemote objTargetSessionBeanRemote;

Deployment:

We have deployed the target session bean first & then tried to deploy the source session bean. That produced the following error:

=================================================================================
[#|2009-08-11T17:44:27.472+0530|SEVERE|sun-appserver9.1|javax.enterprise.system.tools.deployment|_ThreadID=20;_ThreadName=Thread-39;_RequestID=8433cf2e-cc74-481e-9d9c-ba2bc8f9e59a;|Exception occured in J2EEC Phasejava.lang.IllegalArgumentException: Invalid ejb jar [D:\Sun\AppServer\domains\domain1\applications\j2ee-modules\SourceResource]: it contains zero ejb.
Note:
1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message driven bean.
2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar.
3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven), please check server.log to see whether the annotations were processed properly.
com.sun.enterprise.deployment.backend.IASDeploymentException: Error loading deployment descriptors for module [SourceResource] -- Invalid ejb jar [D:\Sun\AppServer\domains\domain1\applications\j2ee-modules\SourceResource]: it contains zero ejb.
Note:
1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message driven bean.
2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar.
3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven), please check server.log to see whether the annotations were processed properly.
at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:390)
at com.sun.enterprise.deployment.backend.ModuleDeployer.loadDescriptors(ModuleDeployer.java:423)
at com.sun.enterprise.deployment.backend.EjbModuleDeployer.deploy(EjbModuleDeployer.java:140)
at com.sun.enterprise.deployment.backend.ModuleDeployer.doRequestFinish(ModuleDeployer.java:179)
at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:191)
at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:919)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:279)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:788)
at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:187)
at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:223)
Caused by: java.lang.IllegalArgumentException: Invalid ejb jar [D:\Sun\AppServer\domains\domain1\applications\j2ee-modules\SourceResource]: it contains zero ejb.
Note:
1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message driven bean.
2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar.
3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven), please check server.log to see whether the annotations were processed properly.
at com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:95)
at com.sun.enterprise.deployment.EjbBundleDescriptor.visit(EjbBundleDescriptor.java:729)
at com.sun.enterprise.deployment.archivist.EjbArchivist.validate(EjbArchivist.java:190)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openArchive(ApplicationArchivist.java:790)
at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openArchive(ApplicationArchivist.java:744)
at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:349)
... 10 more
|#]


[#|2009-08-11T17:50:50.387+0530|INFO|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=24;_ThreadName=p: thread-pool-1; w: 6;|EJB5070: Exception creating stateless session bean : [{0}]
com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref com.session.source.SourceSessionBean/targetSessionRemoteObject@jndi: @null@com.session.target.TargetSessionBeanRemote@Session@com.session.target.TargetSessionBean into class com.session.source.SourceSessionBean
at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387)
at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206)
at com.sun.enterprise.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:127)
at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:533)
at com.sun.ejb.containers.StatelessSessionContainer.access$100(StatelessSessionContainer.java:111)
at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:772)
at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:199)
at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:486)
at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:1675)
at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1229)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:202)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:117)
at $Proxy100.callTarget(Unknown Source)
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:585)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
Caused by: javax.naming.NameNotFoundException: #com.session.target.TargetSessionBeanRemote not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
at com.sun.enterprise.naming.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:111)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:398)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:922)
at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:396)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:287)
... 27 more
|#]

=================================================================================

Please help us to resolve this problem.




Dan Kempten
Greenhorn

Joined: Dec 26, 2008
Posts: 25
I am not an expert but .... @EJB TargetSessionBeanRemote objTargetSessionBeanRemote;

if you have two beans communicating in the same container, shouldn't they be using a local interface?
chetan agg
Ranch Hand

Joined: Apr 11, 2009
Posts: 31
I think dependency injection works for all beans deployed in same ear file using @EJB annotation.

To inject bean deployed as separate ear, you need to use @EJB (mappedName="java:/comp/ejb/MyEJB/Remote")....

Check above syntax. Using mappedName attribute with fully qualified JNDI name will solve your problem

Thanks
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10102
    
164

"chetan agg"

Please click on the "My Private Messages" link on top of this page, for a message from JavaRanch.


[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB access from within a EJB using @EJB is failing in Sun Application Server