6 Replies Latest reply on Jan 13, 2012 2:19 PM by vineet.reynolds

    Arquillian has previously been attempted initialized, but failed.

    sonuthekool

      I am trying to configure the Arquillian tests to run on Weblogic 10.3 server and changed the arquillian.xml to reflect the WLS specific properties and the pom.xml to add a new profile for weblogic. However, when I try to execute the tests from 'arquillian-core/examples/junit' folder using the command     'mvn test -Pweblogic-remote-10-3', I see that all my tests failed. When I see the surefire-reports, I see the XML output for each test and they all have the below error. Can anyone please help me and let me know what I am doing wrong ? Also, has anyone made Arquillian work with Weblogic server yet ?

       

        <testcase time="0" classname="com.acme.resource.InjectionTestCase" name="initializationError">

          <error message="Arquillian has previously been attempted initialized, but failed. See previous exceptions for cause." type="java.lang.RuntimeException">java.lang.RuntimeException: Arquillian has previously been attempted initialized, but failed. See previous exceptions for cause.

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

      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.execute(JUnit4TestSet.java:51)

      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115)

      at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:102)

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

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

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

      </error>

        • 1. Re: Arquillian has previously been attempted initialized, but failed.
          vineet.reynolds

          All except one stacktrace will display the same information if Arquillian has failed initialization. The actual cause of failure to initialize Arquillian ought to be present in the Surefire test report of the first test run by Surefire. Could you post that stacktrace?

          • 2. Re: Arquillian has previously been attempted initialized, but failed.
            aslak

            Not sure what version of Arquillian Core you're using, but atleast in > CR4 or so, the initial/real cause of the exception will be the Cause of the exception that is thrown. No need to hunt down the first test that ran to see it.

            • 3. Re: Arquillian has previously been attempted initialized, but failed.
              sonuthekool

              Aslak, Vineet,

               

              Here is the log from the tests under surefire reports folder. I have my local weblogic server running while running these tests. I see 1.0.0.Alpha5 and 1.0.0.CR7 under arquillian-core maven repository. The parent tag in pom.xml under arquillian-core\examples\junit folder has 1.0.0.Alpha5. When I change it to 1.0.0.CR7 I see some dependency resolver issues and the tests wont even run. Please let me know if I should post any other info. As always, thanks a lot for your help.

               

                <testcase time="0" classname="com.acme.cdi.InjectionTestCase" name="initializationError">

                  <error message="JavaArchive" type="java.lang.NoClassDefFoundError">java.lang.NoClassDefFoundError: JavaArchive

                  at java.lang.Class.getDeclaredMethods0(Native Method)

                  at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)

                  at java.lang.Class.getMethod0(Class.java:2670)

                  at java.lang.Class.getMethod(Class.java:1603)

                  at org.junit.internal.builders.SuiteMethodBuilder.hasSuiteMethod(SuiteMethodBuilder.java:20)

                  at org.junit.internal.builders.SuiteMethodBuilder.runnerForClass(SuiteMethodBuilder.java:13)

                  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.execute(JUnit4TestSet.java:51)

                  at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115)

                  at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:102)

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

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

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

              Caused by: java.lang.ClassNotFoundException: JavaArchive

                  at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

                  at java.security.AccessController.doPrivileged(Native Method)

                  at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

                  at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

                  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

                  at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

                  ... 20 more

              </error>

               

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

               

              My arquillian.xml is attached as a file in this post.


              Here is the output from the command line where I execute the tests

               

              [INFO] Scanning for projects...

              [INFO]                                                                        

              [INFO] ------------------------------------------------------------------------

              [INFO] Building Arquillian Example JUnit 1.0.0.Alpha5

              [INFO] ------------------------------------------------------------------------

              [INFO]

              [INFO] --- maven-enforcer-plugin:1.0-beta-1:enforce (enforce-java-version) @ arquillian-example-junit ---

              [INFO]

              [INFO] --- maven-enforcer-plugin:1.0-beta-1:enforce (enforce-maven-version) @ arquillian-example-junit ---

              [INFO]

              [INFO] --- maven-enforcer-plugin:1.0-beta-1:enforce (enforce-maven-environment) @ arquillian-example-junit ---

              [INFO]

              [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ arquillian-example-junit ---

              [INFO] Using 'UTF-8' encoding to copy filtered resources.

              [INFO] skip non existing resourceDirectory c:\Documents and Settings\SS12323\arquillian-core\examples\junit\src\main\resources

              [INFO]

              [INFO] --- maven-compiler-plugin:2.3.1:compile (default-compile) @ arquillian-example-junit ---

              [INFO] No sources to compile

              [INFO]

              [INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ arquillian-example-junit ---

              [INFO] Using 'UTF-8' encoding to copy filtered resources.

              [INFO] Copying 1 resource

              [INFO]

              [INFO] --- maven-compiler-plugin:2.3.1:testCompile (default-testCompile) @ arquillian-example-junit ---

              [INFO] Nothing to compile - all classes are up to date

              [INFO]

              [INFO] --- maven-surefire-plugin:2.5:test (default-test) @ arquillian-example-junit ---

              [INFO] Surefire report directory: c:\Documents and Settings\SS12323\arquillian-core\examples\junit\target\surefire-reports

               

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

              T E S T S

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

              Running com.acme.cdi.InjectionTestCase

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

              Running com.acme.resource.InjectionTestCase

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

              Running com.acme.ejb.TemperatureConverterTestCase

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

              Running com.acme.jms.InjectionTestCase

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

              Running com.acme.ejb31.NoInterfaceEJBTestCase

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

              Running com.acme.cdi.random.RandomTestCase

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

              Running com.acme.web.LocalRunServletTestCase

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

              Running com.acme.cdi.payment.SynchronousPaymentProcessorTestCase

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

              Running com.acme.ejb.InjectionTestCase

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

               

              Results :

               

              Tests in error:

                initializationError(com.acme.cdi.InjectionTestCase)

                initializationError(com.acme.resource.InjectionTestCase)

                initializationError(com.acme.ejb.TemperatureConverterTestCase)

                initializationError(com.acme.jms.InjectionTestCase)

                initializationError(com.acme.ejb31.NoInterfaceEJBTestCase)

                initializationError(com.acme.cdi.random.RandomTestCase)

                initializationError(com.acme.web.LocalRunServletTestCase)

                initializationError(com.acme.cdi.payment.SynchronousPaymentProcessorTestCase)

                initializationError(com.acme.ejb.InjectionTestCase)

               

              Tests run: 9, Failures: 0, Errors: 9, Skipped: 0

               

              [INFO] ------------------------------------------------------------------------

              [INFO] BUILD FAILURE

              [INFO] ------------------------------------------------------------------------

              [INFO] Total time: 2.937s

              [INFO] Finished at: Wed Jan 11 10:03:34 EST 2012

              [INFO] Final Memory: 6M/15M

              [INFO] ------------------------------------------------------------------------

              [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.5:test (default-test) on project arquillian-example-junit: There are test failures.

              [ERROR]

              [ERROR] Please refer to c:\Documents and Settings\SS12323\arquillian-core\examples\junit\target\surefire-reports for the individual test results.

              [ERROR] -> [Help 1]

              [ERROR]

              [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

              [ERROR] Re-run Maven using the -X switch to enable full debug logging.

              [ERROR]

              [ERROR] For more information about the errors and possible solutions, please read the following articles:

              [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

              • 4. Re: Arquillian has previously been attempted initialized, but failed.
                vineet.reynolds

                Well, that is strange. It looks like a runtime error arising out of an incompatible or absent JARs in your Maven repository. The POM on GitHub for the master, certainly doesn't have the version as 1.0.0.Alpha5, and the CR7 tag also has the right version. Could see if you've forked an older version of  Arquillian Core, and also if your Maven repo has the necessary artifacts?

                • 5. Re: Arquillian has previously been attempted initialized, but failed.
                  sonuthekool

                  Hmmm. I used the following commands to get the core and wls-remote. Can you pls let me know if they are right ? I have attached the pom.xml under arquillian-core\example\junit folder, that was originally used to test with JBoss and now has a new weblogic profile and some changes for Weblogic as well in it that I used to run these tests now.

                   

                  for arquillian core - git clone git://github.com/arquillian/arquillian-core.git arquillian-core

                   

                  for wls-container - git clone git://github.com/arquillian/arquillian-container-wls.git arquillian-container-wls

                  • 6. Re: Arquillian has previously been attempted initialized, but failed.
                    vineet.reynolds

                    The commands are right, but having examined the tests, I do not think it is a good idea to use the test in arquillian-example-junit project against a WLS 10.3 installation, for several reasons:

                     

                    • WLS 10.3 is a JEE5 container, and most of the tests in the arquillian-example-junit project are targetted against JEE6 containers. Some tests could be made to work against WLS 10.3, but this requires changing the tests, or the classes in the arquillian-example-domain project.
                    • The EJB 3.0 compatible tests are bound to fail, as WLS 10.3 does not publish any mapping for local EJBs, to the global JNDI tree. Since Arquillian relies on JNDI lookups for injecting EJBs, one would either have to change the local EJBs to remote ones, or declare ejb-local-ref elements (see the WebLogicInjectionTestCase unit-test in the WLS integration project itself, to see how this is done).
                    • The CDI tests are bound to fail, since no implementation is present in WLS 10.3 to bootstrap CDI. The corresponding @Deployments would have to be modified, to include weld-servlet. See the WebLogicCDIEarTestCase, WebLogicCDIWarTestCase unit-tests in the WLS integration on how to do this for WLS 10.3.
                    • The tests that depend on JEE6 constituents like EJB 3.1 and Servlet 3.0, i.e. no-interface EJBs and Servlets defined using @WebServlet,  are bound to fail.

                     

                    I haven't run the tests involving JMS and JavaMail sessions; these are less likely to fail.

                     

                    If you do wish to modify any of these tests and get past the ClassNotFoundException/NoClassDefFoundError, add the following Maven profile to the POM:

                     

                     

                            <profile>
                                <id>wls-remote-103</id>
                                <dependencies>
                                    <dependency>
                                        <groupId>org.jboss.arquillian.container</groupId>
                                        <artifactId>arquillian-wls-remote-10.3</artifactId>
                                        <version>1.0.0.Alpha1</version>
                                    </dependency>
                                    <dependency>
                                        <groupId>org.jboss.arquillian.container</groupId>
                                        <artifactId>arquillian-container-spi</artifactId>
                                        <version>${project.version}</version>
                                    </dependency>
                                    <dependency>
                                        <groupId>org.jboss.arquillian.testenricher</groupId>
                                        <artifactId>arquillian-testenricher-cdi</artifactId>
                                        <version>${project.version}</version>
                                    </dependency>
                                    <dependency>
                                        <groupId>org.jboss.arquillian.testenricher</groupId>
                                        <artifactId>arquillian-testenricher-resource</artifactId>
                                        <version>${project.version}</version>
                                    </dependency>
                                    <dependency>
                                        <groupId>org.jboss.arquillian.testenricher</groupId>
                                        <artifactId>arquillian-testenricher-ejb</artifactId>
                                        <version>${project.version}</version>
                                    </dependency>
                                    <dependency>
                                        <groupId>org.jboss.arquillian.testenricher</groupId>
                                        <artifactId>arquillian-testenricher-initialcontext</artifactId>
                                        <version>${project.version}</version>
                                    </dependency>
                                    <dependency>
                                        <groupId>org.jboss.arquillian.protocol</groupId>
                                        <artifactId>arquillian-protocol-servlet</artifactId>
                                        <version>${project.version}</version>
                                    </dependency>
                                </dependencies>
                                <build>
                                    <plugins>
                                        <plugin>
                                            <groupId>org.apache.maven.plugins</groupId>
                                            <artifactId>maven-surefire-plugin</artifactId>
                                            <configuration>
                                                <includes>
                                                    <include>com/acme/ejb/*</include>
                                                </includes>
                                            </configuration>
                                        </plugin>
                                    </plugins>
                                </build>
                            </profile>
                    

                     

                    I've used this to attempt running the tests involving EJBs, but as stated earlier, the tests are bound to fail unless they're modified to suit WLS.

                     

                    Note that this is against the master branch in Git (having version 1.0.0.Final-SNAPSHOT), and not any specific tag (like 1.0.0.CR7). If you do run into dependency issues, it is usually because the WLS 1.0.0.Alpha1 integration brings the 1.0.0.CR5 version of Arquillian Core components, declared in it's POM. In such a scenario, run

                    mvn -Pwls-remote-103 dependency:tree

                    and override the components from 1.0.0.CR5, with the ones you need.

                     

                    Also, this is my arquillian.xml file:

                     

                    <?xml version="1.0" encoding="UTF-8"?>
                    <arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xmlns="http://jboss.org/schema/arquillian"
                        xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
                    
                        <engine>
                            <property name="deploymentExportPath">target/</property>
                        </engine>
                    
                        <container qualifier="wls" default="true">
                            <configuration>
                                <property name="adminUrl">t3://localhost:7001</property>
                                <property name="adminUserName">weblogic</property>
                                <property name="adminPassword">weblogic$1</property>
                                <property name="target">AdminServer</property>
                                <property name="wlsHome">G:\Oracle\Middleware\wlserver_10.3</property>
                            </configuration>
                        </container>
                    </arquillian>