I got a problem with accessing EJB:s from a different application than they are running under.
My idea is to have 3 apps running on 1 app server:
The idea is that tasks that may be performed by both the main-app and the admin-app are located as EJB:s in the ejb-app. The reason is that if I need to update an EJB I just need to update it at one place, instead of updating all EJB in every app. Do you get my point?
The problem is of course that I can't figure out how to access any EJB:s in the ejb-app from the admin-app or the main-app.
When I execute this code from a Servlet in the main.ear, for example, that tries to locate a EJB in ejb.ear I get the exception below:
Context context = new InitialContext();
Object object = context.lookup("java:comp/
TestHome testHome = (TestHome)PortableRemoteOb
TestRemote testRemote = (TestRemote)PortableRemote
String output = testRemote.getStringFromFi
Communication error: ejb/ejb/beans not found in main, there are no bound values
xception: ejb/ejb/beans not found in main, there are n
o bound values
When I execute that code from a Servlet in the ejb.ear it works perfect.
So the problem is how to get access to EJB:s between applications inside a app server.
I have created a zip file with my 3 apps that is ready to use in any server (I hope) if you would like to try it out for your self.
It is possible to download at:
If you are using orion do not forget to add these lines in default-web-site.xml:
<web-app application="main" name="main" root="/main" />
<web-app application="admin" name="admin" root="/admin" />
<web-app application="ejb" name="ejb" root="/ejb" />
...and these lines in server.xml:
<application name="main" path="../applications/main
<application name="admin" path="../applications/admi
<application name="ejb" path="../applications/ejb.
When unzip my zip-file with the 3 apps you will find a build.bat file for Windows for each one of the apps. You may need to change the paths depending on where you unzip it if you would like to use the build.bat-files.
My file System looks like:
When everything is installed you should be able to locate your browser to:
Each index.html got a link to a EjbCallerServlet but only the one in the ejb.ear works and response with a output: THAT CALL WORKED!!
In the zip file is also a overview image of files in the 3 apps.
So if you would take the time to test it and try to see if you can find out how to get access to EJB:s in an other app it would be great!
I guess that I just have missed something but I can't figure out what.
BTW if you think that my architecture with shared EJB:s is totaly crazy please tell me why!