3 Replies Latest reply on Sep 23, 2011 2:01 AM by hege

    OpenEJB EJBInjectionEnricher.enrich() NullPointerException

    hege Newbie

      I  run a simple test for an bean with openEjb. The test start but fails with a NullPointerException:

      java.lang.NullPointerException

      at org.jboss.arquillian.testenricher.ejb.EJBInjectionEnricher.enrich(EJBInjectionEnricher.java:51)

      at org.jboss.arquillian.container.openejb.embedded_3_1.OpenEJBTestEnricher.enrich(OpenEJBTestEnricher.java:62)

      at org.jboss.arquillian.impl.enricher.ClientTestEnricher.enrich(ClientTestEnricher.java:61)

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

      at org.jboss.arquillian.impl.core.EventContextImpl.invokeObservers(EventContextImpl.java:98)

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

      at org.jboss.arquillian.impl.client.ContainerDeploymentContextHandler.createContext(ContainerDeploymentContextHandler.java:133)

      at org.jboss.arquillian.impl.client.ContainerDeploymentContextHandler.createBeforeContext(ContainerDeploymentContextHandler.java:115)

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

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

      at org.jboss.arquillian.impl.TestContextHandler.createTestContext(TestContextHandler.java:82)

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

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

      at org.jboss.arquillian.impl.TestContextHandler.createClassContext(TestContextHandler.java:68)

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

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

      at org.jboss.arquillian.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:54)

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

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

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

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

      at org.jboss.arquillian.impl.EventTestRunnerAdaptor.before(EventTestRunnerAdaptor.java:85)

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

      at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:303)

      at org.jboss.arquillian.junit.Arquillian.access$300(Arquillian.java:45)

      at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:228)

      at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)

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

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

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

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

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

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

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

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

      at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:303)

      at org.jboss.arquillian.junit.Arquillian.access$300(Arquillian.java:45)

      at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:187)

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

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

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

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

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

      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)

       

       

      Thats the bean:

      package com.example;
      
      import javax.annotation.security.PermitAll;
      import javax.ejb.Local;
      import javax.ejb.Stateless;
      import org.jboss.ejb3.annotation.SecurityDomain;
      import com.example.client.ProjectManagerLocal;
      
      @Stateless(name = "Example.ProjectManager")
      @SecurityDomain("Example")
      @Local(ProjectManagerLocal.class)
      @PermitAll
      public class ProjectManagerBean implements ProjectManagerLocal {
           public String createProject(String world) {
                return "Hello " + world;
           }
      }
      

       

      the interface:

      package com.example.client;
       
      public interface ProjectManagerLocal {
           String createProject(String world);
      }
      

       

      the test:

      package com.example;
      
      import javax.ejb.EJB;
      
      import org.jboss.arquillian.api.Deployment;
      import org.jboss.arquillian.junit.Arquillian;
      import org.jboss.shrinkwrap.api.ShrinkWrap;
      import org.jboss.shrinkwrap.api.spec.JavaArchive;
      import org.junit.Assert;
      import org.junit.Test;
      import org.junit.runner.RunWith;
      
      import com.example.ProjectManagerBean;
      import com.example.client.ProjectManagerLocal;
      
      @RunWith(Arquillian.class)
      public class ProjectManagerBeanTest {
      
           @Deployment
           public static JavaArchive createTestArchive() {
                return ShrinkWrap.create(JavaArchive.class, "test.jar").addClasses(
                     ProjectManagerBean.class, ProjectManagerLocal.class);
           }
      
           @EJB
           private ProjectManagerLocal projectManager;
      
           @Test
           public void testCreateProject() throws Exception {
                String text = projectManager.createProject("World!");
                Assert.assertEquals("fail", "Hello World!", text);
           }
      }
      

       

      the pom.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
           <modelVersion>4.0.0</modelVersion>
           <groupId>com.example</groupId>
           <artifactId>Example_EJB</artifactId>
           <packaging>ejb</packaging>
      
           <properties>
                <arquillian.version>1.0.0-SNAPSHOT</arquillian.version>
           </properties>
      
           <name>Example_EJB</name>
      
           <dependencies>
                <dependency>
                     <groupId>org.jboss.jbossas</groupId>
                     <artifactId>jboss-as-client</artifactId>
                     <version>5.1.0.GA</version>
                     <type>pom</type>
                     <scope>provided</scope>
                </dependency>
                <dependency>
                     <groupId>org.jboss.arquillian</groupId>
                     <artifactId>arquillian-junit</artifactId>
                     <version>${arquillian.version}</version>
                     <scope>test</scope>
                </dependency>
                <dependency>
                     <groupId>org.jboss.arquillian.junit</groupId>
                     <artifactId>arquillian-junit-container</artifactId>
                     <version>${arquillian.version}</version>
                     <scope>test</scope>
                </dependency>
                <dependency>
                     <groupId>junit</groupId>
                     <artifactId>junit</artifactId>
                     <version>4.8.2</version>
                     <scope>test</scope>
                </dependency>
                <dependency>
                     <groupId>javax.enterprise</groupId>
                     <artifactId>cdi-api</artifactId>
                     <version>1.0-SP1</version>
                     <scope>provided</scope>
                </dependency>
                <dependency>
                     <!-- Need on all profiles except Glassfish to compile, api is not 100% up to date with final spec -->
                     <groupId>org.jboss.ejb3</groupId>
                     <artifactId>jboss-ejb3-api</artifactId>
                     <version>3.1.0</version>
                     <scope>test</scope>
                </dependency>
                <dependency>
                     <groupId>org.apache.openejb</groupId>
                     <artifactId>openejb-core</artifactId>
                     <version>3.1.4</version>
                     <scope>test</scope>
                </dependency>
                <dependency>
                     <groupId>org.jboss.arquillian.container</groupId>
                     <artifactId>arquillian-openejb-embedded-3.1</artifactId>
                     <version>${arquillian.version}</version>
                     <scope>test</scope>
                </dependency>
           </dependencies>
      
      
           <build>
                <plugins>
                     <!-- Compiler Settings -->
                     <plugin>
                          <artifactId>maven-compiler-plugin</artifactId>
                          <version>2.3.2</version>
                          <configuration>
                               <source>1.6</source>
                               <target>1.6</target>
                          </configuration>
                     </plugin>
                     <!-- EJB Plugin Settings -->
                     <plugin>
                          <groupId>org.apache.maven.plugins</groupId>
                          <artifactId>maven-ejb-plugin</artifactId>
                          <version>2.3</version>
                          <configuration>
                               <ejbVersion>3.1</ejbVersion>
                               <!-- generate client jar -->
                               <generateClient>true</generateClient>
                               <!-- includes of client jar -->
                               <clientIncludes>
                                    <clientInclude>com/examplel/client/**</clientInclude>
                               </clientIncludes>
                               <!-- excludes of ejb jar -->
                               <excludes>
                                    <exclude>com/example/client/**</exclude>
                               </excludes>
                               <archive>
                                    <manifest>
                                         <addClasspath>true</addClasspath>
                                         <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                                         <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                    </manifest>
                               </archive>
                          </configuration>
                     </plugin>
                </plugins>
           </build>
      </project>
      

       

      the arquillian.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian-1.0.xsd">
           <engine>
                <property name="deploymentExportPath">target/</property>
           </engine>
      </arquillian>
      

       

      The console output:

      20.09.2011 07:22:15 org.jboss.arquillian.impl.client.container.ContainerRegistryCreator getActivatedConfiguration

      INFO: Could not read active container configuration: null

      Apache OpenEJB 3.1.4    build: 20101112-03:32

      http://openejb.apache.org/

      INFO - openejb.home = C:\Workspace\workspace_example\Example_EJB

      INFO - openejb.base = C:\Workspace\workspace_example\Example_EJB

      INFO - Using 'openejb.assembler=org.jboss.arquillian.container.openejb.embedded_3_1.OpenEJBAssembler'

      INFO - Using 'openejb.configurator=org.jboss.shrinkwrap.openejb.config.ShrinkWrapConfigurationFactory'

      INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)

      INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)

      INFO - Using 'openejb.deployments.classpath=false'

      INFO - Configuring enterprise application: C:\Users\...\AppData\Local\Temp\c9b855ca-e702-4181-a656-24878d86d2d9\test.jar

      INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)

      INFO - Auto-creating a container for bean Example.ProjectManager: Container(type=STATELESS, id=Default Stateless Container)

      INFO - Enterprise application "C:\Users\...\AppData\Local\Temp\c9b855ca-e702-4181-a656-24878d86d2d9\test.jar" loaded.

      INFO - Assembling app: C:\Users\...\AppData\Local\Temp\c9b855ca-e702-4181-a656-24878d86d2d9\test.jar

      INFO - Jndi(name=Examplel.ProjectManagerLocal) --> Ejb(deployment-id=Example.ProjectManager)

      INFO - Created Ejb(deployment-id=Example.ProjectManager, ejb-name=Example.ProjectManager, container=Default Stateless Container)

      INFO - Deployed Application(path=C:\Users\...\AppData\Local\Temp\c9b855ca-e702-4181-a656-24878d86d2d9\test.jar)

      INFO - Undeploying app: C:\Users\...\AppData\Local\Temp\c9b855ca-e702-4181-a656-24878d86d2d9\test.jar

       

      May someone can help me? I can't find the point i missed.

       

      Thanks

      hege

       

      edit markup