We have an old drools library that've been upgrading to later versions of KIE, and Executable rule models caught my eye. When I started my migration, my dependencies looked like this:
<dependencies>
...
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.mvel</groupId>
<artifactId>mvel2</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${kie.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<version>${kie.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
...
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>${kie.version}</version>
<extensions>true</extensions>
</plugin>
Using 7.26.0.Final. When I upgraded to 7.59.0.Final I added the compiler dependency as I was supposed to from the doc:
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-model-compiler</artifactId>
<version>${kie.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${kie.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<version>${kie.version}</version>
</dependency>
But my generate model now seems to fail:
[INFO] --- kie-maven-plugin:7.59.0.Final:generateModel (default-generateModel) # rules ---
[INFO] Using NEW implementation
[INFO] Using NEW implementation
[INFO] Artifact not fetched from maven: org.drools:drools-model-compiler:7.59.0.Final. To enable the KieScanner you need kie-ci on the classpath
[INFO] Artifact not fetched from maven: org.kie:kie-ci:7.59.0.Final. To enable the KieScanner you need kie-ci on the classpath
[INFO] Artifact not fetched from maven: org.apache.commons:commons-collections4:4.4. To enable the KieScanner you need kie-ci on the classpath
[INFO] Artifact not fetched from maven: org.apache.commons:commons-lang3:3.12.0. To enable the KieScanner you need kie-ci on the classpath
[INFO] Artifact not fetched from maven: org.kie:kie-api:7.59.0.Final. To enable the KieScanner you need kie-ci on the classpath
[INFO] Artifact not fetched from maven: org.mvel:mvel2:2.4.12.Final. To enable the KieScanner you need kie-ci on the classpath
WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[WARNING] Found more than one default KieBase: disabling all. KieBases will be accessible only by name
[WARNING] Found more than one default KieSession: disabling all. KieSessions will be accessible only by name
[ERROR] Unable to build KieBaseModel:plan-rules
InvalidExpressionErrorResult: Method equalsAnyIgnoreCase on class org.apache.commons.lang3.StringUtils with arguments [class java.lang.String, class java.lang.Object] is missing
InvalidExpressionErrorResult: Method intersectionsStartsWith on class com.accolade.clinical.utils.RuleUtils with arguments [interface java.util.List, class java.lang.Object] is missing
InvalidExpressionErrorResult: Method size on class java.lang.Object with arguments [] is missing
... (A lot more errors of this nature)
Why won't it pick up the dependencies even if I have maven CI and the plugin configured? Is there something I missed in the docs?
Edit:
As per the the first answer:
I tried replacing the 3 dependencies I've listed above with
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-engine</artifactId>
<version>${kie.version}</version>
</dependency>
But unfortunately kie doesn't want to use the new generate models method in this case:
[INFO] --- kie-maven-plugin:7.59.0.Final:generateModel (default-generateModel) # rules ---
[WARNING] You're trying to build rule assets in a project from an executable rule model, but you did not provide the required dependency on the project classpath.
To enable executable rule models for your project, add the `drools-model-compiler` dependency in the `pom.xml` file of your project.
[INFO]
[INFO] --- kie-maven-plugin:7.59.0.Final:generateDMNModel (default-generateDMNModel) # rules ---
[INFO]
[INFO] --- kie-maven-plugin:7.59.0.Final:generatePMMLModel (default-generatePMMLModel) # rules ---
[WARNING] Skipping `generatePMMLModel` because you did not provide the required dependency on the project classpath.
To enable it for your project, add the `drools-model-compiler` dependency in the `pom.xml` file of your project.
[INFO]
[INFO] --- kie-maven-plugin:7.59.0.Final:generateANC (default-generateANC) # rules ---
[INFO]
[INFO] --- kie-maven-plugin:7.59.0.Final:build (default-build) # rules ---
Here's an output of mvn dependency:tree:
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< com.mycompany:rules >---------------------
[INFO] Building Rules 5.0.0-SNAPSHOT
[INFO] --------------------------------[ kjar ]--------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # rules ---
[INFO] com.mycompany:rules:kjar:5.0.0-SNAPSHOT
[INFO] +- com.mycompany.acp.utilities:model-utilities:jar:7.1.0:compile
[INFO] | +- com.mycompany.acp.fhir:common-fhir:jar:8.2.0:compile
[INFO] | | +- io.swagger.core.v3:swagger-annotations:jar:2.1.10:compile
[INFO] | | +- io.swagger:swagger-annotations:jar:1.6.2:compile
[INFO] | | +- org.reflections:reflections:jar:0.9.12:compile
[INFO] | | | \- org.javassist:javassist:jar:3.26.0-GA:compile
[INFO] | | +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] | | | \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] | | +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] | | | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | | | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | | \- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] | +- com.github.java-json-tools:json-patch:jar:1.13:compile
[INFO] | +- com.github.java-json-tools:msg-simple:jar:1.2:compile
[INFO] | | \- com.github.java-json-tools:btf:jar:1.3:compile
[INFO] | +- com.github.java-json-tools:jackson-coreutils:jar:2.0:compile
[INFO] | +- com.contentful.java:java-sdk:jar:10.4.5:compile
[INFO] | | +- com.squareup.retrofit2:retrofit:jar:2.5.0:compile
[INFO] | | +- com.squareup.retrofit2:adapter-rxjava2:jar:2.5.0:compile
[INFO] | | +- com.squareup.retrofit2:converter-gson:jar:2.5.0:compile
[INFO] | | +- io.reactivex.rxjava2:rxjava:jar:2.2.6:compile
[INFO] | | | \- org.reactivestreams:reactive-streams:jar:1.0.2:compile
[INFO] | | +- com.squareup.okhttp3:okhttp:jar:3.12.12:compile
[INFO] | | | \- com.squareup.okio:okio:jar:1.15.0:compile
[INFO] | | +- com.google.code.gson:gson:jar:2.8.5:compile
[INFO] | | \- com.github.tony19:named-regexp:jar:0.2.5:compile
[INFO] | +- com.mycompany.acp.resources:singularity-models:jar:6.1.0:compile
[INFO] | | +- com.mycompany.acp-common-eventbus:models:jar:5.0.3:compile
[INFO] | | | \- com.amazonaws:aws-java-sdk-sns:jar:1.11.625:compile
[INFO] | | | \- com.amazonaws:aws-java-sdk-sqs:jar:1.11.625:compile
[INFO] | | +- com.amazonaws:aws-java-sdk-dynamodb:jar:1.12.18:compile
[INFO] | | | +- com.amazonaws:aws-java-sdk-s3:jar:1.12.18:compile
[INFO] | | | | \- com.amazonaws:aws-java-sdk-kms:jar:1.12.18:compile
[INFO] | | | +- com.amazonaws:aws-java-sdk-core:jar:1.12.18:compile
[INFO] | | | | +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO] | | | | | \- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] | | | | +- software.amazon.ion:ion-java:jar:1.0.2:compile
[INFO] | | | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.12.3:compile
[INFO] | | | | \- joda-time:joda-time:jar:2.8.1:compile
[INFO] | | | \- com.amazonaws:jmespath-java:jar:1.12.18:compile
[INFO] | | +- com.amazonaws:aws-java-sdk-sts:jar:1.12.18:compile
[INFO] | | \- com.mycompany.acp.fhir:common-utilities:jar:8.2.0:compile
[INFO] | | \- org.springframework:spring-web:jar:5.3.8:compile
[INFO] | | +- org.springframework:spring-beans:jar:5.3.8:compile
[INFO] | | \- org.springframework:spring-core:jar:5.3.8:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.3.8:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-databind:jar:2.12.4:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.4:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.4:compile
[INFO] +- org.apache.commons:commons-collections4:jar:4.4:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.12.0:compile
[INFO] +- commons-io:commons-io:jar:2.11.0:compile
[INFO] +- org.mvel:mvel2:jar:2.4.12.Final:compile
[INFO] +- org.slf4j:slf4j-api:jar:2.0.0-alpha5:provided
[INFO] +- org.projectlombok:lombok:jar:1.18.20:provided
[INFO] +- org.drools:drools-engine:jar:7.59.0.Final:compile
[INFO] | +- org.kie:kie-api:jar:7.59.0.Final:compile
[INFO] | | \- org.kie.soup:kie-soup-maven-support:jar:7.59.0.Final:compile
[INFO] | +- org.kie:kie-internal:jar:7.59.0.Final:compile
[INFO] | +- org.drools:drools-core:jar:7.59.0.Final:compile
[INFO] | | +- org.kie.soup:kie-soup-xstream:jar:7.59.0.Final:compile
[INFO] | | +- org.drools:drools-core-reflective:jar:7.59.0.Final:compile
[INFO] | | +- org.drools:drools-core-dynamic:jar:7.59.0.Final:runtime
[INFO] | | \- commons-codec:commons-codec:jar:1.11:compile
[INFO] | +- org.drools:drools-compiler:jar:7.59.0.Final:compile
[INFO] | | +- org.kie:kie-memory-compiler:jar:7.59.0.Final:compile
[INFO] | | +- org.drools:drools-ecj:jar:7.59.0.Final:compile
[INFO] | | +- org.antlr:antlr-runtime:jar:3.5.2:compile
[INFO] | | \- com.thoughtworks.xstream:xstream:jar:1.4.17:compile
[INFO] | | \- io.github.x-stream:mxparser:jar:1.2.1:compile
[INFO] | | \- xmlpull:xmlpull:jar:1.1.3.1:compile
[INFO] | \- org.drools:drools-model-compiler:jar:7.59.0.Final:compile
[INFO] | +- org.drools:drools-canonical-model:jar:7.59.0.Final:compile
[INFO] | +- com.github.javaparser:javaparser-core:jar:3.13.10:compile
[INFO] | +- org.drools:drools-mvel-parser:jar:7.59.0.Final:compile
[INFO] | \- org.drools:drools-mvel-compiler:jar:7.59.0.Final:compile
[INFO] +- xerces:xercesImpl:jar:2.12.1:test
[INFO] | \- xml-apis:xml-apis:jar:1.4.01:test
[INFO] +- com.google.guava:guava:jar:30.1.1-jre:test
[INFO] | +- com.google.guava:failureaccess:jar:1.0.1:test
[INFO] | +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:test
[INFO] | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] | +- org.checkerframework:checker-qual:jar:3.8.0:test
[INFO] | +- com.google.errorprone:error_prone_annotations:jar:2.5.1:test
[INFO] | \- com.google.j2objc:j2objc-annotations:jar:1.3:test
[INFO] +- org.junit.jupiter:junit-jupiter-api:jar:5.7.2:test
[INFO] | +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | \- org.junit.platform:junit-platform-commons:jar:1.7.2:test
[INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.7.2:test
[INFO] | \- org.junit.platform:junit-platform-engine:jar:1.7.2:test
[INFO] \- org.junit.jupiter:junit-jupiter-params:jar:5.7.2:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.439 s
[INFO] Finished at: 2021-09-19T23:53:58-07:00
[INFO] ------------------------------------------------------------------------
Can you try using these new wrapper modules? They should solve your problem
"
This issue is mainly caused by the fact that users have among their dependencies modules like drools-core and drools-compiler that in reality are no more than "internal implementation details". To avoid similar problems in future, in the very likely case that other modules will be introduced to split engine in finer grained submodules and descope optional features, the following 2 new wrapper modules have been created to cover the 2 different main usage scenarios:
drools-engine aggregating drools-core, drools-compiler and drools-model-compiler
drools-engine-classic aggregating drools-core, drools-compiler and drools-mvel
"
If you want to use the executable model, use drools-engine
Edit:
The dependencies are correct, if you see this error message
InvalidExpressionErrorResult: Method equalsAnyIgnoreCase on class org.apache.commons.lang3.StringUtils with arguments [class java.lang.String, class java.lang.Object] is missing
InvalidExpressionErrorResult: Method intersectionsStartsWith on class com.accolade.clinical.utils.RuleUtils with arguments [interface java.util.List, class java.lang.Object] is missing
InvalidExpressionErrorResult: Method size on class java.lang.Object with arguments [] is missing
It means the executable model is compiling, but it's failing on some of your rules. We'll need a reproducer to see what's going on now. For example the line
InvalidExpressionErrorResult: Method size on class java.lang.Object with arguments [] is missing
Seems really strange as Object doesn't have a size() method.
Please file a bug on issues.redhat.com uploading your obfuscated rules so that we can investigate further.
Related
I am having some difficulty configuring some loggers for velocity in Spring. I am using Velocity 2.1, Spring 5.2.2 and SLF4J 2.0.0
org.slf4j.simple.SimpleLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.
I am trying to configure some old discarded Spring classes to build a JAR (new versions of them) to use in my application.
velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE, (new SimpleLoggerFactory()).getLogger("SpringVelocityConfiguration"));
This is how I am doing it. But I keep getting the exception.
The line throwing the exception is from org.apache.velocity.runtime.RuntimeInstance:
if (Logger.class.isAssignableFrom(o.getClass()))
From what I saw from the API documentation, SimpleLogger is a subclass to Logger. So it should work out isn't it?
Adding the dependency tree as requested:
[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) # spring-velocity-support ---
[INFO] com.gtt.palabs:spring-velocity-support:jar:0.0.1-SNAPSHOT
[INFO] +- commons-logging:commons-logging:jar:1.2:provided
[INFO] +- javax.servlet:javax.servlet-api:jar:4.0.1:provided
[INFO] +- org.slf4j:slf4j-api:jar:2.0.0-alpha1:provided
[INFO] +- org.slf4j:slf4j-simple:jar:2.0.0-alpha1:compile
[INFO] +- org.springframework:spring-context:jar:5.2.2.RELEASE:provided
[INFO] | +- org.springframework:spring-aop:jar:5.2.2.RELEASE:provided
[INFO] | +- org.springframework:spring-beans:jar:5.2.2.RELEASE:provided
[INFO] | \- org.springframework:spring-expression:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-core:jar:5.2.2.RELEASE:provided
[INFO] | \- org.springframework:spring-jcl:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-web:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-webmvc:jar:5.2.2.RELEASE:provided
[INFO] +- org.apache.velocity:velocity-engine-core:jar:2.1:provided
[INFO] | \- org.apache.commons:commons-lang3:jar:3.9:compile
[INFO] +- org.apache.velocity.tools:velocity-tools-generic:jar:3.0:provided
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] | | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | +- org.apache.commons:commons-digester3:jar:3.2:compile
[INFO] | | \- cglib:cglib:jar:2.2.2:compile
[INFO] | | \- asm:asm:jar:3.3.1:compile
[INFO] | \- com.github.cliftonlabs:json-simple:jar:3.0.2:provided
[INFO] \- org.apache.velocity.tools:velocity-tools-view:jar:3.0:compile
Error:
org.apache.velocity.exception.VelocityException: Error initializing log: com.gtt.logicalprovisioning.velocity.utilities.VelocityLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.
at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:958)
at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:260)
at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:90)
at com.gtt.logicalprovisioning.velocity.utilities.VelocityBuilderSystem.<init>(VelocityBuilderSystem.java:69)
at com.gtt.logicalprovisioning.ipflex.VelocityBuilderAction.processAction(VelocityBuilderAction.java:158)
at com.gtt.logicalprovisioning.rtp.BaseActionListType.run(BaseActionListType.java:72)
Caused by: org.apache.velocity.exception.VelocityException: com.gtt.logicalprovisioning.velocity.utilities.VelocityLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.
at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:931)
... 5 more
The log line says it all:
org.apache.velocity.exception.VelocityException: Error initializing log:
com.gtt.logicalprovisioning.velocity.utilities.VelocityLogger
object set as runtime.log.instance
is not a valid org.slf4j.Logger implementation.
It means that the old Spring classes you are working with do overwrite the runtime.instance.log property before Velocity initialization is carried on.
In my project I have a package that uses several 3rd party libraries. Let's have a look at the dependency tree:
[INFO] +- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.apache.directory.studio:org.apache.commons.collections:jar:3.2.1:compile
[INFO] | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- xerces:xercesImpl:jar:2.11.0:compile
[INFO] | \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] +- org.apache.cxf:cxf-rt-bindings-soap:jar:3.2.2:compile
[INFO] | +- org.apache.cxf:cxf-core:jar:3.2.2:compile
[INFO] | | +- com.fasterxml.woodstox:woodstox-core:jar:5.0.3:compile
[INFO] | | | \- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
[INFO] | | \- org.apache.ws.xmlschema:xmlschema-core:jar:2.2.3:compile
[INFO] | +- org.apache.cxf:cxf-rt-wsdl:jar:3.2.2:compile
[INFO] | | +- wsdl4j:wsdl4j:jar:1.6.3:compile
[INFO] | | \- org.ow2.asm:asm:jar:5.2:compile
[INFO] | \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:3.2.2:compile
[INFO] +- org.apache.wss4j:wss4j-ws-security-common:jar:2.2.1:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.22:compile
[INFO] | +- org.apache.santuario:xmlsec:jar:2.1.1:compile
[INFO] | | \- commons-codec:commons-codec:jar:1.10:compile
[INFO] | +- org.opensaml:opensaml-saml-impl:jar:3.3.0:compile
[INFO] | | +- org.opensaml:opensaml-profile-api:jar:3.3.0:compile
[INFO] | | | \- org.opensaml:opensaml-core:jar:3.3.0:compile
[INFO] | | | \- io.dropwizard.metrics:metrics-core:jar:3.1.2:compile
[INFO] | | +- org.opensaml:opensaml-saml-api:jar:3.3.0:compile
[INFO] | | | +- org.opensaml:opensaml-xmlsec-api:jar:3.3.0:compile
[INFO] | | | \- org.opensaml:opensaml-soap-api:jar:3.3.0:compile
[INFO] | | +- org.opensaml:opensaml-security-impl:jar:3.3.0:compile
[INFO] | | | \- org.opensaml:opensaml-security-api:jar:3.3.0:compile
[INFO] | | | +- org.cryptacular:cryptacular:jar:1.1.1:compile
[INFO] | | | \- org.bouncycastle:bcprov-jdk15on:jar:1.55:compile
[INFO] | | +- org.opensaml:opensaml-xmlsec-impl:jar:3.3.0:compile
[INFO] | | \- net.shibboleth.utilities:java-support:jar:7.3.0:compile
[INFO] | | +- com.google.guava:guava:jar:19.0:compile
[INFO] | | \- joda-time:joda-time:jar:2.7:compile
[INFO] | +- org.opensaml:opensaml-xacml-impl:jar:3.3.0:compile
[INFO] | | \- org.opensaml:opensaml-xacml-api:jar:3.3.0:compile
[INFO] | +- org.opensaml:opensaml-xacml-saml-impl:jar:3.3.0:compile
[INFO] | | \- org.opensaml:opensaml-xacml-saml-api:jar:3.3.0:compile
[INFO] | +- org.jasypt:jasypt:jar:1.9.2:compile
[INFO] | \- org.apache.geronimo.javamail:geronimo-javamail_1.4_mail:jar:1.8.4:compile
[INFO] +- org.apache.wss4j:wss4j-ws-security-dom:jar:2.2.1:compile
[INFO] | \- net.sf.ehcache:ehcache:jar:2.10.4:runtime
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.22:compile
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] \- org.testng:testng:jar:6.11:test
[INFO] +- com.beust:jcommander:jar:1.64:test
[INFO] \- org.yaml:snakeyaml:jar:1.17:test
Compiling and running works fine so far.
But when I what to start debugging with IntelliJ, I get a list of over 100 errors like:
Error:java: the unnamed module reads package org.opensaml.saml.config from both opensaml.saml.api and opensaml.saml.impl
Error:java: the unnamed module reads package javax.xml.datatype from both xml.apis and java.xml
Error:java: the unnamed module reads package javax.xml.transform.dom from both xml.apis and java.xml
....
This seems to be an error due to the new Java 9 module restrictions. But how to deal with here?
Both org.opensaml are part of wss4j-ws-security-common 2.2.1 (this is the last version, released in January 2018). opensaml.saml.api and opensaml.saml.impl are version 3.3.0 and both use org.opensaml.saml.config of the same version. So???
And why does "mvn compile" pass, but debugging with IntelliJ fails?
I had the same 100+ multititude of "ERROR: The unnamed module reads package javax.xml from both xml.apis and java.xml" in my Java 9 IntelliJ project too.
Except I would get them whenever I tried to run unit tests in IntelliJ. Everything worked perfectly building and testing with maven from the command line; just like you.
I was able to make my errors go away by...
1) Removing the following from the top-level pom of a multi-module project...
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
...
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${javaee.api.version}</version>
<scope>provided</scope>
</dependency>
2) Right clicking the top-level pom in IntelliJ's project navigator, then select "Maven - Reimport"
3) Doing "Build -> Build module [myModule]" from the IntelliJ menu.
Just work out which maven artifacts contain the packages listed in your 100+"ERROR" messages. Then comment them out. Reimport. Then "Build module" from the menu. That worked for me anyway.
The artifacts I removed from the pom were copy/pasted in there speculatively from another project I used as a template. But luckily I don't need any of them.
This is a known IDEA bug. Please vote for https://youtrack.jetbrains.com/issue/IDEA-171320
I'm currently attempting to get PlexusContainer to give me an initialized Maven-instance outside of a maven or eclipse execution context.
For that purpose I have following code (simplified):
PlexusContainer container = null;
try {
container = new DefaultPlexusContainer();
container.lookup(MavenResolutionTask.class).run();
container.dispose();
} catch (Exception e) {
e.printStackTrace();
}
// --- MavenResolutionTask.java:
#Component(role = MavenResolutionTask.class)
// ResolutionTask is an abstract class
// implementing Runnable and extending CompletableFuture
public class MavenResolutionTask extends ResolutionTask {
#Requirement
private Maven maven;
}
Given that I had the standard plexus-component-metadata:process-classes plugin execution in my pom.xml I would've liked if this had worked like this.
Unfortunately running this code results in a LookupException with the following reason (stacktrace omitted for brevity):
WARN Sisu - Error injecting: org.apache.maven.project.DefaultProjectBuildingHelper
com.google.inject.ProvisionException: Guice provision errors:
1) No implementation for org.apache.maven.repository.RepositorySystem was bound.
while locating org.apache.maven.project.DefaultProjectBuildingHelper
WARN Sisu - Error injecting: org.apache.maven.project.DefaultProjectBuilder
com.google.inject.ProvisionException: Guice provision errors:
1) No implementation for org.apache.maven.repository.RepositorySystem was bound.
while locating org.apache.maven.project.DefaultProjectBuildingHelper
at ClassRealm[plexus.core, parent: null]
at ClassRealm[plexus.core, parent: null]
while locating org.apache.maven.project.ProjectBuildingHelper
while locating org.apache.maven.project.DefaultProjectBuilder
...
To remediate the missing bindings and prevent myself from having to go through the trouble of manually registering the complete dependency-graph of maven I attempted to merge the component descriptors included in my dependencies with the one generated for my application.
For that purpose I copied all dependencies into target/dependency and ran some shell-scripts to get a list of all dependencies that include a components.xml.
I pass these dependencies to an execution of dependency:unpack before then passing the extracted locations to the metadata-merger like so:
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<version>1.7.1</version>
<executions>
<execution>
<id>process-classes</id>
<goals>
<goal>generate-metadata</goal>
</goals>
</execution>
<execution>
<id>process-test-classes</id>
<goals>
<goal>generate-test-metadata</goal>
</goals>
</execution>
<execution>
<id>merge-descriptors</id>
<phase>process-classes</phase>
<goals>
<goal>merge-metadata</goal>
</goals>
</execution>
</executions>
<configuration>
<output>${plexus.outputFile}</output>
<descriptors>
<descriptor>${plexus.outputFile}</descriptor>
<!--./aether-transport-wagon-1.1.0.jar.d/META-INF/plexus/components.xml-->
<descriptor>${project.build.directory}/extracted-sources/aether-transport-wagon/META-INF/plexus/components.xml</descriptor>
<!--./maven-aether-provider-3.1.0.jar.d/META-INF/plexus/components.xml-->
<descriptor>${project.build.directory}/extracted-sources/maven-aether-provider/META-INF/plexus/components.xml</descriptor>
<!--./maven-artifact-manager-2.2.1.jar.d/META-INF/plexus/components.xml-->
<descriptor>${project.build.directory}/extracted-sources/maven-artifact-manager/META-INF/plexus/components.xml</descriptor>
<!--./maven-core-3.1.1.jar.d/META-INF/plexus/components.xml-->
<descriptor>${project.build.directory}/extracted-sources/maven-core/META-INF/plexus/components.xml</descriptor>
<!--./maven-model-builder-3.1.0.jar.d/META-INF/plexus/components.xml-->
<descriptor>${project.build.directory}/extracted-sources/maven-model-builder/META-INF/plexus/components.xml</descriptor>
<!--./maven-plugin-registry-2.2.1.jar.d/META-INF/plexus/components.xml-->
<descriptor>${project.build.directory}/extracted-sources/maven-plugin-registry/META-INF/plexus/components.xml</descriptor>
<!--./maven-profile-2.2.1.jar.d/META-INF/plexus/components.xml-->
<descriptor>${project.build.directory}/extracted-sources/maven-profile/META-INF/plexus/components.xml</descriptor>
<!--./maven-project-2.2.1.jar.d/META-INF/plexus/components.xml-->
<descriptor>${project.build.directory}/extracted-sources/maven-project/META-INF/plexus/components.xml</descriptor>
<!--./maven-settings-builder-3.1.1.jar.d/META-INF/plexus/components.xml-->
<descriptor>${project.build.directory}/extracted-sources/maven-settings-builder/META-INF/plexus/components.xml</descriptor>
<!--./org.eclipse.sisu.plexus-0.0.0.M2a.jar.d/META-INF/plexus/components.xml-->
<descriptor>${project.build.directory}/extracted-sources/sisu-plexus/META-INF/plexus/components.xml</descriptor>
<!--./plexus-cipher-1.4.jar.d/META-INF/plexus/components.xml-->
<descriptor>${project.build.directory}/extracted-sources/plexus-cipher/META-INF/plexus/components.xml</descriptor>
<!--./plexus-interactivity-api-1.0-alpha-6.jar.d/META-INF/plexus/components.xml-->
<descriptor>${project.build.directory}/extracted-sources/plexus-interactivity-api/META-INF/plexus/components.xml</descriptor>
<!--./plexus-sec-dispatcher-1.3.jar.d/META-INF/plexus/components.xml-->
<descriptor>${project.build.directory}/extracted-sources/plexus-sec-dispatcher/META-INF/plexus/components.xml</descriptor>
<!--./wagon-ssh-1.0.jar.d/META-INF/plexus/components.xml-->
<descriptor>${project.build.directory}/extracted-sources/wagon-ssh/META-INF/plexus/components.xml</descriptor>
<!--./wagon-ssh-common-1.0.jar.d/META-INF/plexus/components.xml-->
<descriptor>${project.build.directory}/extracted-sources/wagon-ssh-common/META-INF/plexus/components.xml</descriptor>
</descriptors>
</configuration>
</plugin>
Unfortunately the error message persists
So I guess my question is: How do I easily get a Maven instance from Plexus?
P.S. for completeness sake, I'm currently using the following dependencies:
[INFO] com.github.vogel612:dependency-analyzer:jar:0.0.1
[INFO] +- org.projectlombok:lombok:jar:1.16.16:compile
[INFO] +- commons-cli:commons-cli:jar:1.4:compile
[INFO] +- org.slf4j:slf4j-simple:jar:1.7.16:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.16:compile
[INFO] +- org.codehaus.plexus:plexus-utils:jar:3.0.24:compile
[INFO] +- org.eclipse.aether:aether-api:jar:1.1.0:compile
[INFO] +- org.eclipse.aether:aether-util:jar:1.1.0:compile
[INFO] +- org.eclipse.aether:aether-impl:jar:1.1.0:compile
[INFO] | \- org.eclipse.aether:aether-spi:jar:1.1.0:compile
[INFO] +- org.eclipse.aether:aether-connector-basic:jar:1.1.0:compile
[INFO] +- org.eclipse.aether:aether-transport-file:jar:1.1.0:compile
[INFO] +- org.eclipse.aether:aether-transport-http:jar:1.1.0:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.3.5:compile
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.3.2:compile
[INFO] | | \- commons-codec:commons-codec:jar:1.6:compile
[INFO] | \- org.slf4j:jcl-over-slf4j:jar:1.6.2:compile
[INFO] +- org.eclipse.aether:aether-transport-wagon:jar:1.1.0:compile
[INFO] | \- org.apache.maven.wagon:wagon-provider-api:jar:1.0:compile
[INFO] +- org.apache.maven:maven-aether-provider:jar:3.1.0:compile
[INFO] | +- org.apache.maven:maven-model:jar:3.1.0:compile
[INFO] | +- org.apache.maven:maven-model-builder:jar:3.1.0:compile
[INFO] | +- org.apache.maven:maven-repository-metadata:jar:3.1.0:compile
[INFO] | +- org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.0.0.M2a:compile
[INFO] | | +- javax.enterprise:cdi-api:jar:1.0:compile
[INFO] | | | +- javax.annotation:jsr250-api:jar:1.0:compile
[INFO] | | | \- javax.inject:javax.inject:jar:1:compile
[INFO] | | +- com.google.guava:guava:jar:10.0.1:compile
[INFO] | | | \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] | | +- org.sonatype.sisu:sisu-guice:jar:no_aop:3.1.0:compile
[INFO] | | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | | \- org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.0.0.M2a:compile
[INFO] | | \- asm:asm:jar:3.3.1:compile
[INFO] | \- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile
[INFO] +- org.apache.maven.wagon:wagon-ssh:jar:1.0:compile
[INFO] | +- com.jcraft:jsch:jar:0.1.44-1:compile
[INFO] | \- org.apache.maven.wagon:wagon-ssh-common:jar:1.0:compile
[INFO] | \- org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-6:compile
[INFO] +- org.apache.maven:maven-core:jar:3.1.1:compile
[INFO] | +- org.apache.maven:maven-settings:jar:3.1.1:compile
[INFO] | +- org.apache.maven:maven-settings-builder:jar:3.1.1:compile
[INFO] | +- org.apache.maven:maven-artifact:jar:3.1.1:compile
[INFO] | +- org.apache.maven:maven-plugin-api:jar:3.1.1:compile
[INFO] | +- org.codehaus.plexus:plexus-interpolation:jar:1.19:compile
[INFO] | +- org.codehaus.plexus:plexus-classworlds:jar:2.5.1:compile
[INFO] | \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile
[INFO] | \- org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[INFO] \- org.apache.maven:maven-project:jar:2.2.1:compile
[INFO] +- org.apache.maven:maven-profile:jar:2.2.1:compile
[INFO] +- org.apache.maven:maven-artifact-manager:jar:2.2.1:compile
[INFO] | \- backport-util-concurrent:backport-util-concurrent:jar:3.1:compile
[INFO] +- org.apache.maven:maven-plugin-registry:jar:2.2.1:compile
[INFO] \- org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
[INFO] +- junit:junit:jar:3.8.1:compile
[INFO] \- classworlds:classworlds:jar:1.1-alpha-2:compile
It might have been helpful as a start to read the error message closely:
The missing Component is org.apache.maven.repository.RepositorySystem and not org.eclipse.aether.RepositorySystem. While the former was already included, the latter is only present in org.apache.maven:maven-compat.
Adding that to the dependencies (and including it's component definitions) fixes the immediate issue here. The intermediate result is currently a NoClassDefFoundError for Lorg/apache/maven/artifact/transform/ArtifactTransformationManager, which can be resolved by actually using the correct version of the dependency.
As the final step now an instance of org.eclipse.aether.RepositorySystem and one instance of org.eclipse.aether.impl.RemoteRepositoryManager needs to be registered, which can be accomplished using code along the following lines:
final ServiceLocator serviceLocator = MavenRepositorySystemUtils.newServiceLocator()
.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class)
.addService(TransporterFactory.class, FileTransporterFactory.class)
.addService(TransporterFactory.class, HttpTransporterFactory.class);
// ...
container.addComponent(serviceLocator.lookup(RepositorySystem.class)
, RepositorySystem.class
, "default");
container.addComponent(serviceLocator.lookup(RemoteRepositoryManager.class)
, RemoteRepositoryManager.class
, "default");
And now we can finally have a maven-instance.
Description:
I am trying to test a static method from a class. I am using powerMock (1.6.2) + mockito (1.10.19) for mocking along with Junit4 (4.12) & java8.
Issue:
Getting the error: "Failed to transform class with name com.gs.ops.domain.StaticClass Reason: java.io.IOException: invalid constant type: 18"
Solutions Tried:
Googled threads for issue on with powermock - mockito & java-8
Excluded java assist from powermock and added java assist 3.19.0-GA
Tried different versions of powermock (1.5.4, 1.6.2...)
Below is the exception stack trace:
java.lang.IllegalStateException: Failed to transform class with name com.StaticClass. Reason: java.io.IOException: invalid constant type: 18
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:266)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:180)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:68)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:340)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:145)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:40)
at org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.createTestDelegators(AbstractTestSuiteChunkerImpl.java:244)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.<init>(JUnit4TestSuiteChunkerImpl.java:61)
at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.<init>(AbstractCommonPowerMockRunner.java:32)
at org.powermock.modules.junit4.PowerMockRunner.<init>(PowerMockRunner.java:34)
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:408)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
Caused by: java.lang.RuntimeException: java.io.IOException: invalid constant type: 18
at javassist.CtClassType.getClassFile2(CtClassType.java:203)
at javassist.compiler.MemberResolver.lookupMethod(MemberResolver.java:110)
at javassist.compiler.MemberResolver.lookupMethod(MemberResolver.java:96)
at javassist.compiler.TypeChecker.atMethodCallCore(TypeChecker.java:704)
at javassist.expr.NewExpr$ProceedForNew.setReturnType(NewExpr.java:243)
at javassist.compiler.JvstTypeChecker.atCallExpr(JvstTypeChecker.java:146)
at javassist.compiler.ast.CallExpr.accept(CallExpr.java:45)
at javassist.compiler.TypeChecker.atVariableAssign(TypeChecker.java:248)
at javassist.compiler.TypeChecker.atAssignExpr(TypeChecker.java:217)
at javassist.compiler.ast.AssignExpr.accept(AssignExpr.java:38)
at javassist.compiler.CodeGen.doTypeCheck(CodeGen.java:241)
at javassist.compiler.CodeGen.atStmnt(CodeGen.java:329)
at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49)
at javassist.compiler.CodeGen.atStmnt(CodeGen.java:350)
at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49)
at javassist.compiler.CodeGen.atIfStmnt(CodeGen.java:404)
at javassist.compiler.CodeGen.atStmnt(CodeGen.java:354)
at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49)
at javassist.compiler.Javac.compileStmnt(Javac.java:568)
at javassist.expr.NewExpr.replace(NewExpr.java:206)
at org.powermock.core.transformers.impl.MainMockTransformer$PowerMockExpressionEditor.edit(MainMockTransformer.java:418)
at javassist.expr.ExprEditor.loopBody(ExprEditor.java:211)
at javassist.expr.ExprEditor.doit(ExprEditor.java:90)
at javassist.CtClassType.instrument(CtClassType.java:1374)
at org.powermock.core.transformers.impl.MainMockTransformer.transform(MainMockTransformer.java:74)
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:251)
... 24 more
Caused by: java.io.IOException: invalid constant type: 18
at javassist.bytecode.ConstPool.readOne(ConstPool.java:1090)
at javassist.bytecode.ConstPool.read(ConstPool.java:1033)
at javassist.bytecode.ConstPool.<init>(ConstPool.java:149)
at javassist.bytecode.ClassFile.read(ClassFile.java:737)
at javassist.bytecode.ClassFile.<init>(ClassFile.java:108)
at javassist.CtClassType.getClassFile2(CtClassType.java:190)
... 49 more
Pom file:
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.6.2</version>
<exclusions>
<exclusion>
<groupId>org.junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>org.powermock</groupId>
<artifactId>powermock-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.powermock</groupId>
<artifactId>powermock-reflect</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.19.0-GA</version>
</dependency>
Powermock 1.6.3 uses javassist 3.15.2-GA which does not support certain types. Using 3.18.2-GA javassist worked for me. You may want to override dependency in your project.
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.18.2-GA</version>
</dependency>
You may face another problem for which the solution lies here Mockito + PowerMock LinkageError while mocking system class
Hope this helps.
So there seems to be issue with javassist (bytecode toolkit) prior to 3.18.2, as there's a resolved JIRA ticket-223.
1 - To find javassist version in your pom.xml, can use mvn dependency task
$ mvn dependency:tree | grep javassist
[INFO] | \- org.javassist:javassist:jar:3.14.0-GA:compile
which is used by the powermock-module-junit4-rule ,
[INFO] +- org.powermock:powermock-module-junit4-rule:jar:1.4.9:test
[INFO] | +- org.powermock:powermock-classloading-base:jar:1.4.9:test
[INFO] | \- org.powermock:powermock-core:jar:1.4.9:compile
[INFO] | \- org.javassist:javassist:jar:3.14.0-GA:compile
2 - So, updating the javassist version by explicitly to any versions >= 3.18.2 should work.
As, in my case, I am using use 3.20.0-GA
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.20.0-GA</version>
</dependency>
Working eg. with scalatest
#PowerMockIgnore(Array("javax.management.*"))
#RunWith(classOf[PowerMockRunner])
#PrepareForTest(Array(classOf[Configurator]))
class LogServiceSpec {
#Test
def initialises_log4j2_on_each_instance_call() {
PowerMockito.mockStatic(classOf[Configurator])
val logService1 = new LogService
PowerMockito.verifyStatic(Mockito.times(1))
Configurator.initialize(Matchers.anyString(), Matchers.eq("log4j.config"))
}
}
This is caused because of the conflict of dependencies. Resolving the dependency conflicts is one way to resolve this issue and the other way is to reorder <dependency></dependency> elements in your pom.xml. Move the powermock dependency declarations to the top of the <dependencies></dependencies> section. This is a complete hack and the right way to resolve it would be to resolve the dependency conflicts.
To identify those conflict you may use the command "mvn dependency:tree". Here is the dependency tree for my application for which I came across this same problem. Notice that there are two dependencies of "javassist" in the tree.
[INFO] +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.1:compile
[INFO] | \- org.objenesis:objenesis:jar:2.1:compile
[INFO] +- org.powermock:powermock-module-junit4:jar:1.6.4:test
[INFO] | \- org.powermock:powermock-module-junit4-common:jar:1.6.4:test
[INFO] | +- org.powermock:powermock-core:jar:1.6.4:compile
[INFO] | <span style="background-color: #FFFF00">| \- org.javassist:javassist:jar:3.20.0-GA:compile</span>
[INFO] | \- org.powermock:powermock-reflect:jar:1.6.4:compile
[INFO] +- org.powermock:powermock-api-mockito:jar:1.6.4:compile
[INFO] | \- org.powermock:powermock-api-support:jar:1.6.4:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.14:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.14:compile
[INFO] | \- log4j:log4j:jar:1.2.17:compile
[INFO] | +- org.apache.struts:struts2-core:jar:2.3.16.3-atlassian-6:provided
[INFO] | | \- ognl:ognl:jar:3.0.6:provided
<span style="background-color: #FFFF00">
[INFO] | | \- javassist:javassist:jar:3.11.0.GA:provided</span>
[INFO] | +- com.atlassian:webwork-compat:jar:1.24:provided
[INFO] | +- org.freemarker:freemarker:jar:2.3.16-atlassian-34:provided
[INFO] | | \- logkit:logkit:jar:1.2:provided
[INFO] | +- opensymphony:sitemesh:jar:2.5-atlassian-6:provided
[INFO] | +- commons-fileupload:commons-fileupload:jar:1.3.1:provided
[INFO] | +- org.tuckey:urlrewritefilter:jar:4.0.3:provided
[INFO] | +- velocity-tools:velocity-tools:jar:1.2:provided
[INFO] | +- commons-dbutils:commons-dbutils:jar:1.3:provided
[INFO] | +- org.hamcrest:hamcrest-all:jar:1.3:provided
[INFO] | +- com.atlassian.bamboo:atlassian-user-crowd-provider:jar:5.10.0:provided
[INFO] | | +- com.atlassian.crowd:crowd-integration-client-rest:jar:2.7.2:provided
[INFO] | | | \- com.atlassian.crowd:crowd-integration-client-common:jar:2.7.2:provided
[INFO] | | | \- com.atlassian.security:atlassian-cookie-tools:jar:3.2:provided
[INFO] | | +- com.atlassian.crowd:crowd-integration-api:jar:2.7.2:provided
[INFO] | | | \- com.atlassian.crowd:embedded-crowd-api:jar:2.7.2:provided
[INFO] | | +- com.atlassian.user:atlassian-user-api:jar:4.1.1:provided
[INFO] | | | \- com.opensymphony.propertyset:api:jar:1.6.0-m1:provided
[INFO] | | +- com.atlassian.user:atlassian-user-ldap:jar:4.1.1:provided
[INFO] | | +- org.acegisecurity:acegi-security:jar:1.0.4:provided
[INFO] | | | \- oro:oro:jar:2.0.8:provided
[INFO] | | \- com.atlassian.crowd:crowd-integration-seraph25:jar:2.7.2:provided
[INFO] | +- javax.xml.stream:stax-api:jar:1.0-2:provided
[INFO] | +- com.atlassian.core:atlassian-core:jar:5.0.2:provided
[INFO] | | \- com.atlassian.image:atlassian-image-consumer:jar:1.0.1:provided
[INFO] | +- org.apache.maven:maven-embedder:jar:3.0.4:provided
[INFO] | | +- org.apache.maven:maven-settings:jar:3.0.4:provided
[INFO] | | +- org.apache.maven:maven-plugin-api:jar:3.0.4:provided
[INFO] | | +- org.apache.maven:maven-model-builder:jar:3.0.4:provided
[INFO] | | +- org.apache.maven:maven-compat:jar:3.0.4:provided
[INFO] | | +- org.codehaus.plexus:plexus-classworlds:jar:2.4:provided
[INFO] | | +- org.sonatype.sisu:sisu-inject-plexus:jar:2.3.0:provided
[INFO] | | | \- org.sonatype.sisu:sisu-inject-bean:jar:2.3.0:provided
[INFO] | | +- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:provided
[INFO] | | +- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:provided
[INFO] | | +- org.sonatype.plexus:plexus-cipher:jar:1.7:provided
[INFO] | | \- commons-cli:commons-cli:jar:1.2:provided
[INFO] | +- org.apache.maven:maven-model:jar:3.0.4:provided
[INFO] | +- com.octo.captcha:jcaptcha:jar:2.0-alpha-1:provided
[INFO] | +- com.octo.captcha:jcaptcha-api:jar:2.0-alpha-1:provided
[INFO] | +- com.jhlabs:filters:jar:2.0.235:provided
[INFO] | +- org.apache.struts:struts2-sitemesh-plugin:jar:2.1.8.1:provided
[INFO] | +- org.slf4j:jul-to-slf4j:jar:1.7.10:provided
[INFO] | +- com.atlassian.plugins:atlassian-plugins-schema:jar:4.0.5:provided
[INFO] | | \- com.atlassian.plugins:atlassian-plugins-osgi:jar:4.0.5:provided
[INFO] | | +- com.atlassian.plugins:atlassian-plugins-osgi-events:jar:4.0.5:provided
[INFO] | | +- biz.aQute.bnd:biz.aQute.bndlib:jar:2.4.1:provided
[INFO] | | +- org.apache.felix:org.apache.felix.framework:jar:4.2.1:provided
[INFO] | | \- org.twdata.pkgscanner:package-scanner:jar:0.9.5:provided
[INFO] | \- xerces:xercesImpl:jar:2.11.0:provided
[INFO] | \- xml-apis:xml-apis:jar:1.4.01:provided
[INFO] +- junit:junit:jar:4.12:test
[INFO] +- info.cukes:cucumber-java:jar:1.2.4:test
[INFO] | \- info.cukes:cucumber-core:jar:1.2.4:test
[INFO] | +- info.cukes:cucumber-html:jar:0.2.3:test
[INFO] | +- info.cukes:cucumber-jvm-deps:jar:1.0.5:test
[INFO] | \- info.cukes:gherkin:jar:2.12.2:test
[INFO] +- info.cukes:cucumber-junit:jar:1.2.4:test
[INFO] +- com.atlassian.plugins:atlassian-plugins-osgi-testrunner:jar:1.2.3:test
[INFO] | +- org.apache.wink:wink-client:jar:1.1.3-incubating:test
[INFO] | | +- org.apache.wink:wink-common:jar:1.1.3-incubating:test
[INFO] | | | \- org.apache.geronimo.specs:geronimo-annotation_1.1_spec:jar:1.0:test
[INFO] | | +- javax.xml.bind:jaxb-api:jar:2.2:test
[INFO] | | \- com.sun.xml.bind:jaxb-impl:jar:2.2.1.1:test
[INFO] | +- commons-io:commons-io:jar:1.4:provided
[INFO] | \- com.atlassian.upm:upm-api:jar:2.15:test
[INFO] +- javax.ws.rs:jsr311-api:jar:1.1.1:provided
[INFO] +- com.google.code.gson:gson:jar:2.2.2-atlassian-1:compile
[INFO] +- com.mashape.unirest:unirest-java:jar:1.3.3:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.3.1:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.3:compile
[INFO] | \- commons-codec:commons-codec:jar:1.6:compile
[INFO] +- org.apache.httpcomponents:httpasyncclient:jar:4.0:compile
[INFO] | \- org.apache.httpcomponents:httpcore-nio:jar:4.3:compile
[INFO] +- org.apache.httpcomponents:httpmime:jar:4.3.1:compile
[INFO] +- org.json:json:jar:20090211:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.3.3:compile
[INFO] \- com.fasterxml.jackson.core:jackson-databind:jar:2.3.3:compile
[INFO] \- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.0:compile
I hope this helps.
In my case, a "java.io.IOException: invalid constant type: 18" was caused by multiple versions of javassist libraries in my classpath - both 3.12.1.GA and 3.18.2-GA. The problem disappeared when i removed the older one.
Not really an answer! I got a similar error when running a Maven build with JDK8 and generating Java6 byte code. My pom looks like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compilerVersion>1.6</compilerVersion>
<source>1.6</source>
<target>1.6</target>
<maxmem>2000m</maxmem>
<fork>true</fork>
</configuration>
</plugin>
When I reverted to JDK6 I no longer got the error.
In my case JRE System Library --> Execution Environment was set up on JavaSE-1.7, but the only installed JRE was JRE1.8. So it was pointing to java 8 in place of java 7. Once I moved to java 7 it start working fine for me.
This issue is related to a compatibility issue with Java 8. could you execute your tests on java 7 ?
Run "mvn dependency:tree | grep javassist" on terminal. If javaassist dependency is being shown in non test and test libraries. Now you only have to exclude it during runtime for tests. So the way to do this is adding a build plugin on the lines of:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<configuration>
<classpathDependencyExcludes>
<classpathDependencyExcludes>javassist:javassist</classpathDependencyExcludes>
</classpathDependencyExcludes>
</configuration>
</plugin>
</plugins>
Please note the classpathDependencyExcludes might change for you based on your javassist version.
Description:
I am trying to test a static method from a class. I am using powerMock (1.6.2) + mockito (1.10.19) for mocking along with Junit4 (4.12) & java8.
Issue:
Getting the error: "Failed to transform class with name com.gs.ops.domain.StaticClass Reason: java.io.IOException: invalid constant type: 18"
Solutions Tried:
Googled threads for issue on with powermock - mockito & java-8
Excluded java assist from powermock and added java assist 3.19.0-GA
Tried different versions of powermock (1.5.4, 1.6.2...)
Below is the exception stack trace:
java.lang.IllegalStateException: Failed to transform class with name com.StaticClass. Reason: java.io.IOException: invalid constant type: 18
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:266)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:180)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:68)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:340)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:145)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:40)
at org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.createTestDelegators(AbstractTestSuiteChunkerImpl.java:244)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.<init>(JUnit4TestSuiteChunkerImpl.java:61)
at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.<init>(AbstractCommonPowerMockRunner.java:32)
at org.powermock.modules.junit4.PowerMockRunner.<init>(PowerMockRunner.java:34)
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:408)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
Caused by: java.lang.RuntimeException: java.io.IOException: invalid constant type: 18
at javassist.CtClassType.getClassFile2(CtClassType.java:203)
at javassist.compiler.MemberResolver.lookupMethod(MemberResolver.java:110)
at javassist.compiler.MemberResolver.lookupMethod(MemberResolver.java:96)
at javassist.compiler.TypeChecker.atMethodCallCore(TypeChecker.java:704)
at javassist.expr.NewExpr$ProceedForNew.setReturnType(NewExpr.java:243)
at javassist.compiler.JvstTypeChecker.atCallExpr(JvstTypeChecker.java:146)
at javassist.compiler.ast.CallExpr.accept(CallExpr.java:45)
at javassist.compiler.TypeChecker.atVariableAssign(TypeChecker.java:248)
at javassist.compiler.TypeChecker.atAssignExpr(TypeChecker.java:217)
at javassist.compiler.ast.AssignExpr.accept(AssignExpr.java:38)
at javassist.compiler.CodeGen.doTypeCheck(CodeGen.java:241)
at javassist.compiler.CodeGen.atStmnt(CodeGen.java:329)
at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49)
at javassist.compiler.CodeGen.atStmnt(CodeGen.java:350)
at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49)
at javassist.compiler.CodeGen.atIfStmnt(CodeGen.java:404)
at javassist.compiler.CodeGen.atStmnt(CodeGen.java:354)
at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49)
at javassist.compiler.Javac.compileStmnt(Javac.java:568)
at javassist.expr.NewExpr.replace(NewExpr.java:206)
at org.powermock.core.transformers.impl.MainMockTransformer$PowerMockExpressionEditor.edit(MainMockTransformer.java:418)
at javassist.expr.ExprEditor.loopBody(ExprEditor.java:211)
at javassist.expr.ExprEditor.doit(ExprEditor.java:90)
at javassist.CtClassType.instrument(CtClassType.java:1374)
at org.powermock.core.transformers.impl.MainMockTransformer.transform(MainMockTransformer.java:74)
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:251)
... 24 more
Caused by: java.io.IOException: invalid constant type: 18
at javassist.bytecode.ConstPool.readOne(ConstPool.java:1090)
at javassist.bytecode.ConstPool.read(ConstPool.java:1033)
at javassist.bytecode.ConstPool.<init>(ConstPool.java:149)
at javassist.bytecode.ClassFile.read(ClassFile.java:737)
at javassist.bytecode.ClassFile.<init>(ClassFile.java:108)
at javassist.CtClassType.getClassFile2(CtClassType.java:190)
... 49 more
Pom file:
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.6.2</version>
<exclusions>
<exclusion>
<groupId>org.junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>org.powermock</groupId>
<artifactId>powermock-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.powermock</groupId>
<artifactId>powermock-reflect</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.19.0-GA</version>
</dependency>
Powermock 1.6.3 uses javassist 3.15.2-GA which does not support certain types. Using 3.18.2-GA javassist worked for me. You may want to override dependency in your project.
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.18.2-GA</version>
</dependency>
You may face another problem for which the solution lies here Mockito + PowerMock LinkageError while mocking system class
Hope this helps.
So there seems to be issue with javassist (bytecode toolkit) prior to 3.18.2, as there's a resolved JIRA ticket-223.
1 - To find javassist version in your pom.xml, can use mvn dependency task
$ mvn dependency:tree | grep javassist
[INFO] | \- org.javassist:javassist:jar:3.14.0-GA:compile
which is used by the powermock-module-junit4-rule ,
[INFO] +- org.powermock:powermock-module-junit4-rule:jar:1.4.9:test
[INFO] | +- org.powermock:powermock-classloading-base:jar:1.4.9:test
[INFO] | \- org.powermock:powermock-core:jar:1.4.9:compile
[INFO] | \- org.javassist:javassist:jar:3.14.0-GA:compile
2 - So, updating the javassist version by explicitly to any versions >= 3.18.2 should work.
As, in my case, I am using use 3.20.0-GA
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.20.0-GA</version>
</dependency>
Working eg. with scalatest
#PowerMockIgnore(Array("javax.management.*"))
#RunWith(classOf[PowerMockRunner])
#PrepareForTest(Array(classOf[Configurator]))
class LogServiceSpec {
#Test
def initialises_log4j2_on_each_instance_call() {
PowerMockito.mockStatic(classOf[Configurator])
val logService1 = new LogService
PowerMockito.verifyStatic(Mockito.times(1))
Configurator.initialize(Matchers.anyString(), Matchers.eq("log4j.config"))
}
}
This is caused because of the conflict of dependencies. Resolving the dependency conflicts is one way to resolve this issue and the other way is to reorder <dependency></dependency> elements in your pom.xml. Move the powermock dependency declarations to the top of the <dependencies></dependencies> section. This is a complete hack and the right way to resolve it would be to resolve the dependency conflicts.
To identify those conflict you may use the command "mvn dependency:tree". Here is the dependency tree for my application for which I came across this same problem. Notice that there are two dependencies of "javassist" in the tree.
[INFO] +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.1:compile
[INFO] | \- org.objenesis:objenesis:jar:2.1:compile
[INFO] +- org.powermock:powermock-module-junit4:jar:1.6.4:test
[INFO] | \- org.powermock:powermock-module-junit4-common:jar:1.6.4:test
[INFO] | +- org.powermock:powermock-core:jar:1.6.4:compile
[INFO] | <span style="background-color: #FFFF00">| \- org.javassist:javassist:jar:3.20.0-GA:compile</span>
[INFO] | \- org.powermock:powermock-reflect:jar:1.6.4:compile
[INFO] +- org.powermock:powermock-api-mockito:jar:1.6.4:compile
[INFO] | \- org.powermock:powermock-api-support:jar:1.6.4:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.14:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.14:compile
[INFO] | \- log4j:log4j:jar:1.2.17:compile
[INFO] | +- org.apache.struts:struts2-core:jar:2.3.16.3-atlassian-6:provided
[INFO] | | \- ognl:ognl:jar:3.0.6:provided
<span style="background-color: #FFFF00">
[INFO] | | \- javassist:javassist:jar:3.11.0.GA:provided</span>
[INFO] | +- com.atlassian:webwork-compat:jar:1.24:provided
[INFO] | +- org.freemarker:freemarker:jar:2.3.16-atlassian-34:provided
[INFO] | | \- logkit:logkit:jar:1.2:provided
[INFO] | +- opensymphony:sitemesh:jar:2.5-atlassian-6:provided
[INFO] | +- commons-fileupload:commons-fileupload:jar:1.3.1:provided
[INFO] | +- org.tuckey:urlrewritefilter:jar:4.0.3:provided
[INFO] | +- velocity-tools:velocity-tools:jar:1.2:provided
[INFO] | +- commons-dbutils:commons-dbutils:jar:1.3:provided
[INFO] | +- org.hamcrest:hamcrest-all:jar:1.3:provided
[INFO] | +- com.atlassian.bamboo:atlassian-user-crowd-provider:jar:5.10.0:provided
[INFO] | | +- com.atlassian.crowd:crowd-integration-client-rest:jar:2.7.2:provided
[INFO] | | | \- com.atlassian.crowd:crowd-integration-client-common:jar:2.7.2:provided
[INFO] | | | \- com.atlassian.security:atlassian-cookie-tools:jar:3.2:provided
[INFO] | | +- com.atlassian.crowd:crowd-integration-api:jar:2.7.2:provided
[INFO] | | | \- com.atlassian.crowd:embedded-crowd-api:jar:2.7.2:provided
[INFO] | | +- com.atlassian.user:atlassian-user-api:jar:4.1.1:provided
[INFO] | | | \- com.opensymphony.propertyset:api:jar:1.6.0-m1:provided
[INFO] | | +- com.atlassian.user:atlassian-user-ldap:jar:4.1.1:provided
[INFO] | | +- org.acegisecurity:acegi-security:jar:1.0.4:provided
[INFO] | | | \- oro:oro:jar:2.0.8:provided
[INFO] | | \- com.atlassian.crowd:crowd-integration-seraph25:jar:2.7.2:provided
[INFO] | +- javax.xml.stream:stax-api:jar:1.0-2:provided
[INFO] | +- com.atlassian.core:atlassian-core:jar:5.0.2:provided
[INFO] | | \- com.atlassian.image:atlassian-image-consumer:jar:1.0.1:provided
[INFO] | +- org.apache.maven:maven-embedder:jar:3.0.4:provided
[INFO] | | +- org.apache.maven:maven-settings:jar:3.0.4:provided
[INFO] | | +- org.apache.maven:maven-plugin-api:jar:3.0.4:provided
[INFO] | | +- org.apache.maven:maven-model-builder:jar:3.0.4:provided
[INFO] | | +- org.apache.maven:maven-compat:jar:3.0.4:provided
[INFO] | | +- org.codehaus.plexus:plexus-classworlds:jar:2.4:provided
[INFO] | | +- org.sonatype.sisu:sisu-inject-plexus:jar:2.3.0:provided
[INFO] | | | \- org.sonatype.sisu:sisu-inject-bean:jar:2.3.0:provided
[INFO] | | +- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:provided
[INFO] | | +- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:provided
[INFO] | | +- org.sonatype.plexus:plexus-cipher:jar:1.7:provided
[INFO] | | \- commons-cli:commons-cli:jar:1.2:provided
[INFO] | +- org.apache.maven:maven-model:jar:3.0.4:provided
[INFO] | +- com.octo.captcha:jcaptcha:jar:2.0-alpha-1:provided
[INFO] | +- com.octo.captcha:jcaptcha-api:jar:2.0-alpha-1:provided
[INFO] | +- com.jhlabs:filters:jar:2.0.235:provided
[INFO] | +- org.apache.struts:struts2-sitemesh-plugin:jar:2.1.8.1:provided
[INFO] | +- org.slf4j:jul-to-slf4j:jar:1.7.10:provided
[INFO] | +- com.atlassian.plugins:atlassian-plugins-schema:jar:4.0.5:provided
[INFO] | | \- com.atlassian.plugins:atlassian-plugins-osgi:jar:4.0.5:provided
[INFO] | | +- com.atlassian.plugins:atlassian-plugins-osgi-events:jar:4.0.5:provided
[INFO] | | +- biz.aQute.bnd:biz.aQute.bndlib:jar:2.4.1:provided
[INFO] | | +- org.apache.felix:org.apache.felix.framework:jar:4.2.1:provided
[INFO] | | \- org.twdata.pkgscanner:package-scanner:jar:0.9.5:provided
[INFO] | \- xerces:xercesImpl:jar:2.11.0:provided
[INFO] | \- xml-apis:xml-apis:jar:1.4.01:provided
[INFO] +- junit:junit:jar:4.12:test
[INFO] +- info.cukes:cucumber-java:jar:1.2.4:test
[INFO] | \- info.cukes:cucumber-core:jar:1.2.4:test
[INFO] | +- info.cukes:cucumber-html:jar:0.2.3:test
[INFO] | +- info.cukes:cucumber-jvm-deps:jar:1.0.5:test
[INFO] | \- info.cukes:gherkin:jar:2.12.2:test
[INFO] +- info.cukes:cucumber-junit:jar:1.2.4:test
[INFO] +- com.atlassian.plugins:atlassian-plugins-osgi-testrunner:jar:1.2.3:test
[INFO] | +- org.apache.wink:wink-client:jar:1.1.3-incubating:test
[INFO] | | +- org.apache.wink:wink-common:jar:1.1.3-incubating:test
[INFO] | | | \- org.apache.geronimo.specs:geronimo-annotation_1.1_spec:jar:1.0:test
[INFO] | | +- javax.xml.bind:jaxb-api:jar:2.2:test
[INFO] | | \- com.sun.xml.bind:jaxb-impl:jar:2.2.1.1:test
[INFO] | +- commons-io:commons-io:jar:1.4:provided
[INFO] | \- com.atlassian.upm:upm-api:jar:2.15:test
[INFO] +- javax.ws.rs:jsr311-api:jar:1.1.1:provided
[INFO] +- com.google.code.gson:gson:jar:2.2.2-atlassian-1:compile
[INFO] +- com.mashape.unirest:unirest-java:jar:1.3.3:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.3.1:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.3:compile
[INFO] | \- commons-codec:commons-codec:jar:1.6:compile
[INFO] +- org.apache.httpcomponents:httpasyncclient:jar:4.0:compile
[INFO] | \- org.apache.httpcomponents:httpcore-nio:jar:4.3:compile
[INFO] +- org.apache.httpcomponents:httpmime:jar:4.3.1:compile
[INFO] +- org.json:json:jar:20090211:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.3.3:compile
[INFO] \- com.fasterxml.jackson.core:jackson-databind:jar:2.3.3:compile
[INFO] \- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.0:compile
I hope this helps.
In my case, a "java.io.IOException: invalid constant type: 18" was caused by multiple versions of javassist libraries in my classpath - both 3.12.1.GA and 3.18.2-GA. The problem disappeared when i removed the older one.
Not really an answer! I got a similar error when running a Maven build with JDK8 and generating Java6 byte code. My pom looks like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compilerVersion>1.6</compilerVersion>
<source>1.6</source>
<target>1.6</target>
<maxmem>2000m</maxmem>
<fork>true</fork>
</configuration>
</plugin>
When I reverted to JDK6 I no longer got the error.
In my case JRE System Library --> Execution Environment was set up on JavaSE-1.7, but the only installed JRE was JRE1.8. So it was pointing to java 8 in place of java 7. Once I moved to java 7 it start working fine for me.
This issue is related to a compatibility issue with Java 8. could you execute your tests on java 7 ?
Run "mvn dependency:tree | grep javassist" on terminal. If javaassist dependency is being shown in non test and test libraries. Now you only have to exclude it during runtime for tests. So the way to do this is adding a build plugin on the lines of:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<configuration>
<classpathDependencyExcludes>
<classpathDependencyExcludes>javassist:javassist</classpathDependencyExcludes>
</classpathDependencyExcludes>
</configuration>
</plugin>
</plugins>
Please note the classpathDependencyExcludes might change for you based on your javassist version.