2 Replies Latest reply on Feb 9, 2011 1:25 PM by Mason Harding

    web.xml not found in classloader (under Arquillian)

    Mason Harding Newbie

      Hi all.  I just mavenized my EAR project, and can successfully install/deploy it.  I am now trying to get Arquillian working.  I have the following code...

       

          @Deployment
          public static Archive<?> getTestArchive() {
      
              // EJB-JAR
              final JavaArchive ejb = ShrinkWrap.create(JavaArchive.class, "test.jar").addResource("seam.properties", "seam.properties").addResource("META-INF/ejb-jar.xml", "META-INF/ejb-jar.xml").addResource("META-INF/persistence.xml", "META-INF/persistence.xml");
      
              // WAR
              final WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war").setWebXML("web.xml").addResource("WEB-INF/components.xml", "WEB-INF/components.xml");
      
              // EAR
              final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class,
                      "test.ear").addModule(ejb).addModule(war).addModule("org.jboss.seam:jboss-seam:2.2.1.GA")
                      .addLibrary("org.jboss.el:jboss-el:1.0_02.CR4");
      
              return ear;
          }
      

       

      I can load the resources in my EJB, but not my war.  I am getting the error...

       

              ... 18 more
      Caused by: java.lang.reflect.InvocationTargetException
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.arquillian.impl.DeploymentAnnotationArchiveGenerator.generateApplicationArchive(DeploymentAnnotationArchiveGenerator.java:57)
              ... 22 more
      Caused by: java.lang.IllegalArgumentException: war/web.xml not found in classloader sun.misc.Launcher$AppClassLoader@5acac268
              at org.jboss.shrinkwrap.impl.base.Validate.notNull(Validate.java:44)
              at org.jboss.shrinkwrap.impl.base.asset.ClassLoaderAsset.<init>(ClassLoaderAsset.java:64)
              at org.jboss.shrinkwrap.impl.base.asset.ClassLoaderAsset.<init>(ClassLoaderAsset.java:48)
              at org.jboss.shrinkwrap.impl.base.container.WebContainerBase.setWebXML(WebContainerBase.java:84)
              at com.myproj.ArquilianTest.getTestArchive(ArquilianTest.java:51)
      

       

      If I do

      mvn install -DskipTests

      then a 'find' for web.xml, it is at

      ./myproj-war/target/myproj-war-1.0-SNAPSHOT/WEB-INF/web.xml

      ./myproj-war/src/main/webapp/WEB-INF/web.xml

       

      but after running

      mvn clean test -Pjbossas-remote-6

      'find' only finds web.xml at

      ./myproj-war/src/main/webapp/WEB-INF/web.xml

       

      I have tried every version of .setWebXML("web.xml") I can think of "WEB-INF/web.xml", specifying the war, the ear/war, etc.  As i am fairly new to Maven, I might well be doing something dumb.  Any ideas?

       

      Thanks,

      Mason

        • 1. web.xml not found in classloader (under Arquillian)
          Aslak Knutsen Master

          setWebXML("web.xml") will try to load a resource on your classpath named "web.xml".

           

          If /myproj-war/src/main/webapp/ is defined as a source folder, setWebXML("WEB-INF/web.xml") should work.

          1 of 1 people found this helpful
          • 2. Re: web.xml not found in classloader (under Arquillian)
            Mason Harding Newbie

            Okay.  Thanks for that. 

             

            I try not to ask stupid questions, but as I'm fairly new to Arquillian and Maven, and am guessing others will have this problem as well.....Do you have any suggestions on How to set my webapp as a source folder?

             

            My war's pom has a build section like

             

                <build>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-war-plugin</artifactId>
                            <configuration>
                                <source>1.5</source>
                                <target>1.5</target>
                                <warSourceDirectory>src/main/webapp</warSourceDirectory>
                                <webResources>
                                    <resource>
                                        <directory>src/main/webapp</directory>
                                    </resource>
                                </webResources>
                                <archive>
                                    <manifest>
                                        <addClasspath>true</addClasspath>
                                    </manifest>
                                </archive>
                            </configuration>
                        </plugin>
                    </plugins>
                    <sourceDirectory>src/main/webapp</sourceDirectory>
                </build>
            

            But none of this seems to affect the classpath under arquillian.. 

             

            I still keep getting

             

            Caused by: java.lang.IllegalArgumentException: WEB-INF/web.xml not found in classloader sun.misc.Launcher$AppClassLoader@35a16869
                    at org.jboss.shrinkwrap.impl.base.Validate.notNull(Validate.java:44)
                    at org.jboss.shrinkwrap.impl.base.asset.ClassLoaderAsset.<init>(ClassLoaderAsset.java:64)
                    at org.jboss.shrinkwrap.impl.base.asset.ClassLoaderAsset.<init>(ClassLoaderAsset.java:48)
                    at org.jboss.shrinkwrap.impl.base.container.WebContainerBase.setWebXML(WebContainerBase.java:84)
                    at com.myproj.ArquilianTest.getTestArchive(ArquilianTest.java:51)
            

             

            Thank you very much.

            Mason