4 Replies Latest reply on Sep 22, 2011 11:52 AM by gunter zeilinger

    ejb-jar.xml ignored by jbossas-remote-6?

    gunter zeilinger Newbie

      I want to specifiy injections of resources in the EJB deployment descriptor to avoid putting resource mapping names in the EJB source, e.g.




      public class CompositeQueryBean implements CompositeQuery {


          // avoid @Resource(mappedName="java:/DefaultDS")

          private DataSource dataSource;




      <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"


        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"























      which actually works in regular deployment to JBoss 6.1.0 final, but not when deploying it

      by Arquillian-1.0.0.Alpha-5:



      public class PatientQueryTest {



          public static JavaArchive createDeployment() {

              return ShrinkWrap.create(JavaArchive.class, "test.jar")








          private CompositeQuery query;



          public testFoo() {








      => The test fails because CompositeQueryBean.dataSource does not get injected.


      I did not evaluate, if the deployment descriptor is just ignored, or if just the specified injection is not performed.

        • 1. Re: ejb-jar.xml ignored by jbossas-remote-6?
          jaikiran pai Master

          Try changing this




          .addAsManifestResource("META-INF/ejb-jar.xml", "ejb-jar.xml");


          You can also dump the jar contents by doing a


          JavaArchive jar = Shrinkwrap.create(...)



          That'll show you the actual contents of the jar.

          • 2. Re: ejb-jar.xml ignored by jbossas-remote-6?
            Aslak Knutsen Master

            The problem is... Arquillian has to somehow communicate with the TestClass to do inconainer testing. In JBossAS6, the defualt is to use the "Servlet 3.0" Protocol for communication, which implies that a Servlet has to be included in the deployment somehow. The DeploymentPackager that comes with the Servlet 3.0 protocol will 'rewrite' your defined @Deployment so it can communicate with it.


            In this case where you define a JavaArchive, The Servlet 3.0 Protocol will rewrite that as a WebArchive and place your JavaArchive in WEB-INF/lib (pluss adding some other libs to WEB-INF/lib that registeres a web-fragment and so on)


            The EJB 3.1 spec states:

                 "A .war may contain an ejb-jar.xml file. If present, the ejb-jar.xml is packaged as WEB-INF/ejb-jar.xml."


            Since your JavaArchive is placed under WEB-INF/lib, from the container view ejb-jar.xml is now located in WEB-INF/lib/test.jar/META-INF/ejb-jar.xml which is ignored.


            So you have two options, either create a WebArchive with the EJBs in WEB-INF/classes:



            ShrinkWrap.create(WebArchive.class, "test.war")
                 .addClasses(CompositeQuery.class, CompositeQueryBean.class)
                 .addAsWebInfResource("META-INF/ejb-jar.xml", "ejb-jar.xml")


            or create a WebArchive with EJBs in a library in WEB-INF/lib and ejb-jar.xml in WEB-INF/



            ShrinkWrap.create(WebArchive.class, "test.war")
                    ShrinkWrap.ctreate(JavaArchive.class, "test.jar")
                      .addClasses(CompositeQuery.class, CompositeQueryBean.class)
                 .addAsWebInfResource("META-INF/ejb-jar.xml", "ejb-jar.xml")