1

I'm using a JBoss eap 6.4 and tries to create a test EAR with a WAR and a JAR with ejb's inside.

My problem is that Servlets in my WAR can not make local calls (@EJB) to the ejb's inside the JAR even though they are packed inside the same EAR. The reference is never injected.

I found this for local clients: It must run in the same application as the enterprise bean it accesses. at https://docs.oracle.com/javaee/6/tutorial/doc/gipjf.html#girfl. To my that sounds like my situation, please correct me if I'm wrong.

I also found this interesting post: EAR vs separate EJB + WAR. To me the situation #1 in the first answer sounds like this should work.

But I also found this post: How to get CDI in war AND EJB running if both are bundled in an EAR that saying that there is different scope for the classloader. To me that sounds like my attempt with local calls never will work. Could it be different situation's for different app-servers?

To illustrate this I just made this image, the problem is where the red arrow is.

Do you think I have mixed something up?

Image of my EAR

Best regards Fredrik

user2902165
  • 303
  • 2
  • 14

1 Answers1

0

You can put a jboss-deployment-structure.xml into ear META-INF directory.

see https://access.redhat.com/documentation/en-us/jboss_enterprise_application_platform/6.2/html/development_guide/chap-class_loading_and_modules

Jan W
  • 66
  • 4
  • Hello! Thanks for your coment, really interesting page. If I get it right it each WAR, JAR etc inside a EAR is a isolated module then? But on the first page I referred to above it say that it should be possible to use the java:app namespace is used to look up local enterprise beans packaged within the same application. Should I not be able to to that with @EJB then? – user2902165 Nov 05 '17 at 19:55
  • Since you are using JBoss EAP what about asking Redhead this question? – Jan W Nov 07 '17 at 07:34
  • Hello! I actually have done that already: https://developer.jboss.org/thread/276413, but no answers. – user2902165 Nov 08 '17 at 14:48
  • I just mention that it looks like the forum where I posted the question is EOL. Instead it looks like I should post them here but with tag "jboss-eap-6". So I posted a new question: https://stackoverflow.com/questions/47448804/how-to-use-ejb-in-this-local-context-with-jboss-6-4 – user2902165 Nov 23 '17 at 14:07
  • Just mention that I solved it in the new post, best regards. – user2902165 Nov 29 '17 at 14:41