3 Replies Latest reply: May 3, 2012 1:54 PM by Dominik Grupp RSS

    StartException for ArquillianTest

    Dominik Grupp Newbie

      Hello,

       

      for an arquillian test I run into the following error on jbossas7 but don't understand why that error is thrown (a simple login test with arquillian works fine). Some classes for which the error is thrown are not even used for the test (UserEditAll, UserModify). Without the test the application is working fine. What do I need to change?

       

      -------------------------------------------------------------------------------

      Test set: de.comp.login.CreateProductTest

      -------------------------------------------------------------------------------

      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 8.613 sec <<< FAILURE!

      de.comp.login.CreateProductTest  Time elapsed: 0 sec  <<< ERROR!

      org.jboss.arquillian.container.spi.client.container.DeploymentException: Could not deploy to container

                at org.jboss.as.arquillian.container.ArchiveDeployer.deploy(ArchiveDeployer.java:68)

                at org.jboss.as.arquillian.container.CommonDeployableContainer.deploy(CommonDeployableContainer.java:142)

                at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:156)

                at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:123)

                at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.executeOperation(ContainerDeployController.java:266)

                at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.deploy(ContainerDeployController.java:122)

                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.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.container.impl.client.ContainerDeploymentContextHandler.createDeploymentContext(ContainerDeploymentContextHandler.java:78)

                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.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createContainerContext(ContainerDeploymentContextHandler.java:57)

                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.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

                at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

                at org.jboss.arquillian.container.impl.client.container.DeploymentExceptionHandler.verifyExpectedExceptionDuringDeploy(DeploymentExceptionHandler.java:50)

                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.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.core.impl.EventImpl.fire(EventImpl.java:67)

                at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$1.perform(ContainerDeployController.java:90)

                at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$1.perform(ContainerDeployController.java:79)

                at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.forEachDeployment(ContainerDeployController.java:258)

                at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.forEachManagedDeployment(ContainerDeployController.java:234)

                at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.deployManaged(ContainerDeployController.java:78)

                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.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.core.impl.ManagerImpl.fire(ManagerImpl.java:134)

                at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)

                at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

                at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:101)

                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.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:39)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                at java.lang.reflect.Method.invoke(Method.java:597)

                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:39)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                at java.lang.reflect.Method.invoke(Method.java:597)

                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:300)

                at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)

                at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35)

                at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:115)

                at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97)

                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.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)

                at $Proxy0.invoke(Unknown Source)

                at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)

                at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)

                at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)

      Caused by: java.lang.Exception: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"test.war\".WeldService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"test.war\".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001409 Ambiguous dependencies for type [User] with qualifiers [@Default] at injection point [[field] @Inject private de.comp.admin.UserEditAll.loggedInUser]. Possible dependencies [[Producer Method [User] with qualifiers [@Any @Default @Named] declared as [[method] @Produces @Named public de.comp.admin.UserModify.getUserToModify()], Producer Method [User] with qualifiers [@Any @Default @Named] declared as [[method] @Produces @Named public de.comp.admin.UserCreate.getNewUser()], Managed Bean [class de.comp.domain.User] with qualifiers [@Any @Default]]]"}}

                at org.jboss.as.controller.client.helpers.standalone.impl.ServerDeploymentPlanResultFuture.getActionResult(ServerDeploymentPlanResultFuture.java:134)

                at org.jboss.as.controller.client.helpers.standalone.impl.ServerDeploymentPlanResultFuture.getResultFromNode(ServerDeploymentPlanResultFuture.java:123)

                at org.jboss.as.controller.client.helpers.standalone.impl.ServerDeploymentPlanResultFuture.get(ServerDeploymentPlanResultFuture.java:85)

                at org.jboss.as.controller.client.helpers.standalone.impl.ServerDeploymentPlanResultFuture.get(ServerDeploymentPlanResultFuture.java:42)

                at org.jboss.as.arquillian.container.ArchiveDeployer.executeDeploymentPlan(ArchiveDeployer.java:85)

                at org.jboss.as.arquillian.container.ArchiveDeployer.deploy(ArchiveDeployer.java:58)

                ... 94 more

       

       

      package de.comp.login;

       

      import java.io.File;

      import javax.inject.Inject;

      import org.jboss.arquillian.container.test.api.Deployment;

      import org.jboss.arquillian.junit.Arquillian;

      import org.jboss.shrinkwrap.api.Archive;

      import org.jboss.shrinkwrap.api.GenericArchive;

      import org.jboss.shrinkwrap.api.ShrinkWrap;

      import org.jboss.shrinkwrap.api.asset.EmptyAsset;

      import org.jboss.shrinkwrap.api.spec.WebArchive;

      import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;

      import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;

      import org.junit.Assert;

      import org.junit.Test;

      import org.junit.runner.RunWith;

      import de.comp.admin.UserCreate;

      import de.comp.domain.User;

      import de.comp.service.UserManager;

      import de.comp.tools.PasswordDigest;

      import de.comp.validator.Fieldsequal;

       

      @RunWith(Arquillian.class)

      public class CreateProductTest {

       

                public static final String WEBAPP_SRC = "src/main/webapp";

       

                @Deployment

                public static Archive<?> createTestArchive() {

                          return ShrinkWrap

                                              .create(WebArchive.class, "test.war")

                                              .addPackages(true, UserCreate.class.getPackage(), PasswordDigest.class.getPackage(), Fieldsequal.class.getPackage())

                                              .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")

                                              .addAsWebInfResource(new File(WEBAPP_SRC, "WEB-INF/faces-config.xml"))

                                              .addAsWebResource(new File(WEBAPP_SRC, "index.html"))

                                              .addAsLibraries(

                                                                  DependencyResolvers.use(MavenDependencyResolver.class)

                                                                                      .artifact("de.comp:admdomain:jar:1.0")

                                                                                      .artifact("de.comp:admserv:jar:1.0").artifact("javax.enterprise:cdi-api:jar:1.0")

                                                                                      .artifact("org.jboss.spec.javax.annotation:jboss-annotations-api_1.1_spec:jar:1.0.0.Final")

                                                                                      .artifact("org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_1.1_spec:jar:1.0.0.Final")

                                                                                      .artifact("org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final")

                                                                                      .artifact("org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec:jar:1.0.0.Final")

                                                                                      .artifact("org.hibernate:hibernate-jpamodelgen:jar:1.1.1.Final")

                                                                                      .artifact("javax.servlet:servlet-api:jar:2.5").artifact("commons-el:commons-el:jar:1.0")

                                                                                      .resolveAs(GenericArchive.class));

                }

       

                @Inject

                private UserCreate userCreate;

       

                @Inject

                private UserManager usermanager;

       

                @Test

                public void createProductTest() throws Exception {

       

                          User user = userCreate.getNewUser();

                          user.setFirstname("Joe");

                          user.setLastname("Smith");

                          user.setAdmin(false);

                          user.setBarred(false);

                          user.setLoginname("smithj");

                          user.setPwd(PasswordDigest.calculateDigest("secret"));

       

                          userCreate.saveUser();

       

                          User newUser = usermanager.findByLogin("smithj");

       

                          Assert.assertNotNull("User " + user.toString() + " was not created", newUser);

       

      }

       

      }

       

        

      Another question - immediately after testing all tables are dropped - regardless whether I use <property name="hibernate.hbm2ddl.auto" value="create-drop" /> or <property name="hibernate.hbm2ddl.auto" value="validate" /> in persistence.xml. Can I change that behaviour?

       

      Regards,

       

      Michael

        • 1. Re: StartException for ArquillianTest
          Dominik Grupp Newbie

          Aaaargh. I forgot to add the package where the login is being done (and which contains a qualifier to mark the loggedInUser special).

           

          I had to add as well the message.properties file. However, now I receive the below exception. FacesContext seems not to be initialized (variable ctx - see below - is null).

           

          -------------------------------------------------------------------------------

          Test set: de.comp.login.CreateProductTest

          -------------------------------------------------------------------------------

          Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 8.836 sec <<< FAILURE!

          createProductTest(de.comp.login.CreateProductTest)  Time elapsed: 0.319 sec  <<< ERROR!

          javax.ejb.EJBException: java.lang.NullPointerException

                    at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:166)

                    at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230)

                    at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)

                    at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

                    at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)

                    at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ejb3.component.stateful.StatefulComponentIdInterceptor.processInvocation(StatefulComponentIdInterceptor.java:52)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

                    at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72)

                    at de.comp.admin.UserCreate$$$view83.saveUser(Unknown Source)

                    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.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264)

                    at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)

                    at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)

                    at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260)

                    at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:111)

                    at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56)

                    at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)

                    at de.comp.admin.UserCreate$Proxy$_$$_Weld$Proxy$.saveUser(UserCreate$Proxy$_$$_Weld$Proxy$.java)

                    at de.comp.admin.UserCreate$Proxy$_$$_WeldClientProxy.saveUser(UserCreate$Proxy$_$$_WeldClientProxy.java)

                    at de.comp.login.CreateProductTest.createProductTest(CreateProductTest.java:72)

                    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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

                    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

                    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

                    at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:270)

                    at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60)

                    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.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.core.impl.ManagerImpl.fire(ManagerImpl.java:134)

                    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)

                    at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

                    at org.jboss.arquillian.container.test.impl.execution.ContainerTestExecuter.execute(ContainerTestExecuter.java:38)

                    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.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.createTestContext(TestContextHandler.java:89)

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

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                    at java.lang.reflect.Method.invoke(Method.java:597)

                    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.createClassContext(TestContextHandler.java:75)

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

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                    at java.lang.reflect.Method.invoke(Method.java:597)

                    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.GeneratedMethodAccessor22.invoke(Unknown Source)

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                    at java.lang.reflect.Method.invoke(Method.java:597)

                    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.test.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:111)

                    at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:263)

                    at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:226)

                    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$5.evaluate(Arquillian.java:240)

                    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

                    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

                    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

                    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                    at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185)

                    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:300)

                    at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)

                    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)

                    at org.junit.runner.JUnitCore.run(JUnitCore.java:136)

                    at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65)

                    at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethodInternal(JMXTestRunner.java:128)

                    at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethod(JMXTestRunner.java:107)

                    at org.jboss.as.arquillian.service.ArquillianService$ExtendedJMXTestRunner.runTestMethod(ArquillianService.java:226)

                    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 com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:93)

                    at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:27)

                    at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:208)

                    at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:120)

                    at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:262)

                    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)

                    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)

                    at org.jboss.as.jmx.PluggableMBeanServerImpl$TcclMBeanServer.invoke(PluggableMBeanServerImpl.java:489)

                    at org.jboss.as.jmx.PluggableMBeanServerImpl.invoke(PluggableMBeanServerImpl.java:243)

                    at org.jboss.remoting3.jmx.protocol.v1.ServerProxy$InvokeHandler.handle(ServerProxy.java:1034)

                    at org.jboss.remoting3.jmx.protocol.v1.ServerProxy$MessageReciever$1.run(ServerProxy.java:215)

                    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                    at java.lang.Thread.run(Thread.java:680)

          Caused by: java.lang.NullPointerException

                    at de.comp.tools.Messages.getFacesMessage(Messages.java:40)

                    at de.comp.admin.UserCreate.saveUser(UserCreate.java:43)

                    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.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374)

                    at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:127)

                    at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:135)

                    at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

                    at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.jpa.interceptor.SFSBInvocationInterceptor.processInvocation(SFSBInvocationInterceptor.java:58)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.processInvocation(StatefulSessionSynchronizationInterceptor.java:156)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:84)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

                    at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ejb3.component.stateful.StatefulComponentInstanceInterceptor.processInvocation(StatefulComponentInstanceInterceptor.java:70)

                    at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

                    at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228)

                    ... 124 more

           

           

          Here is my Messages class. I marked line 40

           

          package de.comp.tools;

           

          import java.text.MessageFormat;

          import java.util.Locale;

          import java.util.MissingResourceException;

          import java.util.ResourceBundle; 

          import javax.faces.application.Application;

          import javax.faces.application.FacesMessage;

          import javax.faces.component.UIViewRoot;

          import javax.faces.context.FacesContext;

          import org.apache.log4j.Logger;

           

          public class Messages {

           

                    final static Logger logger = Logger.getLogger(Messages.class);

           

                    public static String getResourceText(FacesContext ctx, String bundleName, String key, Object... args) {

                              Application app = ctx.getApplication();

                              ResourceBundle bundle = app.getResourceBundle(ctx, bundleName);

                              return getResourceText(bundle, key, args);

                    }

           

                    public static String getResourceText(ResourceBundle bundle, String key, Object... args) {

                              String text;

                              try {

                                        text = bundle.getString(key);

                              } catch (MissingResourceException e) {

                                        logger.error("could not find labels resource '" + key + "'");

                                        return "???" + key + "???";

                              }

                              if (args != null) {

                                        text = MessageFormat.format(text, args);

                              }

                              return text;

                    }

           

                    public static FacesMessage getFacesMessage(FacesContext ctx, FacesMessage.Severity severity, String msgKey, Object... args) {

                              Locale loc = ctx.getViewRoot().getLocale();   <== LINE 40

                              ctx.getApplication();

                              ResourceBundle bundle = ResourceBundle.getBundle(ctx.getApplication().getMessageBundle(), loc);

                              String msg = bundle.getString(msgKey);

                              if (args != null) {

                                        MessageFormat format = new MessageFormat(msg);

                                        msg = format.format(args);

                              }

                              return new FacesMessage(severity, msg, null);

                    }

           

           

                    public static Locale getLocale(FacesContext context) {

                              Locale locale = null;

                              UIViewRoot viewRoot = context.getViewRoot();

                              if (viewRoot != null)

                                        locale = viewRoot.getLocale();

                              if (locale == null)

                                        locale = Locale.getDefault();

                              return locale;

                    }

           

           

                    public static ClassLoader getClassLoader() {

                              ClassLoader loader = Thread.currentThread().getContextClassLoader();

                              if (loader == null)

                                        loader = ClassLoader.getSystemClassLoader();

                              return loader;

                    }

          }

           

           

          The changed test class

           

          package de.comp.login;

           

          import java.io.File;

          import javax.inject.Inject;

          import org.jboss.arquillian.container.test.api.Deployment;

          import org.jboss.arquillian.junit.Arquillian;

          import org.jboss.shrinkwrap.api.Archive;

          import org.jboss.shrinkwrap.api.GenericArchive;

          import org.jboss.shrinkwrap.api.ShrinkWrap;

          import org.jboss.shrinkwrap.api.asset.EmptyAsset;

          import org.jboss.shrinkwrap.api.spec.WebArchive;

          import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;

          import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;

          import org.junit.Assert;

          import org.junit.Test;

          import org.junit.runner.RunWith;

          import de.comp.admin.UserCreate;

          import de.comp.domain.User;

          import de.comp.service.UserManager;

          import de.comp.tools.PasswordDigest;

          import de.comp.validator.Fieldsequal;

           

          @RunWith(Arquillian.class)

          public class CreateProductTest {

           

            public static final String WEBAPP_SRC = "src/main/webapp";

           

            @Deployment

                    public static Archive<?> createTestArchive() {

                              return ShrinkWrap

                                                  .create(WebArchive.class, "test.war")

                                                  .addPackages(true, UserCreate.class.getPackage(), PasswordDigest.class.getPackage(), Fieldsequal.class.getPackage(), Credentials.class.getPackage())

                                                  .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")

                                                  .addAsWebInfResource(new File(WEBAPP_SRC, "WEB-INF/faces-config.xml"))

                                                  .addAsWebResource(new File(WEBAPP_SRC, "index.html"))

                                                  .addAsResource(new File("src/main/resources/de/comp"), "messages_de.properties")

                                                  .addAsLibraries(

                                                                      DependencyResolvers.use(MavenDependencyResolver.class)

                                                                                          .artifact("de.comp:admdomain:jar:1.0")

                                                                                          .artifact("de.comp:admserv:jar:1.0").artifact("javax.enterprise:cdi-api:jar:1.0")

                                                                                          .artifact("org.jboss.spec.javax.annotation:jboss-annotations-api_1.1_spec:jar:1.0.0.Final")

                                                                                          .artifact("org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_1.1_spec:jar:1.0.0.Final")

                                                                                          .artifact("org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final")

                                                                                          .artifact("org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec:jar:1.0.0.Final")

                                                                                          .artifact("org.hibernate:hibernate-jpamodelgen:jar:1.1.1.Final")

                                                                                          .artifact("javax.servlet:servlet-api:jar:2.5").artifact("commons-el:commons-el:jar:1.0")

                                                                                          .resolveAs(GenericArchive.class));

                    }

           

            @Inject

                    private UserCreate userCreate;

           

            @Inject

                    private UserManager usermanager;

           

            @Test

                    public void createProductTest() throws Exception {

           

                              User user = userCreate.getNewUser();

                              user.setFirstname("Joe");

                              user.setLastname("Smith");

                              user.setAdmin(false);

                              user.setBarred(false);

                              user.setLoginname("smithj");

                              user.setPwd(PasswordDigest.calculateDigest("secret"));

           

                              userCreate.saveUser();

           

                              User newUser = usermanager.findByLogin("smithj");

           

                              Assert.assertNotNull("User " + user.toString() + " was not created", newUser);

           

                    }

           

          }

          • 2. Re: StartException for ArquillianTest
            Aslak Knutsen Master

            FacesContext is only available when you do a JSF request. Either you have to do a HTTP request from the Client (@RunAsClient) or use the JSFUnit integration, http://arquillian.org/modules/jsfunit-extension/

            • 3. Re: StartException for ArquillianTest
              Dominik Grupp Newbie

              Sorry for my really late response. Thanks, Aslak. I started to try using @RunAsClient (new posting on that on https://community.jboss.org/thread/199202).