ingwarsw / arquillian-suite-extension

Arquillian extension that will force single deployment for all tests
Apache License 2.0
67 stars 20 forks source link

Dependency on org.reflections:reflections:0.9.11 causes exception "could not scan file arquillian.xml" #51

Open mark1900 opened 6 years ago

mark1900 commented 6 years ago

Documenting an issue I had with a downstream dependency - https://github.com/ronmamo/reflections/issues/235


I get the following exception when combining

2018-07-16 14:52:26,614 X DEBUG [main] (Reflections:257) - could not scan file arquillian.xml in url file:/C:/dev/source/MyProject/ComponentA-test/target/test-classes/ with scanner TypeAnnotationsScanner
org.reflections.ReflectionsException: could not create class object from file arquillian.xml
    at org.reflections.scanners.AbstractScanner.scan(AbstractScanner.java:32)
    at org.reflections.Reflections.scan(Reflections.java:253)
    at org.reflections.Reflections.scan(Reflections.java:202)
    at org.reflections.Reflections.<init>(Reflections.java:123)
    at org.reflections.Reflections.<init>(Reflections.java:168)
    at org.eu.ingwar.tools.arquillian.extension.suite.ArquillianSuiteExtension.getDeploymentClass(ArquillianSuiteExtension.java:82)
    at org.eu.ingwar.tools.arquillian.extension.suite.ArquillianSuiteExtension.register(ArquillianSuiteExtension.java:65)
    at org.jboss.arquillian.core.impl.loadable.LoadableExtensionLoader.load(LoadableExtensionLoader.java:79)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:96)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:103)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:85)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:143)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)
    at org.jboss.arquillian.core.impl.ManagerImpl.fireProcessing(ManagerImpl.java:341)
    at org.jboss.arquillian.core.impl.ManagerImpl.<init>(ManagerImpl.java:98)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:162)
    at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:103)
    at org.jboss.arquillian.core.spi.ManagerBuilder.create(ManagerBuilder.java:77)
    at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.<init>(EventTestRunnerAdaptor.java:62)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:162)
    at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:103)
    at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:52)
    at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:114)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: org.reflections.ReflectionsException: could not create class file from arquillian.xml
    at org.reflections.adapters.JavassistAdapter.getOfCreateClassObject(JavassistAdapter.java:102)
    at org.reflections.adapters.JavassistAdapter.getOfCreateClassObject(JavassistAdapter.java:24)
    at org.reflections.scanners.AbstractScanner.scan(AbstractScanner.java:30)
    ... 40 more
Caused by: java.io.IOException: bad magic number: 3c3f786d
    at javassist.bytecode.ClassFile.read(ClassFile.java:773)
    at javassist.bytecode.ClassFile.<init>(ClassFile.java:118)
    at org.reflections.adapters.JavassistAdapter.getOfCreateClassObject(JavassistAdapter.java:100)
    ... 42 more

My current workaround

    <dependency>
        <groupId>org.eu.ingwar.tools</groupId>
        <artifactId>arquillian-suite-extension</artifactId>
        <version>1.1.4</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.reflections</groupId>
        <artifactId>reflections</artifactId>
        <version>0.9.10</version>
        <exclusions>
            <exclusion>
                <groupId>dom4j</groupId>
                <artifactId>dom4j</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

This issue could be related to https://github.com/ronmamo/reflections/issues/15, https://github.com/ronmamo/reflections/issues/184.

kullmanp commented 6 years ago

This workaround does not work for me.

mark1900 commented 6 years ago

@kullmanp Do you still still see this exception - IOException: bad magic number ?

FYI, I was able to upgrade to org.eu.ingwar.tools:arquillian-suite-extension:1.2.0 using the same workaround of setting the org.reflections:reflections:0.9.11 dependency.

My current configuration

kullmanp commented 6 years ago

@mark1900 yes, I still see it when I'm enabling debug logging.

mark1900 commented 5 years ago

@kullmanp Just a quick update. I am able to run this successfully against the latest Wildfly 17.0.1.Final release with the following properties.

Test Project pom.xml

<properties>
    <arquillian.bom.version>1.4.1.Final</arquillian.bom.version>

    <arquillian-suite-extension.bom.version>1.2.0</arquillian-suite-extension.bom.version>

    <!-- Support for Wildfly 12 and 13 - https://github.com/arquillian/arquillian-container-chameleon/pull/93/files -->
    <arquillian.wildfly-arquillian-container-managed.version>2.1.1.Final</arquillian.wildfly-arquillian-container-managed.version>

    <reflections.version>0.9.10</reflections.version>

    <!-- https://issues.jboss.org/browse/SHRINKRES-290 -->
    <!-- https://issues.jboss.org/browse/SHRINKRES-263 -->
    <shrinkwrap-resolver-impl-maven.version>2.2.4</shrinkwrap-resolver-impl-maven.version>
