2 Replies Latest reply on Jul 19, 2011 8:40 AM by Mike Mosiewicz

    EJB + WAR in EAR (on Jboss7)

    Mike Mosiewicz Newbie


      Excuse me if I choose the wrong forum. I'm not sure if it's more JBoss or Weld related.

      I have an ear containing war and ejb. I package my components in EJB jar, however right now there is no EJB at all, just plain POJOs. And after I deploy it on JBoss 7, no bean from EJB jar is discovered (it contains beans.xml of course). There is a lot of ClassNotFound exceptions when I turn weld debugging on.

      However after I add a dummy EJB (empty class annotated with @Stateless) all POJO beans from EJB are properly discovered. Is it becouse of some spec, or something else?

        • 1. Re: EJB + WAR in EAR (on Jboss7)
          Joshua Davis Expert

          I think that's a packaging issue.   What's the point of having an ejb-jar with no EJBs in it?  The JBoss deployers probably expect some EJBs in your ejb-jar (correct me if I'm wrong JBoss folks).   If you want to have POJO components in your WAR, it's best to package them as JARs in WEB-INF/lib.

          • 2. Re: EJB + WAR in EAR (on Jboss7)
            Mike Mosiewicz Newbie
            As I said it was 'right now'. It's becouse it's a fresh project and simply didn't have those EJBs planned. Anyway... now I would extend this topic on packaging.

            There is one issue I'm fighting with and I cannot fight. I'm creating an application that has a few WAR's and EJB. I wanted to use seam-config so my EJB keeps common components, but both WAR's may have alternative configurations regarding to - for example - security. So I assumed that in A.war I would have:

            <x:MyBean property="a" />

            and in B.war:

            <x:MyBean property="b" />

            However it seems that it's not posible with seam config. Seam config is able to use my ejb.jar:META-INF/beans.xml or any lib/*.jar:META-INF/beans.xml but won't work with *.war:**/beans.xml. I'm testing it on Jboss AS 7. My experiments with moving seam-config extension to WEB-INF/lib also fail becouse this way some components get duplicated.

            So my question is how one should deal with multi-war EAR's. In my case I create multiple WAR's becouse these are different applications configurable under different domains etc. However I want them to share my components, very slightly customized at WAR level. What is the best strategy in such case?