3 Replies Latest reply on Jan 11, 2011 6:52 AM by Carlo de Wolf

    EJB 3.1 embeddable JUnit Tests

    Hans-Michael Rupp Novice

      Hallo, I am trying to move from OpenEJB to JBoss 6 final.

      My JUnit Tests do not work in Eclipse.

      I have the jars in client on my classpath.

       

      public class FechterDAOTestJEE6 {

       

          public static EJBContainer ejbC;

       

          @BeforeClass

          public static void setup() {

              ejbC = EJBContainer.createEJBContainer();

          }

       

          @AfterClass

          public static void tearDown() {

              ejbC.close();

          }

       

          @Test

          public void testNeuerFechter() throws NamingException {

           //...

          }

      }

       

      At @BeforeClass I get this exception:

      javax.ejb.EJBException: java.lang.reflect.InvocationTargetException

          at org.jboss.ejb3.embedded.impl.standalone.JBossStandaloneEJBContainerProvider.createEJBContainer(JBossStandaloneEJBContainerProvider.java:153)

          at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:93)

          at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:75)

          at fencing.control.test.FechterDAOTestJEE6.setup(FechterDAOTestJEE6.java:27)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

          at java.lang.reflect.Method.invoke(Unknown Source)

          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.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)

          at org.junit.runners.ParentRunner.run(ParentRunner.java:236)

          at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)

          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.reflect.InvocationTargetException

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

          at java.lang.reflect.Method.invoke(Unknown Source)

          at org.jboss.ejb3.embedded.impl.standalone.JBossStandaloneEJBContainerProvider.createEJBContainer(JBossStandaloneEJBContainerProvider.java:141)

          ... 19 more

      Caused by: java.lang.NoClassDefFoundError: org/jboss/logmanager/Logger$AttachmentKey

          at org.jboss.logging.JBossLogManagerProvider.<clinit>(JBossLogManagerProvider.java:36)

          at org.jboss.logging.LoggerProviders.findProvider(LoggerProviders.java:33)

          at org.jboss.logging.LoggerProviders.<clinit>(LoggerProviders.java:28)

          at org.jboss.logging.Logger.getLogger(Logger.java:2164)

          at org.jboss.logging.Logger.getLogger(Logger.java:2189)

          at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.<clinit>(ClassPathEjbJarScanner.java:80)

          at org.jboss.ejb3.embedded.sub.JBossSubmersibleEJBContainer.createEJBContainer(JBossSubmersibleEJBContainer.java:117)

          ... 24 more

      Caused by: java.lang.ClassNotFoundException: org.jboss.logmanager.Logger$AttachmentKey

          at java.net.URLClassLoader$1.run(Unknown Source)

          at java.security.AccessController.doPrivileged(Native Method)

          at java.net.URLClassLoader.findClass(Unknown Source)

          at java.lang.ClassLoader.loadClass(Unknown Source)

          at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

          at java.lang.ClassLoader.loadClass(Unknown Source)

          at java.lang.ClassLoader.loadClassInternal(Unknown Source)

          ... 31 more

       

      Any ideas what to do?

       

      Thanks,

       

      Hans

        • 1. EJB 3.1 embeddable JUnit Tests
          Shelly McGowan Apprentice


          Add the $JBOSS_HOME/lib/jboss-logmanager.jar to your classpath.

          • 2. EJB 3.1 embeddable JUnit Tests
            Hans-Michael Rupp Novice

            Thanks, that solved the ClassNotFoundException, but now I get at @BeforeClass

             

            javax.ejb.EJBException: java.lang.reflect.InvocationTargetException

                at org.jboss.ejb3.embedded.impl.standalone.JBossStandaloneEJBContainerProvider.createEJBContainer(JBossStandaloneEJBContainerProvider.java:153)

                at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:93)

                at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:75)

                at fencing.control.test.FechterDAOTestJEE6.setup(FechterDAOTestJEE6.java:27)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                at java.lang.reflect.Method.invoke(Unknown Source)

                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.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)

                at org.junit.runners.ParentRunner.run(ParentRunner.java:236)

                at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)

                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.reflect.InvocationTargetException

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                at java.lang.reflect.Method.invoke(Unknown Source)

                at org.jboss.ejb3.embedded.impl.standalone.JBossStandaloneEJBContainerProvider.createEJBContainer(JBossStandaloneEJBContainerProvider.java:141)

                ... 19 more

            Caused by: java.lang.VerifyError: Cannot inherit from final class

                at java.lang.ClassLoader.defineClass1(Native Method)

                at java.lang.ClassLoader.defineClass(Unknown Source)

                at java.security.SecureClassLoader.defineClass(Unknown Source)

                at java.net.URLClassLoader.defineClass(Unknown Source)

                at java.net.URLClassLoader.access$000(Unknown Source)

                at java.net.URLClassLoader$1.run(Unknown Source)

                at java.security.AccessController.doPrivileged(Native Method)

                at java.net.URLClassLoader.findClass(Unknown Source)

                at java.lang.ClassLoader.loadClass(Unknown Source)

                at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

                at java.lang.ClassLoader.loadClass(Unknown Source)

                at java.lang.ClassLoader.loadClass(Unknown Source)

                at java.lang.ClassLoader.loadClassInternal(Unknown Source)

                at java.lang.Class.forName0(Native Method)

                at java.lang.Class.forName(Unknown Source)

                at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.containsEjbComponentClass(ClassPathEjbJarScanner.java:367)

                at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.containsEjbComponentClass(ClassPathEjbJarScanner.java:349)

                at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.containsEjbComponentClass(ClassPathEjbJarScanner.java:349)

                at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.containsEjbComponentClass(ClassPathEjbJarScanner.java:349)

                at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.containsEjbComponentClass(ClassPathEjbJarScanner.java:349)

                at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.containsEjbComponentClass(ClassPathEjbJarScanner.java:349)

                at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.containsEjbComponentClass(ClassPathEjbJarScanner.java:349)

                at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.containsEjbComponentClass(ClassPathEjbJarScanner.java:324)

                at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.isEjbJar(ClassPathEjbJarScanner.java:285)

                at org.jboss.ejb3.embedded.impl.base.scanner.ClassPathEjbJarScanner.getEjbJars(ClassPathEjbJarScanner.java:174)

                at org.jboss.ejb3.embedded.sub.JBossSubmersibleEJBContainer.createEJBContainer(JBossSubmersibleEJBContainer.java:117)

                ... 24 more

            • 3. EJB 3.1 embeddable JUnit Tests
              Carlo de Wolf Master

              You should only put jboss-ejb3-embedded-standalone on your classpath (and any API you use besides EJB 3), not everything in $JBOSS_HOME/client.

               

              See EJB 3.1 Embeddable for details.