3 Replies Latest reply on Nov 12, 2010 4:28 PM by Aslak Knutsen

    Problems Getting Started on JBoss AS 5.1

    l1fe Newbie
        <dependencies>
             <dependency>
                  <groupId>javax.enterprise</groupId>
                  <artifactId>cdi-api</artifactId>
                  <version>1.0-SP2</version>
             </dependency>
          <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
          </dependency>
          <dependency>
               <groupId>org.jboss.arquillian</groupId>
               <artifactId>arquillian-junit</artifactId>
               <version>1.0.0.Alpha4-OSGi</version>
               <scope>test</scope>
          </dependency>
        </dependencies>
        <profiles>
      <profile>
      <id>jbossas-remote-5.1</id>
      <dependencies>
         <dependency>
              <groupId>org.jboss.arquillian.container</groupId>
              <artifactId>arquillian-jbossas-remote-5.1</artifactId>
              <version>1.0.0.Alpha4.SP1</version>
                    </dependency>
                       <dependency>
              <groupId>org.jboss.jbossas</groupId>
              <artifactId>jboss-as-client</artifactId>
              <version>5.1.0.GA</version>
              <type>pom</type>
         </dependency>
      </dependencies>
      </profile> 

        </profiles>

       

        <dependencies>
             <dependency>
                  <groupId>javax.enterprise</groupId>
                  <artifactId>cdi-api</artifactId>
                  <version>1.0-SP2</version>
             </dependency>
          <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
          </dependency>
          <dependency>
               <groupId>org.jboss.arquillian</groupId>
               <artifactId>arquillian-junit</artifactId>
               <version>1.0.0.Alpha4-OSGi</version>
               <scope>test</scope>
          </dependency>
        </dependencies>
        <profiles>
           <profile>
                <id>jbossas-remote-5.1</id>
                <dependencies>
                    <dependency>
                         <groupId>org.jboss.arquillian.container</groupId>
                         <artifactId>arquillian-jbossas-remote-5.1</artifactId>
                         <version>1.0.0.Alpha4.SP1</version>
                    </dependency>
                       <dependency>
                         <groupId>org.jboss.jbossas</groupId>
                         <artifactId>jboss-as-client</artifactId>
                         <version>5.1.0.GA</version>
                         <type>pom</type>
                    </dependency>
                </dependencies>
           </profile>  
        </profiles>
      

       

       

      The above is my pom.xml file. The jndi.properties, TemperatureConverter, and TemperatureConverterTest are pretty much identical to the example in Chapter 3.

       

      I notice that a test.ear is deployed (through my JBoss console) but when running the test, I get NPE on the first assert of each test.

       

      Any help would be much appreciated.

        • 1. Re: Problems Getting Started on JBoss AS 5.1
          Aslak Knutsen Master

          Don't use Alpha4-OSGi, use the plain Alpha-4 v. instead.

           

          can you post you exact Bean definition / Bean interface and Injection point?

          • 2. Re: Problems Getting Started on JBoss AS 5.1
            l1fe Newbie

            The TemperatureConverter:

             

             

            public class TemperatureConverter {
            
                 public double convertToCelsius(double f) {
                      return ((f - 32) * 5 / 9);
                 }
                 
                 public double convertToFarenheit(double c) {
                      return ((c * 9 / 5) + 32);
                 }
            }
            

             

             

            The TemperatureConverterTest:

             

             

            @RunWith(Arquillian.class)
            public class TemperatureConverterTest {
            @Inject
            private TemperatureConverter converter;
            @Deployment
            public static JavaArchive createTestArchive() {
            return ShrinkWrap.create(JavaArchive.class, "test.jar")
            .addClasses(TemperatureConverter.class)
            .addManifestResource(
            EmptyAsset.INSTANCE,
            ArchivePaths.create("beans.xml"));
            }
            @Test
            public void testConvertToCelsius() {
            Assert.assertEquals(converter.convertToCelsius(32d), 0d);
            Assert.assertEquals(converter.convertToCelsius(212d), 100d);
            }
            @Test
            public void testConvertToFarenheit() {
            Assert.assertEquals(converter.convertToFarenheit(0d), 32d);
            Assert.assertEquals(converter.convertToFarenheit(100d), 212d);
            }
            }
            @RunWith(Arquillian.class)
            public class TemperatureConverterTest {
            
                 @Inject
                 private TemperatureConverter converter;
            
                 @Deployment
                 public static JavaArchive createTestArchive() {
                      return ShrinkWrap.create(JavaArchive.class, "test.jar")
                      .addClasses(TemperatureConverter.class)
                      .addManifestResource(
                      EmptyAsset.INSTANCE,
                      ArchivePaths.create("beans.xml"));
            
                 }
            
                 @Test
                 public void testConvertToCelsius() {
                      Assert.assertEquals(converter.convertToCelsius(32d), 0d);
                      Assert.assertEquals(converter.convertToCelsius(212d), 100d);
                 }
            
                 @Test
                 public void testConvertToFarenheit() {
                      Assert.assertEquals(converter.convertToFarenheit(0d), 32d);
                      Assert.assertEquals(converter.convertToFarenheit(100d), 212d);
                 }
            
            }
            

             

             

            The surefire report:

             

             

            -------------------------------------------------------------------------------
            Test set: com.alexduan.arqtest.TemperatureConverterTest
            -------------------------------------------------------------------------------
            Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 3.819 sec <<< FAILURE!
            testConvertToCelsius(com.alexduan.arqtest.TemperatureConverterTest)  Time elapsed: 0.198 sec  <<< ERROR!
            java.lang.NullPointerException
                 at com.alexduan.arqtest.TemperatureConverterTest.testConvertToCelsius(TemperatureConverterTest.java:34)
                 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:44)
                 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
                 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
                 at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:251)
                 at org.jboss.arquillian.impl.handler.TestEventExecuter.callback(TestEventExecuter.java:44)
                 at org.jboss.arquillian.impl.handler.TestEventExecuter.callback(TestEventExecuter.java:34)
                 at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63)
                 at org.jboss.arquillian.impl.context.AbstractEventContext.fire(AbstractEventContext.java:115)
                 at org.jboss.arquillian.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:157)
                 at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:244)
                 at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:207)
                 at org.jboss.arquillian.junit.Arquillian$5$1.evaluate(Arquillian.java:225)
                 at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:297)
                 at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:221)
                 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:163)
                 at org.jboss.arquillian.junit.Arquillian$3$1.evaluate(Arquillian.java:186)
                 at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:297)
                 at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:182)
                 at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
                 at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:127)
                 at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
                 at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
                 at org.jboss.arquillian.junit.JUnitTestRunner.execute(JUnitTestRunner.java:69)
                 at org.jboss.arquillian.protocol.servlet_2_5.ServletTestRunner.doGet(ServletTestRunner.java:84)
                 at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
                 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.jboss.webbeans.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:113)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                 at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
                 at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                 at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
                 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                 at java.lang.Thread.run(Thread.java:619)
            
            testConvertToFarenheit(com.alexduan.arqtest.TemperatureConverterTest)  Time elapsed: 0.026 sec  <<< ERROR!
            java.lang.NullPointerException
                 at com.alexduan.arqtest.TemperatureConverterTest.testConvertToFarenheit(TemperatureConverterTest.java:40)
                 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:44)
                 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
                 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
                 at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:251)
                 at org.jboss.arquillian.impl.handler.TestEventExecuter.callback(TestEventExecuter.java:44)
                 at org.jboss.arquillian.impl.handler.TestEventExecuter.callback(TestEventExecuter.java:34)
                 at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63)
                 at org.jboss.arquillian.impl.context.AbstractEventContext.fire(AbstractEventContext.java:115)
                 at org.jboss.arquillian.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:157)
                 at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:244)
                 at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:207)
                 at org.jboss.arquillian.junit.Arquillian$5$1.evaluate(Arquillian.java:225)
                 at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:297)
                 at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:221)
                 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:163)
                 at org.jboss.arquillian.junit.Arquillian$3$1.evaluate(Arquillian.java:186)
                 at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:297)
                 at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:182)
                 at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
                 at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:127)
                 at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
                 at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
                 at org.jboss.arquillian.junit.JUnitTestRunner.execute(JUnitTestRunner.java:69)
                 at org.jboss.arquillian.protocol.servlet_2_5.ServletTestRunner.doGet(ServletTestRunner.java:84)
                 at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
                 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.jboss.webbeans.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:113)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                 at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
                 at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                 at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
                 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                 at java.lang.Thread.run(Thread.java:619)
            
            

             

            I switched to vanilla 1.0.0.Alpha4 and it's still throwing the same errors.

            • 3. Re: Problems Getting Started on JBoss AS 5.1
              Aslak Knutsen Master

              aah, CDI against JBoss AS 5.1 won't work. CDI is part of EE6, JBoss AS 5.1 is EE5.

               

              You need JBoss AS 6 for this to work.