0 Replies Latest reply on Oct 1, 2013 1:02 AM by doddalas

    Getting Exception while starting Embedded JBoss Server from EJB3Unit Test Case in Eclipse

    doddalas

      While executing the EJB3Unit Test Case as a TestNG Test, I am getting the below exception. I have followed the article in http://hocinegrine.com/2010/06/17/unit-testing-with-jboss-embedded-ejb3-container/. PFB my Test Case and the exception stacktrace.

       

      Test Case:

       

      package com.framework.ejb.test;

       

       

       

      import javax.naming.InitialContext;

       

      import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap;

      import org.jboss.ejb3.embedded.EJB3StandaloneDeployer;

      import org.testng.annotations.AfterClass;

      import org.testng.annotations.BeforeClass;

      import org.testng.annotations.Test;

       

      import com.bm.testsuite.BaseSessionBeanFixture;

      import com.framework.ejb.SimpleStatefulSessionBean;

       

      /**

      * The class <code>SimpleStatefulSessionBeanTest</code> contains tests for the

      * class <code>{@link SimpleStatefulSessionBean}</code>.

      *

      * @generatedBy CodePro at 9/30/13 3:47 PM

      * @author DoddalaV

      * @version $Revision: 1.0 $

      */

      public class SimpleStatefulSessionBeanTest extends

              BaseSessionBeanFixture<SimpleStatefulSessionBean> {

       

          /**

           * Beans used for this test

           */

          private static final Class[] usedBeans = {};

       

          /**

           * An instance of the class being tested.

           *

           * @see SimpleStatefulSessionBean

           *

           * @generatedBy CodePro at 9/30/13 3:47 PM

           */

          private SimpleStatefulSessionBean fixture;

       

          /**

           * Initialize a newly create test instance to have the given name.

           *

           * @param name

           *            the name of the test

           *

           * @generatedBy CodePro at 9/30/13 3:47 PM

           */

          public SimpleStatefulSessionBeanTest() {

              super(SimpleStatefulSessionBean.class, usedBeans);

          }

       

          // a boolean to test if the container is running or not

          private static boolean containerRunning = false;

       

          // the EJB3 deployer

          private EJB3StandaloneDeployer deployer;

       

          /**

           * This method is executed before the test methods. It starts the JBoss

           * Embedded Container

           *

           * @throws Exception

           */

          @BeforeClass

          public void init() throws Exception {

       

              startupEmbeddedContainer();

       

              /**

               * Create proxies to call the HelloWorld Service

               */

              InitialContext initialContext = new InitialContext();

       

              fixture = (SimpleStatefulSessionBean) initialContext

                      .lookup("SimpleStatefulSessionBean/remote");

       

          }

       

          /**

           * Return an instance of the class being tested.

           *

           * @return an instance of the class being tested

           *

           * @see SimpleStatefulSessionBean

           *

           * @generatedBy CodePro at 9/30/13 3:47 PM

           */

          public SimpleStatefulSessionBean getFixture() throws Exception {

              if (fixture == null) {

                  fixture = getBeanToTest();

              }

              return fixture;

          }

       

          /**

           * Run the String sayHello() method test.

           *

           * @throws Exception

           *

           * @generatedBy CodePro at 9/30/13 3:47 PM

           */

          @Test

          public void testSayHello_fixture_1() throws Exception {

              SimpleStatefulSessionBean fixture2 = getFixture();

              System.out.println("fixture2:" + fixture2);

              String result = fixture2.sayHello();

              System.out.println("result:" + result);

       

              // add additional test code here

              assertNotNull(result);

          }

       

          /**

           * Launch the test.

           *

           * @param args

           *            the command line arguments

           *

           * @generatedBy CodePro at 9/30/13 3:47 PM

           */

          public static void main(String[] args) {

              junit.textui.TestRunner.run(SimpleStatefulSessionBeanTest.class);

          }

       

          /**

           * The method is executed after lunching all tests methods. It stops and

           * destroys the EJB3 deployer and shuts down the container

           *

           * @throws Exception

           */

          @AfterClass

          public void terminate() throws Exception {

              // stop container

              deployer.stop();

              deployer.destroy();

       

              EJB3StandaloneBootstrap.shutdown();

       

              containerRunning = false;

          }

       

          /**

           * The method starts the container and creates a deployer using the

           * persistence.xml file

           *

           * @throws Exception

           */

          private void startupEmbeddedContainer() throws Exception {

              if (!containerRunning) {

       

                  // start EJB microcontainer

                  // configuration files ejb3-interceptors-aop.xml and

                  // embedded-jboss-beans.xml are used

                  EJB3StandaloneBootstrap.boot(null);

       

                  /*

                   * Create a deployer based on the persistence.xml file

                   */

                  deployer = EJB3StandaloneBootstrap.createDeployer();

                  deployer.getArchivesByResource().add("META-INF/persistence.xml");

                  deployer.create();

                  deployer.start();

       

                  containerRunning = true;

              }

          }

      }

       

      Exception:

       

      WARN  01-10 10:18:36,411 (Ejb3Configuration.java:prepareProperties:993)  -Overriding hibernate.transaction.factory_class is dangerous, this might break the EJB3 specification implementation

      [TestNG] Running:

        C:\Users\doddalav\AppData\Local\Temp\testng-eclipse-1370846569\testng-customsuite.xml

       

      ERROR 01-10 10:18:37,543 (AbstractController.java:incrementState:955)  -Error installing to Start: name=java:comp/Initializer state=Create

      java.lang.NoSuchMethodError: org.jboss.ejb3.EJB3Util.getInitialContext(Ljava/util/Hashtable;)Ljavax/naming/InitialContext;

          at org.jboss.ejb3.embedded.JavaCompInitializer.start(JavaCompInitializer.java:52)

          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.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)

          at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)

          at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)

          at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)

          at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)

          at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)

          at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)

          at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)

          at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)

          at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)

          at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)

          at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)

          at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)

          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)

          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)

          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)

          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)

          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)

          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)

          at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean(AbstractKernelDeployer.java:319)

          at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBeans(AbstractKernelDeployer.java:297)

          at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deploy(AbstractKernelDeployer.java:130)

          at org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer.deploy(BeanXMLDeployer.java:96)

          at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:373)

          at com.framework.ejb.test.SimpleStatefulSessionBeanTest.startupEmbeddedContainer(SimpleStatefulSessionBeanTest.java:155)

          at com.framework.ejb.test.SimpleStatefulSessionBeanTest.init(SimpleStatefulSessionBeanTest.java:68)

          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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)

          at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)

          at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)

          at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)

          at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)

          at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)

          at org.testng.TestRunner.privateRun(TestRunner.java:767)

          at org.testng.TestRunner.run(TestRunner.java:617)

          at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)

          at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)

          at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)

          at org.testng.SuiteRunner.run(SuiteRunner.java:240)

          at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)

          at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)

          at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)

          at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)

          at org.testng.TestNG.run(TestNG.java:1057)

          at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)

          at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)

          at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

      ERROR 01-10 10:18:37,674 (AbstractController.java:incrementState:955)  -Error installing to Start: name=UserTransactionBinding state=Create

      java.lang.NoSuchMethodError: org.jboss.ejb3.EJB3Util.getInitialContext(Ljava/util/Hashtable;)Ljavax/naming/InitialContext;

          at org.jboss.ejb3.embedded.JndiBinder.start(JndiBinder.java:67)

          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.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)

          at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)

          at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)

          at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)

          at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)

          at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)

          at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)

          at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)

          at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)

          at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)

          at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)

          at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)

          at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)

          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)

          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)

          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)

          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)

          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)

          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)

          at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean(AbstractKernelDeployer.java:319)

          at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBeans(AbstractKernelDeployer.java:297)

          at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deploy(AbstractKernelDeployer.java:130)

          at org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer.deploy(BeanXMLDeployer.java:96)

          at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:373)

          at com.framework.ejb.test.SimpleStatefulSessionBeanTest.startupEmbeddedContainer(SimpleStatefulSessionBeanTest.java:155)

          at com.framework.ejb.test.SimpleStatefulSessionBeanTest.init(SimpleStatefulSessionBeanTest.java:68)

          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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)

          at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)

          at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)

          at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)

          at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)

          at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)

          at org.testng.TestRunner.privateRun(TestRunner.java:767)

          at org.testng.TestRunner.run(TestRunner.java:617)

          at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)

          at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)

          at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)

          at org.testng.SuiteRunner.run(SuiteRunner.java:240)

          at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)

          at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)

          at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)

          at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)

          at org.testng.TestNG.run(TestNG.java:1057)

          at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)

          at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)

          at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

      WARN  01-10 10:18:37,737 (TxConnectionManager.java:setTrackConnectionByTx:235)  -setTrackConnectionByTx(boolean value) is deprecated in favor of setInterleaving(boolean value)

      FAILED CONFIGURATION: @BeforeClass init

      java.lang.RuntimeException: java.lang.IllegalStateException: Incompletely deployed:

       

      DEPLOYMENTS IN ERROR:

        Deployment "UserTransactionBinding" is in error due to: java.lang.NoSuchMethodError: org.jboss.ejb3.EJB3Util.getInitialContext(Ljava/util/Hashtable;)Ljavax/naming/InitialContext;

        Deployment "java:comp/Initializer" is in error due to: java.lang.NoSuchMethodError: org.jboss.ejb3.EJB3Util.getInitialContext(Ljava/util/Hashtable;)Ljavax/naming/InitialContext;

       

          at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:386)

          at com.framework.ejb.test.SimpleStatefulSessionBeanTest.startupEmbeddedContainer(SimpleStatefulSessionBeanTest.java:155)

          at com.framework.ejb.test.SimpleStatefulSessionBeanTest.init(SimpleStatefulSessionBeanTest.java:68)

          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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)

          at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)

          at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)

          at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)

          at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)

          at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)

          at org.testng.TestRunner.privateRun(TestRunner.java:767)

          at org.testng.TestRunner.run(TestRunner.java:617)

          at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)

          at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)

          at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)

          at org.testng.SuiteRunner.run(SuiteRunner.java:240)

          at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)

          at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)

          at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)

          at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)

          at org.testng.TestNG.run(TestNG.java:1057)

          at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)

          at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)

          at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

      Caused by: java.lang.IllegalStateException: Incompletely deployed:

       

      DEPLOYMENTS IN ERROR:

        Deployment "UserTransactionBinding" is in error due to: java.lang.NoSuchMethodError: org.jboss.ejb3.EJB3Util.getInitialContext(Ljava/util/Hashtable;)Ljavax/naming/InitialContext;

        Deployment "java:comp/Initializer" is in error due to: java.lang.NoSuchMethodError: org.jboss.ejb3.EJB3Util.getInitialContext(Ljava/util/Hashtable;)Ljavax/naming/InitialContext;

       

          at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.internalValidate(AbstractKernelDeployer.java:278)

          at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.validate(AbstractKernelDeployer.java:174)

          at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:374)

          ... 26 more

       

      SKIPPED CONFIGURATION: @AfterClass terminate

      SKIPPED: testSayHello_fixture_1 on null(com.framework.ejb.test.SimpleStatefulSessionBeanTest)

       

      ===============================================

          Default test

          Tests run: 1, Failures: 0, Skips: 1

          Configuration Failures: 1, Skips: 1

      ===============================================

       

       

      ===============================================

      Default suite

      Total tests run: 1, Failures: 0, Skips: 1

      Configuration Failures: 1, Skips: 1

      ===============================================

       

      [TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@20c1f10e: 49 ms

      [TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 6 ms

      [TestNG] Time taken by org.testng.reporters.XMLReporter@423e5d1: 7 ms

      [TestNG] Time taken by org.testng.reporters.jq.Main@3c1d332b: 39 ms

      [TestNG] Time taken by org.testng.reporters.JUnitReportReporter@ac980c9: 8 ms

      [TestNG] Time taken by org.testng.reporters.EmailableReporter2@46b8c8e6: 15 ms