File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
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
Author

Accessing bean from another ejb.jar

Bernardo Hermont
Greenhorn

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:

@Stateless
public class StatelessSessionBean1 implements StatelessSessionBean1Local,StatelessSessionBean1Remote {

@EJB
private StatelessSessionBean2 statelessSessionBean2;

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

public void accessBean2()
{
statelessSessionBean2.accessedByBean1();
}
}

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...:");
ssb1r.accessBean2();


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(EjbEncInjector.java:88)
at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:566)
at org.jboss.ejb3.SessionContainer.start(SessionContainer.java:154)
at org.jboss.ejb3.stateless.StatelessContainer.start(StatelessContainer.java:102)
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: http://aspose.com/file-tools
 
subject: Accessing bean from another ejb.jar