Hello,
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.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );
Context context = new InitialContext(env);
UpdateTimerHome updateTimerHome =
(UpdateTimerHome)PortableRemoteObject.narrow(context.lookup("federation/UpdateTimer"),
UpdateTimerHome.class);
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:
<ejb-jar>
<description>Session Bean Stateless</description>
<display-name>UpdateTimer</display-name>
<enterprise-beans>
<session>
<ejb-name>federation/UpdateTimer</ejb-name>
<home>package.UpdateTimerHome</home>
<remote>package.UpdateTimerRemote</remote>
<ejb-class>package.UpdateTimerBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
Where do I make a mistake?
-
EJB Beginner - how to use ti from a web application (9 messages)
- Posted by: Adam Warski
- Posted on: June 14 2005 11:54 EDT
Threaded Messages (9)
- EJB Beginner - how to use ti from a web application by Poetic Justice on June 14 2005 16:55 EDT
- EJB Beginner - how to access ejb from a web application by Adam Warski on June 14 2005 17:22 EDT
- EJB Beginner - how to access ejb from a web application by Adam Warski on June 16 2005 04:13 EDT
- EJB Beginner - how to access ejb from a web application by Adam Warski on June 14 2005 17:22 EDT
- EJB Beginner - how to use ti from a web application by adama mbaye on August 16 2005 16:08 EDT
- EJB Beginner - how to use ti from a web application by James Schopp on August 23 2005 18:09 EDT
-
An Easier Way by Dawn Gregg on October 21 2005 11:53 EDT
-
The right solution by Carlos Ramirez on June 20 2006 11:12 EDT
-
Question by Alexis Lopez on March 01 2007 11:02 EST
- Found the solution by Alexis Lopez on March 01 2007 11:44 EST
-
Question by Alexis Lopez on March 01 2007 11:02 EST
-
The right solution by Carlos Ramirez on June 20 2006 11:12 EDT
-
An Easier Way by Dawn Gregg on October 21 2005 11:53 EDT
- EJB Beginner - how to use ti from a web application by James Schopp on August 23 2005 18:09 EDT
-
EJB Beginner - how to use ti from a web application[ Go to top ]
- Posted by: Poetic Justice
- Posted on: June 14 2005 16:55 EDT
- in response to Adam Warski
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. -
EJB Beginner - how to access ejb from a web application[ Go to top ]
- Posted by: Adam Warski
- Posted on: June 14 2005 17:22 EDT
- in response to Poetic Justice
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. -
EJB Beginner - how to access ejb from a web application[ Go to top ]
- Posted by: Adam Warski
- Posted on: June 16 2005 04:13 EDT
- in response to Adam Warski
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? -
EJB Beginner - how to use ti from a web application[ Go to top ]
- Posted by: adama mbaye
- Posted on: August 16 2005 16:08 EDT
- in response to Adam Warski
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. -
EJB Beginner - how to use ti from a web application[ Go to top ]
- Posted by: James Schopp
- Posted on: August 23 2005 18:09 EDT
- in response to adama mbaye
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,
jimi -
An Easier Way[ Go to top ]
- Posted by: Dawn Gregg
- Posted on: October 21 2005 23:53 EDT
- in response to James Schopp
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.
Dawn -
The right solution[ Go to top ]
- Posted by: Carlos Ramirez
- Posted on: June 20 2006 11:12 EDT
- in response to Dawn Gregg
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. Thanks, Carlos -
Question[ Go to top ]
- Posted by: Alexis Lopez
- Posted on: March 01 2007 11:02 EST
- in response to Carlos Ramirez
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? -
Found the solution[ Go to top ]
- Posted by: Alexis Lopez
- Posted on: March 01 2007 11:44 EST
- in response to Alexis Lopez
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.