11 Replies Latest reply on Jul 13, 2011 8:48 AM by Amber Jboss

    arquillian maven partially generated ConnectorTestCase NullPointerException

    Amber Jboss Newbie

      Hi I'm getting NullPointerException when running a Arquillian Test Case:

      <testcase time="0.016" classname="com.savvis.isd.jca.ssh.ConnectorTestCase" name="initializationError">

          <error type="java.lang.NullPointerException">java.lang.NullPointerException

                at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:88)

                at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:82)

                at org.jboss.arquillian.impl.DeployableTestBuilder.build(DeployableTestBuilder.java:65)

                at org.jboss.arquillian.junit.Arquillian.&lt;init&gt;(Arquillian.java:82)

                at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

                at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

                at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)

                at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)

                at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)

                at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)

                at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)

                at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)

                at org.apache.maven.surefire.junit4.JUnit4TestSet.&lt;init&gt;(JUnit4TestSet.java:45)

                at org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite.createTestSet(JUnit4DirectoryTestSuite.java:56)

                at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.locateTestSets(AbstractDirectoryTestSuite.java:96)

                at org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:209)

                at org.apache.maven.surefire.Surefire.run(Surefire.java:156)

                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.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)

                at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)

      </error>

        </testcase>

       

      MY MAVEN jboss version, ironjacamar, arquillian version:



      <ironjacamar.version>1.0.0.Beta6</ironjacamar.version>


      <arquillian.version>1.0.0.Alpha5</arquillian.version>


      <jboss.version>6.0.0.Final</jboss.version>

       

      I use jbossas-remote-6 profile as follows:

      <profile>

                                    <id>jbossas-remote-6</id>

                                    <dependencies>

                                              <dependency>

                                                        <groupId>org.jboss.arquillian.container</groupId>

                                                        <artifactId>arquillian-jbossas-remote-6</artifactId>

                                                        <version>${arquillian.version}</version>

                                              </dependency>

                                              <dependency>

                                                        <groupId>org.jboss.jbossas</groupId>

                                                        <artifactId>jboss-as-client</artifactId>

                                                        <version>${jboss.version}</version>

                                                        <type>pom</type>

                                              </dependency>

                                    </dependencies>

                          </profile>

       

      the rest of the pom.xml should be similiar to this (except the additional libraries I have to use to implement our resource pooling solution):

      <!-- for jboss jca below     -->

          <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-as</artifactId>

            <version>1.0.0.Final</version>

          </dependency>

          <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-common-api</artifactId>

            <version>${ironjacamar.version}</version>

          </dependency>

          <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-common-impl</artifactId>

            <version>${ironjacamar.version}</version>

          </dependency>

          <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-common-impl-papaki</artifactId>

            <version>${ironjacamar.version}</version>

          </dependency>

          <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-common-spi</artifactId>

            <version>${ironjacamar.version}</version>

          </dependency>  

          <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-core-api</artifactId>

            <version>${ironjacamar.version}</version>

          </dependency>   

          <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-core-impl</artifactId>

            <version>${ironjacamar.version}</version>

          </dependency>

          <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-depchain</artifactId>

            <version>${ironjacamar.version}</version>

            <type>pom</type>

          </dependency> 

          <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-deployers-common</artifactId>

            <version>${ironjacamar.version}</version>

          </dependency>   

          <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-deployers-fungal</artifactId>

            <version>${ironjacamar.version}</version>

          </dependency>

          <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-embedded</artifactId>

            <version>${ironjacamar.version}</version>

          </dependency>

          <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-embedded-arquillian</artifactId>

            <version>${ironjacamar.version}</version>

          </dependency>

                <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-jdbc</artifactId>

            <version>${ironjacamar.version}</version>

          </dependency>

          <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-spec-api</artifactId>

            <version>${ironjacamar.version}</version>

          </dependency>

          <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-validator</artifactId>

            <version>${ironjacamar.version}</version>

          </dependency>

          <dependency>

            <groupId>org.jboss.ironjacamar</groupId>

            <artifactId>ironjacamar-validator-cli</artifactId>

            <version>${ironjacamar.version}</version>

          </dependency>

                <dependency>

                    <groupId>org.jboss.logging</groupId>

                    <artifactId>jboss-logging</artifactId>

                    <version>3.0.0.GA</version>

          </dependency>

       

       

      I am on a time crunch, Could someone help me out, please, I may download source of the stack trace, but before I do that, has someone encountered that?

       

      BTW, I have my customized ResourceAdapter code-generated....ConnectorTestCase looks like this:

      @RunWith(Arquillian.class)

      public class ConnectorTestCase

      {

         private static Logger log = Logger.getLogger("ConnectorTestCase");

       

       

         private static String deploymentName = "ConnectorTestCase";

       

       

         /**

          * Define the deployment

          *

          * @return The deployment archive

          */

         @Deployment

         public static ResourceAdapterArchive createDeployment()

         {

                   ResourceAdapterArchive raa = ShrinkWrap.create(ResourceAdapterArchive.class, deploymentName

                                              + ".rar");

                          JavaArchive ja = ShrinkWrap

                                              .create(JavaArchive.class, UUID.randomUUID().toString() + ".jar");

                          ja.addClasses(FooResourceAdapterImpl.class,

                                              FooConnectionFactoryImpl.class,

                                              FooConnectionImpl.class,

                                              FooConnectionMetaData.class,

                                              FooFactoryInterface.class,

      FooFactoryImpl.class,

      FooConnection.class,

      FooConnetionImpl.class);

                          raa.addLibrary(ja);

            return raa;

         }

       

       

                /** Resource */

                @Resource(mappedName = "java:/eis/ConnectorTestCase")

                private SshConnectionFactoryInterface connectionFactory;

       

       

                @Test

                public void testBasic() throws Throwable {

                          assertNotNull(connectionFactory);

                          SshConnection connection = connectionFactory.getConnection();

                          assertNotNull(connection);

                          String resp = connection.helloWorld();

                          Assert.assertEquals("hello world!", resp);

                          connection.close();

                }

       

      }

        • 1. Re: arquillian maven partially generated ConnectorTestCase NullPointerException
          Aslak Knutsen Master

          InContainer testing of RAR deployments directly are not supported on JBoss AS 6, if you wrap it in a EAR and add your test case to a WAR or similar in the EAR this should work.

          • 2. Re: arquillian maven partially generated ConnectorTestCase NullPointerException
            Amber Jboss Newbie

            Currently I do have a ear project that refers to the rarModule artifect and webModule (which is a web services project) :

             

            <plugin>

                                                    <artifactId>maven-ear-plugin</artifactId>

                                                    <configuration>

              <modules>

                                                                        <webModule>

                                                                                       <artifactId>foo-ws</artifactId>

                                                                                       <contextRoot>/foo</contextRoot>

                                                                                       <groupId>com.bar</groupId>

                                                                        </webModule>

                                                                        <rarModule>

                                                                                       <artifactId>myrar</artifactId>

                                                                                       <groupId>foo</groupId>

                                                                        </rarModule>

                                                              </modules>

                                                    </configuration>

                                          </plugin>

            you are saying if I install the ConnectorTestCase in the web services project, and run jbossas-remote-6, it should work, right?

            • 3. Re: arquillian maven partially generated ConnectorTestCase NullPointerException
              Aslak Knutsen Master

              something similar to this:

               

               

               

              @Deployment
              public static EnterpriseArchive createDeployment()
              {
                        return ShrinkWrap.create(EnterpriseArchive.class, "test.ear")
                                  .addModule(
                                            ShrinkWrap.create(ResourceAdapterArchive.class, deploymentName+ ".rar")
                                                      .addLibrary(
                                                                ShrinkWrap.create(JavaArchive.class)
                                                                          .addClasses(FooResourceAdapterImpl.class,
                                                                                                        FooConnectionFactoryImpl.class,
                                                                                                        FooConnectionImpl.class,
                                                                                                        FooConnectionMetaData.class,
                                                                                                        FooFactoryInterface.class,
                                                                                                        FooFactoryImpl.class,
                                                                                                        FooConnection.class,
                                                                                                        FooConnetionImpl.class)
                                            )
                                  )
                                  .addModule(
                                            ShrinkWrap.create(WebArchive.class, "test.war")
                                                      .addClass(ConnectorTestCase.class)
                                  );
              }
              
              
              • 4. Re: arquillian maven partially generated ConnectorTestCase NullPointerException
                Amber Jboss Newbie

                I did so but it gave me the same error.

                So DeployableTestBuilder is saying profile is null, from the stacktrace.

                for testing, I do have these 2 dep, as instructed from http://docs.jboss.org/arquillian/reference/latest/en-US/html_single/#d0e417:

                <!-- test -->

                    <dependency>

                      <groupId>junit</groupId>

                      <artifactId>junit</artifactId>

                      <version>4.8.1</version>

                      <scope>test</scope>

                    </dependency>

                          <dependency>

                                    <groupId>org.jboss.arquillian</groupId>

                                    <artifactId>arquillian-junit</artifactId>

                                    <version>${arquillian.version}</version>

                                    <scope>test</scope>

                          </dependency>

                 

                and jndi.properties:

                java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory

                java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

                java.naming.provider.url=jnp://localhost:1099

                 

                I am confused, why won't it work?

                • 5. Re: arquillian maven partially generated ConnectorTestCase NullPointerException
                  Aslak Knutsen Master

                  The NullPointer your seeing i believe is related to not finding any arquillian container on classpath.

                   

                  Are you using executing:

                   

                  mvn install -Pjbossas-remote-6

                   

                  to activate the Maven profile when running the test case?

                  • 6. Re: arquillian maven partially generated ConnectorTestCase NullPointerException
                    Amber Jboss Newbie

                    I run mvn test -Pjbossas-remote-6; which in this case, is running against jnp://localhost:1099, correct?

                    • 8. Re: arquillian maven partially generated ConnectorTestCase NullPointerException
                      Aslak Knutsen Master

                      what is the output of:

                       

                      mvn dependency:tree -Pjbossas-remote-6

                      • 9. Re: arquillian maven partially generated ConnectorTestCase NullPointerException
                        Amber Jboss Newbie

                        ok.

                        I ran mvn dependency:tree -Pjbossas-remote-6 and saw ironjacamar-depchain:pom:1.0.0.Beta6:compile has dependency of  arquillian 1.0.0.Alpha4:runtime  instead of 1.0.0.Alpha5, the one I am using. So I

                         

                         

                        1. updated the arquillian version to 1.0.0.Alpha4, so arquillian-junit is referring to that version.

                         

                        2. added arquillian.xml as follows (just in case):

                        <?xml version="1.0" encoding="UTF-8"?>

                        <arquillian xmlns="http://jboss.com/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">

                         

                          <container qualifier="jbossas" default="true">

                             <configuration>

                                <property name="profileName">default</property>

                                <property name="providerUrl">jnp://localhost:1099</property>

                                <property name="urlPkgPrefix">org.jboss.naming:org.jnp.interfaces</property>

                                <property name="contextFactory">org.jnp.interfaces.NamingContextFactory</property>

                             </configuration>

                             <protocol type="Servlet 3.0">

                                <configuration>

                                    <property name="host">localhost</property>

                                    <property name="port">8080</property>

                                </configuration>

                             </protocol>

                        </container>

                        </arquillian>

                         

                        3. ran  mvn clean test -Pjbossas-remote-6


                        <error message="java.lang.IllegalStateException: More then one implementation found for org.jboss.arquillian.spi.DeployableContainer, please check your classpath. The found implementations are org.jboss.jca.embedded.arquillian.EmbeddedJCAContainer, org.jboss.arquillian.container.jbossas.remote_6.JBossASRemoteContainer" type="org.jboss.arquillian.impl.event.FiredEventException">org.jboss.arquillian.impl.event.FiredEventException: java.lang.IllegalStateException: More then one implementation found for org.jboss.arquillian.spi.DeployableContainer, please check your classpath. The found implementations are org.jboss.jca.embedded.arquillian.EmbeddedJCAContainer, org.jboss.arquillian.container.jbossas.remote_6.JBossASRemoteContainer

                         

                        4. I switched ConnectorTestCase back to the original structure, with the same result  "More then one implementation found for org.jboss.arquillian.spi.DeployableContainer".

                         

                         

                        Sorry, i have to step away for a couple of hours...I really need to read more into Arquillian and shrinkwrap documentation. newbie at this.

                        Thanks so much for the help!

                        • 10. Re: arquillian maven partially generated ConnectorTestCase NullPointerException
                          Aslak Knutsen Master

                          Arquillian can only run with one Container on the ClassPath at any given time, you have both

                           

                          [INFO] +- org.jboss.arquillian.container:arquillian-jbossas-remote-6:jar:1.0.0.Alpha4:compile

                           

                          and

                           

                          [INFO] +- org.jboss.ironjacamar:ironjacamar-embedded-arquillian:jar:1.0.0.Beta6:compile