0 Replies Latest reply on Aug 12, 2011 7:30 AM by Alen Vrečko

    Tests load in wrong ClassLoader

    Alen Vrečko Newbie



      arquillian is pretty impressive but there is one major thing that is bothering me:


      From the documentation I got the feeling the test itself is run on the server - it sure doesn't feel like that is the case.


      Using Alpha5 with Tomcat6 and Jetty7 (embedded) I get this behavior


      public static WebArchive createWar() {
           .... addAsLibraries(someJarThatIncludesFoo); ...
      public void testOnServer(){
           this.getClass().getClassLoader().loadClass("test.Foo"); // I get ClassNotFoundException
           Thread.currentThread().getContextClassLoader().loadClass("test.Foo"); // works with Jetty but not with Tomcat


      I'd expect this.getClass().getClassLoader() to return WebAppLoader instead it returns AppClassLoader.


      Right now I worked around by using Servlets/Listeners (they get loaded in the correct ClassLoader) and doing stuff like


      public void testFromClient(){
          String body = readAllAndClose(new URL(baseUrl, "/Test").openStream());

      it would be a lot more convenient if the Test is loaded in the WebAppClassLoader instead of AppClassLoader.


      Am I missing something or is this the desired behavior? Surely it is not?