It's been a while since I had been in
EJB land - and now I am using the latest and greatest EJB3.1.
So naturally I get stumped by some basic things (again):
My EJB3.1 setup is like so:
MyManagedBean.java which implements LocalInterface.java interface methods (with @Stateless Annotation)
LocalInterface.java with interface methods (with @Local Annotation)
Now this whole thing is packed in an EJB-JAR file along with a WAR which is then bundled inside an EAR and crammed into my
JBoss server.
So the packaging is like so:
EAR PACKAGE ->
EJB-JAR PACKAGE
WAR PACKAGE
In the WAR package - I have a controller that is using InitialContext lookup to find the EJB bundled in the EAR (and thus use it - of course).
Imagine to my surprise that this doesn't actually work!
I am using a lookup with the name
"java:global/myproject-ear-0.0.1-SNAPSHOT/myproject-ejb-0.0.1-SNAPSHOT/MyManagedBean!com.myproject.bean.MyManagedBean"
The error would say:
javax.naming.NameNotFoundException: myproject-ear-0.0.1-SNAPSHOT/myproject-ejb-0.0.1-SNAPSHOT/MyManagedBean!com.myproject.bean.MyManagedBean -- service jboss.naming.context.java.global."myproject-ear-0.0.1-SNAPSHOT"."myproject-ejb-0.0.1-SNAPSHOT"."MyManagedBean!com.myproject.bean.MyManagedBean"
Now here's the kicker:
After tinkering around with it - I found that if I ONLY add the additional annotation of
@LocalBean on the MyManagedBean.java class - and restart the JBoss server again - it would find the Name!
Yet according to my research - the whole @LocalBean annotation is redundant and unnecessary since I already am implementing a LocalInterface with @Local anyways.
So whats the deal here?