Bidyut Majumdar

Greenhorn
+ Follow
since Aug 13, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Bidyut Majumdar

Hi all,

I am facing a problem. Please help me if its possible.

I created two EJB jar (SourceSessionBean.jar, TargetSessionBean.jar) in a single EAR file and deployed in Sun application server.

Now i am trying to access the target session bean in TargetSessionBean.jar from the source session bean in SourceSessionBean.jar. I am getting error Caused by: javax.naming.NameNotFoundException: No object bound to name java:comp/env/com.session.target.TargetSessionBeanRemote

Is it possible to do it?

following is my code snippet.

@Stateless
public class SourceSessionBean implements SourceSessionBeanRemote, SourceSessionBeanLocal {


TargetSessionBeanRemote tgtRemote;

@Resource
SessionContext sctx;

/**
* Default constructor.
*/
public SourceSessionBean() {

}


public void sourceMethod() {

tgtRemote = (TargetSessionBeanRemote)
sctx.lookup(TargetSessionBeanRemote.class.getName());
tgtRemote.targetMethod();

}


}


@Stateless
public class TargetSessionBean implements TargetSessionBeanRemote, TargetSessionBeanLocal {

/**
* Default constructor.
*/
public TargetSessionBean() {

}


public void targetMethod() {
System.out.println("Target method is called....");

}


}
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.