0 Replies Latest reply on Nov 6, 2012 6:25 PM by dspiess

    Getting SLF4J error while trying to run RestEasy in Aquillian test

    dspiess

      Hi,

       

      I'm trying to write a simple test, but I can't seem to get the setup right. 

       

      I'm trying to deploy and run the test on JBoss AS7.

       

      Here's what I have in my test.  It fails when I try to initialize the Resteasy client.  If I comment out the RegisterBuiltin line, the test runs as long as I comment out the rest of the Resteasy calls.

       

      @RunWith(Arquillian.class)
      public class TypeTypeHandlerTest extends DeploymentTest {
        
                private static Logger logger = Logger.getLogger(TypeTypeHandlerTest.class);
        
        @ArquillianResource
          URL deploymentUrl;
        
                public static void initResteasyClient() {       
              //the following only needs to be executed once per VM
              RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
          }
        
          @Deployment
          public static Archive<?> getDeployment() {
                    return createDeploymentArchive();
          }
          
          @BeforeClass
          public static void setup() {
                    initResteasyClient();
          } 
          
          @Test 
                public void shouldBeAbleToListAllTypeTypes(ClientResponse<TypeTypeList> response) {
          //TypeTypeService client = ProxyFactory.create(TypeTypeService.class, "http://localhost:8080/testCDS");
          //ClientResponse<TypeTypeList> clientResponse = client.getTypeTypeList();
                    assertEquals("Didn't get a response.", true, response != null);
           
          //TypeTypeList list = clientResponse.getEntity(new GenericType<TypeTypeList>() {});
                          assertEquals("Return status was not ok", 200, response.getStatus());
        //assertEquals("Didnt get a type type list", true, list != null);
                }
        
      }
      

       

       

       

      This is where I set up the deployment.  I've tried adding SLF4J and removing it.

       

        /**
                 * Creates a deployment which can be tested on JBoss
                 * @return the deployment which is sent to JBoss for testing
                 */
                public static Archive<?> createDeploymentArchive() {
                          if (theArchive == null) {
        logger.debug("BUILDING MVN dependencies");
        
                                    MavenDependencyResolver resolver = DependencyResolvers
                                         .use(MavenDependencyResolver.class)
                                  .goOffline();
        
        logger.debug("CREATING Archive");
                                    theArchive = ShrinkWrap.create(WebArchive.class, "testCDS.war")
                                              .addPackages(true, "org.neoninc.cds.pdr")
                                              .addClass("org.neoninc.cds.RestApplication")
                                              .addAsLibraries(resolver.artifact("org.neoninc:cdsResources:1.0-SNAPSHOT").resolveAsFiles())
                                              .addAsLibraries(resolver.artifact("com.oracle:ojdbc6:11.2.0.3").resolveAsFiles())
                                              .addAsLibraries(resolver.artifact("org.hibernatespatial:hibernate-spatial-oracle:1.0").resolveAsFiles())
                                              .addAsLibraries(resolver.artifact("com.oracle:sdoapi:11.2.0.2").resolveAsFiles())
                                              .addAsLibraries(resolver.artifact("commons-codec:commons-codec:1.6").resolveAsFiles())
                                              .addAsLibraries(resolver.artifact("commons-io:commons-io:2.4").resolveAsFiles())
                                              .addAsLibraries(resolver.artifact("org.infinispan:infinispan-core:5.1.5.FINAL").resolveAsFiles())
                                              .addAsLibraries(resolver.artifact("org.jboss.resteasy:resteasy-jaxrs:2.3.4.Final").resolveAsFiles())
        //.addAsLibraries(resolver.artifact("org.slf4j:slf4j-log4j12:1.6.4").resolveAsFiles())
                                              .addAsManifestResource("test-jboss-deployment-structure.xml","jboss-deployment-structure.xml")
                                              .addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml")
                                              .addAsResource("log4j.xml", "log4j.xml")
                                              .addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
        //.addAsLibraries(mvnLibs);
        
                                    logger.debug(theArchive.toString());
                          }
        return theArchive; 
                }
      

       

       

       

      This is the exception I'm getting.

       

      java.lang.ExceptionInInitializerError
                at org.jboss.resteasy.spi.ResteasyProviderFactory.getInstance(ResteasyProviderFactory.java:352)
                at org.neoninc.cds.pdr.rest.TypeTypeHandlerTest.initResteasyClient(TypeTypeHandlerTest.java:35)
                at org.neoninc.cds.pdr.rest.TypeTypeHandlerTest.setup(TypeTypeHandlerTest.java:45)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:601)
                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
                at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
                at org.jboss.arquillian.junit.Arquillian$StatementLifecycleExecutor.invoke(Arquillian.java:351)
                at org.jboss.arquillian.container.test.impl.execution.ClientBeforeAfterLifecycleEventExecuter.execute(ClientBeforeAfterLifecycleEventExecuter.java:99)
                at org.jboss.arquillian.container.test.impl.execution.ClientBeforeAfterLifecycleEventExecuter.on(ClientBeforeAfterLifecycleEventExecuter.java:60)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:601)
                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
                at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
                at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:601)
                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
                at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:601)
                at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)
                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
                at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:134)
                at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)
                at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:80)
                at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:182)
                at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
                at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
                at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)
                at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
                at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)
                at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
                at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
                at org.jboss.resteasy.logging.Logger.getLogger(Logger.java:104)
                at org.jboss.resteasy.plugins.providers.RegisterBuiltin.<clinit>(RegisterBuiltin.java:21)
                ... 50 more
      Caused by: java.lang.reflect.InvocationTargetException
                at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
                at org.jboss.resteasy.logging.Logger.getLogger(Logger.java:92)
                ... 51 more
      Caused by: java.lang.IllegalStateException: org.slf4j.LoggerFactory could not be successfully initialized. See also http://www.slf4j.org/codes.html#unsuccessfulInit
                at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:276)
                at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
                at org.jboss.resteasy.logging.impl.Slf4jLogger.<init>(Slf4jLogger.java:19)
                ... 56 more
      

       

       

      Any ideas where I'm going wrong?

       

      Thanks!