</properties>

Parent project pom.xml

<properties>
    <!-- https://github.com/wildfly/quickstart/blob/17.x/kitchensink-ear/pom.xml -->
    <!-- https://github.com/wildfly/quickstart/blob/17.x/kitchensink-ear/ejb/pom.xml -->
    <!-- https://github.com/wildfly/quickstart/blob/17.x/kitchensink-ear/web/pom.xml -->

    <!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <wildfly.bom.version>17.0.1.Final</wildfly.bom.version>

    <!-- other plugin versions -->
    <clean.plugin.version>3.0.0</clean.plugin.version>
    <compiler.plugin.version>3.7.0</compiler.plugin.version>
    <jar.plugin.version>3.1.0</jar.plugin.version>
    <war.plugin.version>3.2.2</war.plugin.version>
    <ejb.plugin.version>3.0.1</ejb.plugin.version>
    <ear.plugin.version>3.0.1</ear.plugin.version>

    <build-helper.plugin.version>1.10</build-helper.plugin.version>
    <surefire.plugin.version>2.17</surefire.plugin.version> <!-- Use a version compatible with Arquillian -->
    <!-- <surefire.plugin.version>2.22.0</surefire.plugin.version> -->
    <failsafe.plugin.version>2.19.1</failsafe.plugin.version>

<!-- https://winterbe.com/posts/2018/08/29/migrate-maven-projects-to-java-11-jigsaw/ -->
    <!-- maven-compiler-plugin -->
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>

    <!-- other -->
    <javaee-api.version>8.0</javaee-api.version>
    <org.hibernate.version>5.3.10.Final</org.hibernate.version>
    <org.infinispan.version>9.4.14.Final</org.infinispan.version>

    <postgresql.version>42.2.6</postgresql.version>
    <commons-codec.version>1.6</commons-codec.version> <!-- 2011-12-03 -->
    <gson.version>2.8.5</gson.version>
    <guava.version>19.0</guava.version> <!-- 2015-12-09 -->
    <javassist.version>3.23.2-GA</javassist.version> <!-- 2018-07-01 --> <!-- Matches wildfly-17.0.1.Final module -->
<!-- <javassist.version>3.23.2-GA</javassist.version> --> <!-- 2019-04-18 -->
<!-- <javassist.version>3.18.1-GA</javassist.version> --> <!-- 2013-08-30 -->
    <opencsv.version>4.2</opencsv.version>
    <rest-assured.version>3.3.0</rest-assured.version> <!-- 2018-08-17 -->

    <slf4j.version>1.7.25</slf4j.version> <!-- 2017-03-17 -->
    <log4j.version>1.2.17</log4j.version> <!-- 2012-05-13 -->
    <jmockit.version>1.46</jmockit.version> <!-- 2019-03-31 -->
    <!-- <jmockit.version>1.41</jmockit.version> --> <!-- 2018-07-29 --> <!-- Beware new versions require -javaagent - http://jmockit.github.io/changes.html -->
    <junit.version>4.12</junit.version> <!-- 2014-12-04 -->

    <versions-maven-plugin.version>2.7</versions-maven-plugin.version>

</properties>

arquillian.xml

<?xml version="1.0" ?>
<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">

    <!-- https://github.com/ingwarsw/arquillian-suite-extension/blob/master/src/test/resources/arquillian.xml -->

    <defaultProtocol type="Servlet 3.0"/>

    <engine>
        <property name="deploymentExportPath">target/deployments</property>
    </engine>

    <container qualifier="wildfly-arquillian-container-managed" default="true">
        <configuration>
            <property name="serverConfig">standalone-full.xml</property>
            <property name="jbossHome">${env.JBOSS_HOME}</property>
            <property name="javaVmArguments">-Darquillian.debug=true -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n --add-modules=java.se</property>

            <property name="outputToConsole">true</property>
        </configuration>
    </container>

    <!-- http://stackoverflow.com/questions/28046537/testing-jpa-entity-classes-error-transaction-is-required/ -->
    <extension qualifier="transaction">
        <property name="manager">java:jboss/UserTransaction</property>
    </extension>

</arquillian>