4 Replies Latest reply on Apr 3, 2012 10:59 AM by mano_seba

    Arquillian add Resources Help




      I have a problem whit adding some @Resource to arquillian WebArchive.




      private Repository repository;


      private SessionContext ctx;



      How to add them to return  ShrinkWrap.create( WebArchive.class,"test.war");


      I've tried  return ShrinkWrap.create( WebArchive.class,"test.war").addasResource("Repository"); but not a chance


      Can anyone help me whit these please.





        • 1. Re: Arquillian add Resources Help

          Not quite sure what you're trying to do here.. but..


          @Resource is a Common Annotation from JSR-250, and is used to lookup resources bound to JNDI


          WebArchive.addAsResource is used to place 'something' into the Resource location in a WebArchive /WEB-INF/classes

          1 of 1 people found this helpful
          • 2. Re: Arquillian add Resources Help

            Well I try to make an injection with @ EJB service but unfortunately that EJB is null and is my opinion that I must add resource in arquillian


            private GisService gis;


            @Resource(lookup = "java:/jca/jcrJCA")
            private Repositoryrepository;
            private SessionContextctx;
            private FileService fileService;



            public static WebArchive createTestArchive() {
            return  ShrinkWrap.create( WebArchive.class,"test.war")..addClasses(gisService.class);}


            because the GisService is null i thought that the problem is from @Resource SessionContext and Repository... can add thouse Resources to WebArchive or I was wrong about the problem?



            Thanks for the reply

            • 3. Re: Arquillian add Resources Help

              SessionContext can only be injected within a EJB to my knowlegde..


              Your Repository Resource injection should work as long as there is something bound to that lookup JNDI name of type Respository.


              if the @EJB is null, try adding a @EJB.mappedName with the JNDI name where the ejb is bound

              1 of 1 people found this helpful
              • 4. Re: Arquillian add Resources Help

                Thanks for the reply. I was going on a wrong track. I thought that the @Resource must be put in the WebArchive Thanks again for clarification.