I have created a local interface and a stateless session bean which implements that interface (Eclipse 3.8.2 and JBoss AS 7.1, EJB 3.1)
I call the bean through a servlet using JNDI,
Below is the code snippet,
Context initialContext = new InitialContext();
TestSessionBeanLocal testSessionBeanLocal= (TestSessionBeanLocal) initialContext.lookup("TestEJB/TestSessionBean/local");
I am getting the following error,
javax.naming.NameNotFoundException: TestEJB/TestSessionBean/local -- service jboss.naming.context.java.TestEJB.TestSessionBean.local
Posting code snippets of your interface, session bean etc. with the annotations used will give more clarity on what's being done.
And, an additional help tip. If you want to actually check whether your session bean is deployed fine and the binding has happening as you excepted or not, you can look at the JNDI tree of the JBoss from its jmx-console. You can search for details on how to get there
Its easy to implement it in NetBeans.(using insert code and calling enterprise bean).
I am trying it to do it in Eclipse.(Was able to do it using Dependency Injection. @EJB annotation and placing the jar file of the bean in the WEB-INF/lib folder of the Web Content.)
But i am not able to do it using the JNDI way as mentioned in the previous post.
Here are my code snippets,
local bean interface
If I am not wrong, either changing the name="TestSession" to name="TestSessionBean"
Or changing the lookup string "TestEJB/TestSessionBean/local" to "TestEJB/TestSession/local"
should get this working.
And, if it still doesn't work, do have a look at the jndi view of the JBoss after the bean is deployed.
I have tried both ways, but it still gives the same error.
19:04:00,590 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) javax.naming.NameNotFoundException: TestEJB/TestSession/local -- service jboss.naming.context.java.TestEJB.TestSession.local
I hope the deployment structure(war, ear, ejb etc.) is proper as per the example you are following and the ear is named "TestEJB".
If jmx-console is not working, then its worth checking if JBoss is started and running fine or not..