1 2 Previous Next 17 Replies Latest reply: Apr 20, 2012 5:45 PM by Sueleyman Vurucu Go to original post RSS
      • 15. Re: Dependency Injection won't work
        Sueleyman Vurucu Expert

        Hi Vineet,


        I assume that. I have allready a very dynamic Servicelocator so I can use that. In some cases the DI is not enough for our usecase. But I nothing will be work over DI. @PersistenceContex or @Rescource. Both of then don't work as well. I'm very confused.

        • 16. Re: Dependency Injection won't work
          Sueleyman Vurucu Expert

          Hi it's me again,


          it seems so that the DI won't work in an EAR deployment like in a WAR.


          I try the deployment shown below:


          public static EnterpriseArchive createTestArchive(Module testModule, Class<?>... additionalClasses){

              // Get needed Properties

              String versionbase = SystemPropertiesTestConstants.VERSION_BASE.getValue();

              String wmsear = SystemPropertiesTestConstants.WMS_EAR.getValue();

              String testModuleName = testModule.getModuleName() + "-" + versionbase + ".jar";

              // Retrieve the EAR file

              EnterpriseArchive ear = DependencyResolvers





              // EJB Jar with my testcase

              JavaArchive testModuleJar = ear.getAsType(JavaArchive.class, testModuleName);






              return ear;



          I get my EAR which is deployed in my local repo and replace it by adding my testcase in my EJB jar. The deployment is correct. I can verify this by adding the folowing property in my arquillan.xml



                  <property name="deploymentExportPath">target/</property>



          Everything works fine but the DI not as I want.

          • 17. Re: Dependency Injection won't work
            Sueleyman Vurucu Expert

            Hi guys,


            I think I didn't understood the arquillian apprroach. So my testcase is not an EJB. But by adding a beans.xml I can make it to a CDI bean where I can inject almost everything what I need. It was painfull but I learn it .


            So I changed my helper method for deployment as shown below:


              public static EnterpriseArchive createTestArchive(Class<?>... additionalClasses){

                String earMvnString= getMyEARString();


                JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "additionalClasses.jar")

                    .addClasses(additionalClasses).addAsResource(EmptyAsset.INSTANCE, "beans.xml");


                return DependencyResolvers







            That rocks as I want.

            1 2 Previous Next