I want to access an EJB from my web application - the EJB is deployed on the same app server (JBoss 4.0.2). The EJB deploys without any problems, it's the accesing part I have problems with. Here's part of my code:
Hashtable env = new Hashtable();
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );
Context context = new InitialContext(env);
UpdateTimerHome updateTimerHome =
UpdateTimerRemote updateTimerRemote = updateTimerHome.create();
And after that I get an exception:
java.rmi.ServerException: EJBException:; nested exception is:
javax.ejb.EJBException: Invalid invocation, check your deployment packaging, method=public abstract org.jboss.forge.federation.timer.ejb.UpdateTimerRemote org.jboss.forge.federation.timer.ejb.UpdateTimerHome.create() throws java.rmi.RemoteException,javax.ejb.CreateException
I don't have anything special in my web application's web.xml, in ejb-jar.xml:
<description>Session Bean Stateless</description>
Where do I make a mistake?
Is the jndi name federation/UpdateTimer that u use the same as in your ejb deployment description file? you have to use a consistent name or else the lookup will fail.
I suppose it is - I checked in the web console, and it's cleary written there: "JNDI: federation/UpdateTimer". Besides, it's not the lookup that fails, it is the invocation of the create() method.
I have written a stand-alone program to to the same thing - that is, lookup and create the EJB - and it works without any problems. So how can you access EJBs from a web application? I guess there's something you have to add to web.xml, but what?
I had the same problem. The only thing you have to do is:
Copy the file "jbossall-client.jar" (which is located in the $JBOSS_HOME/client folder) in the "lib" folder of your web application. That's all.
I had the same problem, and the prescribed solution (moving jbossall-client.jar into my web-inf/lib directory) worked. BUT... why? I have deployed many other webapps with EJBs, etc... and I've not had this problem before, nor have I used jbossall-client.jar either.
Thanks for the info,
I found that when posting both my EJB jar file and my War file to the same server, JBoss does not like having the home and remote interface in the War file.
If I take the home and remote interfaces out of my war file then the code works fine.
Thank you Dawn it was the solution. I had the same problem. A funny detail is that the problem doesn't happen in Jboss 4.0.0.
I'm having the same problema, I don't understand something in the solution, if I remove the Beans and remotes classes, ¿How am I gonna invoke the methods in the session bean?
OK, I finally understood what the last posts said about taking out the Remote classes from my WAR. It's simple, during codification I had to use the EJB lib because I needed the remote classes to compile the project, right? But When I was creating the WAR, I just removed that lib from the WAR archive with help of my IDE (i used JBuilder 2007), and that was it.