2 Replies Latest reply on Mar 14, 2013 5:08 AM by gmatej

    Arquillian confused

    gmatej Newbie

      Hi everyone.

       

      We have started Java EE development some time ago. And things run quite smothly till we came to arquillian

       

      We are using Glassfish 3.1.22 with netbeans, and maven,...

       

      Our team decided to use hibernate as the ORM provider, which we currently add to Glassfish using pom dependecies (I know not the best way).

       

      What I don't understand yet, is the pom, classpath, arquillian realtionship.

       

          @Deployment

          public static JavaArchive createTestArchive() {

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

                      .addPackages(true, "com.company")

                      .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") // b

                      .addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml");

          }

       

      How come that this test  runs OK, altough in our persistence test Hibernate is selected which is not deployed with GF or GF emebedded. It's seems that some files... libs are loaded from the classpath anyway. The hibernate version running in GF embedded is the one listed in pom file. Can anyone tell me how thiw works and why some people had problmes, where they had to specially add hibernate...

       

      Also two releated questions.... Why did we have to add this

      <classpathDependencyExcludes>

           <classpathDependencyExclude>javax:javaee-api</classpathDependencyExclude>

           <classpathDependencyExclude>javax:javaee-web-api</classpathDependencyExclude>

      </classpathDependencyExcludes>

      To the surefire plugin.

       

      And why if we added Glassfish provied modules (jersey). like

          <dependency>

                  <groupId>com.sun.jersey.glassfish.v3.osgi</groupId>

                  <artifactId>jersey-gf-server</artifactId>

                  <version>1.11.1</version>

                  <scope>provided</scope>

              </dependency>

       

      Arquillina stoped working again....

       

      Maybe someone can give me some information. Because currently I am a litlle confused....

       

      BR,

       

      Matej

        • 1. Re: Arquillian confused
          Aslak Knutsen Master

          Matej Grasic wrote:

           

          What I don't understand yet, is the pom, classpath, arquillian realtionship.

           

              @Deployment

              public static JavaArchive createTestArchive() {

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

                          .addPackages(true, "com.company")

                          .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") // b

                          .addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml");

              }

           

          How come that this test  runs OK, altough in our persistence test Hibernate is selected which is not deployed with GF or GF emebedded. It's seems that some files... libs are loaded from the classpath anyway. The hibernate version running in GF embedded is the one listed in pom file. Can anyone tell me how thiw works and why some people had problmes, where they had to specially add hibernate...

           

           

          Because you're running with a Embedded Container. When running in Embedded mode there is no classloader separation between your applictions classpath and the container. Anything on the application classpth can be seen by the Container.

           

           

           

          Matej Grasic wrote:

           

          Also two releated questions.... Why did we have to add this

          <classpathDependencyExcludes>

               <classpathDependencyExclude>javax:javaee-api</classpathDependencyExclude>

               <classpathDependencyExclude>javax:javaee-web-api</classpathDependencyExclude>

          </classpathDependencyExcludes>

          To the surefire plugin.

           

           

          Because those artifacts are useless runtime. See https://community.jboss.org/wiki/WhatsTheCauseOfThisExceptionJavalangClassFormatErrorAbsentCode

           

           

           

          Matej Grasic wrote:

           

          And why if we added Glassfish provied modules (jersey). like

              <dependency>

                      <groupId>com.sun.jersey.glassfish.v3.osgi</groupId>

                      <artifactId>jersey-gf-server</artifactId>

                      <version>1.11.1</version>

                      <scope>provided</scope>

                  </dependency>

           

           

          Probably due to the same application classpth isolation. The version of GlassFish Embedded is probably not compatible with the jersey version you're putting on classpath.

          • 2. Re: Arquillian confused
            gmatej Newbie

            Thanks that helped allot!!!

             

            BR

             

            MAtej