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

    Arquillian add Resources Help

    mano_seba

      Hi,

       

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

       

       

      @Resource(lookup=:java/x/y)

      private Repository repository;

      @Resource

      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.

       

       

       

      Thanks

        • 1. Re: Arquillian add Resources Help
          aslak

          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
            mano_seba

            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


            @EJB

            private GisService gis;

             

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

             

             

            @Deployment
            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
              aslak

              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
                mano_seba

                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.