I am trying out a simple EJB 2.1 HelloWorld using Jboss AS 6. I created an EJB jar file with the following structure:
I also created a client standalone java class to test the above ejb. I deployed the jar file using the Jboss 6 admin console under Applications > EJB2 jars and clicked on "Add new resource". When i add the jar file it gives me this message so i assume it was deployed correctly.
Now when i run the client i get this error:
Initially i thought that i had to configure the JNDI resource for which the client will use to connect to find the EJB on the application server. Is this not necessary? The example i am using is using the EJB name in the lookup statement. Here is the section of the client code for making the connection. :
And here is the ejb-jar.xml file
One thing i found interesting is that when i compiled the client class, it refused to compile unless it had a reference to the HelloHome class. To resolve this i had to add the ejb jar file to the classpath of the client class. Is this how it is supposed to work? i.e. the ejb jar file needs to be on the classpath of the client?
In terms of the jndi name used for the lookup, do i need to create a new name? In the above example, it looks the EJB name is used as a lookup.
I am currently going through a book about EJB 3.0. Part of the introduction to EBJ 3.0 is to introduce me to the 2.0 variant hence why i am trying out this example. I think it does make sense to at least get a small understanding of how they work even if i am not planning on using EJB2.
I had a look at the console for the list of deployed applications and i cant see my application on the EJB2.0 menu item. This i think means that the jar file has not deployed correctly. The Jboss logs do show that it was deployed (see 4th line below).
Is there anything that looks wrong in the structure i described above?
Joined: Dec 16, 2011
How are you compiling your project?? Are you using maven, ant or which tool are you using to create the war/ ear files?? I havent worked with v6 but to deploy an application in jboss, you need to copy it on the deploy folder..
Ok i managed to resolve it. I am using eclipse to compile and generate the jar file. It looks like i had the ejb-jar.xml file in the wrong place. It was supposed to be in the META-INF folder. I copied it from ext1/ejb21/ejb-jar.xml to /META-INF/ejb-jar.xml and jboss picked up the jar file.
I also made a small change to the xml file as there was a typo in the namespaces used.
I used HelloWorldEJB as the jndi name for the client and it finally worked.