File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Accessing bean from another ejb.jar 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 "Accessing bean from another ejb.jar" Watch "Accessing bean from another ejb.jar" New topic

Accessing bean from another ejb.jar

Bernardo Hermont

Joined: May 20, 2008
Posts: 11
Hi folks,

I'm currently using JBoss and EJB 3.0, trying to access an EJB that is placed inside another jar:

public class StatelessSessionBean1 implements StatelessSessionBean1Local,StatelessSessionBean1Remote {

private StatelessSessionBean2 statelessSessionBean2;

public void accessedByBean2()
System.out.println("This bean was accessed by other ejb.jar");

public void accessBean2()

I'm using only annotations, since no ejb-jar setups is required right?
So, my servlet does the following:
StatelessSessionBean1Remote ssb1r = (StatelessSessionBean1Remote) initialContext.lookup(projectName+"/"+StatelessSessionBean1.class.getSimpleName()+ "/remote");

System.out.println("Accessing bean 2...:");

And I got the following runtime error:

java.lang.RuntimeException: could not resolve global JNDI name for @EJB for container StatelessSessionBean1: reference class: com.certification.session.stateless.beanref2.ejb.StatelessSessionBean2 ejbLink: not used by any EJBs
at org.jboss.injection.EjbEncInjector.inject(
at org.jboss.ejb3.EJBContainer.start(
at org.jboss.ejb3.SessionContainer.start(
at org.jboss.ejb3.stateless.StatelessContainer.start(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

Any clues?

scjp 1.4, scwcd 1.4, scbcd 5.0, scea 5.0, OMG OCUP Fundamental
I agree. Here's the link:
subject: Accessing bean from another ejb.jar
It's not a secret anymore!