NoClassDefFoundError: cucumber/api/DataTable when trying to upgrade to Cucumber 4 - java

I am trying to upgrade my tests to Cucumber 4. I am using testNG and Maven.
I have updated my dependency versions for the following:
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${version.cucumber}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>${version.cucumber}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-guice</artifactId>
<version>${version.cucumber}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>${version.cucumber}</version>
</dependency>
But I keep getting the error 'java.lang.NoClassDefFoundError: cucumber/api/DataTable' when trying to run a test.
This is my runner:
import cucumber.api.CucumberOptions;
import cucumber.api.*;
import cucumber.api.testng.AbstractTestNGCucumberTests;
import org.testng.annotations.DataProvider;
#CucumberOptions(plugin = {"XXXX"},
features = "src/test/resources/features",
glue={"XXXXX"},
tags = {"#XXXXX"})
public class Cucumber4Runner extends AbstractTestNGCucumberTests {
#Override
#DataProvider(parallel = true)
public Object[][] scenarios() {
return super.scenarios();
}
}
I have tried to ensure all versions of dependencies match up but struggling!

Most probably you have not aligned the import statements (other changes might be needed).
From the CHANGELOG.md
3.0.0
...
[Core] Replace DataTable with io.cucumber.datatable.DataTable (#1248 M.P. Korstanje, Björn Rasmusson, Marit van Dijk)
Based on your exception message your code is looking for cucumber.api.DataTable
edit There might be also a transient dependency from one of you other dependencies to an older cucumber version.
Assume the following dependencies only in your pom.xml
<properties>
<version.cucumber>4.2.0</version.cucumber>
</properties>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${version.cucumber}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>${version.cucumber}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-guice</artifactId>
<version>${version.cucumber}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>${version.cucumber}</version>
<type>pom</type>
</dependency>
</dependencies>
listing the project dependencies
$ mvn dependency:tree
would produce the following tree
[INFO] +- io.cucumber:cucumber-java:jar:4.2.0:test
[INFO] | \- io.cucumber:cucumber-core:jar:4.2.0:compile
[INFO] | +- io.cucumber:cucumber-html:jar:0.2.7:compile
[INFO] | +- io.cucumber:gherkin:jar:5.1.0:compile
[INFO] | +- io.cucumber:tag-expressions:jar:1.1.1:compile
[INFO] | +- io.cucumber:cucumber-expressions:jar:6.2.0:compile
[INFO] | \- io.cucumber:datatable:jar:1.1.7:compile
[INFO] | \- io.cucumber:datatable-dependencies:jar:1.1.7:compile
[INFO] +- io.cucumber:cucumber-testng:jar:4.2.0:compile
[INFO] | \- org.testng:testng:jar:6.14.3:compile
[INFO] | +- com.beust:jcommander:jar:1.72:compile
[INFO] | \- org.apache-extras.beanshell:bsh:jar:2.0b6:compile
[INFO] +- io.cucumber:cucumber-guice:jar:4.2.0:test
[INFO] \- io.cucumber:cucumber-jvm:pom:4.2.0:compile
Have a look if there is somewhere a dependency to
info.cuke:* any version
io.cucumber:cucumber-core version before 3

Related

NoSuchMethodError: com.mongodb.MongoClientSettings$Builder.uuidRepresentation

I've tried to get up spring-boot version from 2.1.1.RELEASE to 2.3.8.RELEASE and got error "Caused by: java.lang.NoSuchMethodError: com.mongodb.MongoClientSettings$Builder.uuidRepresentation(Lorg/bson/UuidRepresentation;)Lcom/mongodb/MongoClientSettings$Builder"
My application consists of several modules and one of them has a dependency on a customed 'import-export' service. This service uses Mongo db while my application uses postgree db. When I run mvn dependency:tree, I see 'mongo' is mentioned only here:
[INFO] +- ....export-import-lib-node:jar:0.2.3-springboot-2.3.5:compile
[INFO] | +- org.springframework.data:spring-data-mongodb:jar:3.0.6.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-commons:jar:2.3.6.RELEASE:compile
[INFO] | | \- org.mongodb:mongodb-driver-core:jar:4.0.5:compile
[INFO] | | \- org.mongodb:bson:jar:4.0.5:compile
[INFO] | \- org.mongodb:mongo-java-driver:jar:3.8.2:compile
Before version changes there were:
[INFO] +- .....export-import-lib-node:jar:0.2.4:compile
[INFO] | \- org.springframework.data:spring-data-mongodb:jar:2.1.3.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:2.1.3.RELEASE:compile
[INFO] | \- org.mongodb:mongo-java-driver:jar:3.8.2:compile
I've tried to add dependencies
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson</artifactId>
<version>4.4.2</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-core</artifactId>
<version>4.4.2</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.4.2</version>
</dependency>
but got the same error on running the application on Tomcat server.
Could you advice me what should I do to fix this error?
Thank you.
Update:
Added
#Bean
public MongoClient mongoClient() {
return MongoClients.create(MongoClientSettings.builder()
.uuidRepresentation(UuidRepresentation.JAVA_LEGACY)
.build());
}
but still have the same error " Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.client.MongoClient]: Factory method 'mongoClient' threw exception; nested exception is java.lang.NoSuchMethodError: com.mongodb.MongoClientSettings$Builder.uuidRepresentation(Lorg/bson/UuidRepresentation;)Lcom/mongodb/MongoClientSettings$Builder;"
Try following dependencies
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.12.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mongodb/mongodb-driver -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
<version>3.6.3</version>
<exclusions>
<exclusion>
<groupId>org.mongodb</groupId> <!-- Exclude Project-E from Project-B -->
<artifactId>bson</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-core</artifactId>
<version>3.11.0</version>
</dependency>

maven-dependency-plugin not showing test-scoped dependencies

I'm attempting to display the full tree of dependencies for a project I'm working on using the maven-dependency-plugin version 3.1.2 from the command line, but the mvn dependency:tree goal (nor any of the other goals from the maven-dependency-plugin) is not showing the test dependencies. The documentation of the plugin (https://maven.apache.org/plugins/maven-dependency-plugin/tree-mojo.html) states that all scopes are included by default, so using the -Dscope=test shouldn't be necessary (but when adding this parameter, the output doesn't change).
I've run this with a clean .m2 repository, using no settings.xml file (to ensure that all artifacts are coming directly from repo.maven.apache.org).
I'm running using maven 3.6.2 on a linux environment (CentOS 7) and using Oracle Java 1.8.0_144
Here's my POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sw-eval</groupId>
<artifactId>cayenne-eval</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-server</artifactId>
<version>4.2.M2</version>
</dependency>
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-di</artifactId>
<version>4.2.M2</version>
</dependency>
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-dbsync</artifactId>
<version>4.2.M2</version>
</dependency>
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-client</artifactId>
<version>4.2.M2</version>
</dependency>
</dependencies>
</project>
Here's the output I receive from running the command mvn dependency:tree:
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.sw-eval:cayenne-eval >----------------------
[INFO] Building cayenne-eval 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # cayenne-eval ---
[INFO] com.sw-eval:cayenne-eval:jar:1.0.0-SNAPSHOT
[INFO] +- org.apache.cayenne:cayenne-server:jar:4.2.M2:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.apache.cayenne:cayenne-di:jar:4.2.M2:compile
[INFO] +- org.apache.cayenne:cayenne-dbsync:jar:4.2.M2:compile
[INFO] | +- org.apache.cayenne:cayenne-project:jar:4.2.M2:compile
[INFO] | \- net.java.dev.inflector:inflector:jar:0.7.0:compile
[INFO] \- org.apache.cayenne:cayenne-client:jar:4.2.M2:compile
[INFO] +- com.caucho:hessian:jar:4.0.63:compile
[INFO] \- org.apache.cayenne:cayenne-rop-server:jar:4.2.M2:compile
[INFO] +- org.apache.cayenne:cayenne-web:jar:4.2.M2:compile
[INFO] \- org.slf4j:slf4j-simple:jar:1.7.25:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.951 s
[INFO] Finished at: 2020-11-25T08:53:17-07:00
[INFO] ------------------------------------------------------------------------
When referring to the cayenne-server pom, however, there are many dependencies marked as test which are not shown in the output (specifically, the following are direct dependencies of cayenne-server, see https://search.maven.org/artifact/org.apache.cayenne/cayenne-server/4.2.M2/jar):
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cayenne.build-tools</groupId>
<artifactId>cayenne-test-utilities</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.mockrunner</groupId>
<artifactId>mockrunner-jdbc</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<!-- this one have old Xerces dependency that clashes with JDK's one -->
<groupId>nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<scope>test</scope>
</dependency>
So, is there something that I'm missing that needs to be enabled to show these test-scoped dependencies, and / or is this a weird artifact unique to the cayenne-server dependency?
Thanks in advance!
Dependencies of scope test are not transitive.
The test dependencies of your dependencies are not part of your dependency tree. They are ignored by Maven.

Maven conflicting dependency kafka-stream-test-utils and kafka-streams

Getting this Esception java.lang.NoClassDefFoundError: org/apache/kafka/streams/internals/QuietStreamsConfig.
Possibly because of dependency conflict. Related jars in pom.xml
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams-test-utils</artifactId>
<version>5.5.0-ccs</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
<version>1.0.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId> org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>1.0.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
When I run this command
**
mvn dependency:tree -Dverbose -Dincludes=org.apache.kafka
**
com.walmart.sims.ica:fault-handler:jar:0.0.1-SNAPSHOT
[INFO] +- org.apache.kafka:kafka-streams-test-utils:jar:5.5.0-ccs:test
[INFO] | +- (org.apache.kafka:kafka-streams:jar:5.5.0-ccs:test - omitted for conflict with 1.0.1)
[INFO] | \- (org.apache.kafka:kafka-clients:jar:5.5.0-ccs:test - omitted for conflict with 1.0.1)
[INFO] +- org.apache.kafka:kafka-streams:jar:1.0.1:compile
[INFO] | \- org.apache.kafka:connect-json:jar:1.0.1:compile
[INFO] | \- org.apache.kafka:connect-api:jar:1.0.1:compile
[INFO] \- org.apache.kafka:kafka-clients:jar:1.0.1:compile
So my test dependencies are getting omitted due to conflict because of which I get ClassNotFoundException when I run my test.
How should I resolve the conflict such that dependencies from test-utils are available at test scope otherwise at compile scope kafka-streams and kafka-clients dependencies are used?
What's the point of using one version in real prod code and much newer version of dependency for test code?
I would recommend to either downgrade kafka-streams-test-utils to a version that uses kafka-streams:1.0.1 or upgrade kafka-streams version used by your app to 5.5.0-ccs. I do not think test-utils version 5.5.0-css will work correctly with stream version 1.0.1 anyway.
But if you want to try you can exclude kafka-streams and kafka-client dependencies from test-utils

Spark job Issue [java.lang.VerifyError: class com.fasterxml.jackson.module.scala.ser.ScalaIteratorSerializer overrides final method withResolved]

I am trying to run my spark code, but i am running into issue:
Exception in thread "main" java.lang.VerifyError: class com.fasterxml.jackson.module.scala.ser.ScalaIteratorSerializer overrides final method withResolved.(Lcom/fasterxml/jackson/databind/BeanProperty;Lcom/fasterxml/jackson/databind/jsontype/TypeSerializer;Lcom/fasterxml/jackson/databind/JsonSerializer;)Lcom/fasterxml/jackson/databind/ser/std/AsArraySerializerBase;
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.fasterxml.jackson.module.scala.ser.IteratorSerializerModule$class.$init$(IteratorSerializerModule.scala:70)
at com.fasterxml.jackson.module.scala.DefaultScalaModule.<init>(DefaultScalaModule.scala:18)
at com.fasterxml.jackson.module.scala.DefaultScalaModule$.<init>(DefaultScalaModule.scala:33)
at com.fasterxml.jackson.module.scala.DefaultScalaModule$.<clinit>(DefaultScalaModule.scala)
at org.apache.spark.rdd.RDDOperationScope$.<init>(RDDOperationScope.scala:82)
at org.apache.spark.rdd.RDDOperationScope$.<clinit>(RDDOperationScope.scala)
at org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:135)
at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:116)
at org.apache.spark.sql.execution.QueryExecution.toRdd$lzycompute(QueryExecution.scala:92)
at org.apache.spark.sql.execution.QueryExecution.toRdd(QueryExecution.scala:92)
at org.apache.spark.sql.Dataset.rdd$lzycompute(Dataset.scala:2586)
at org.apache.spark.sql.Dataset.rdd(Dataset.scala:2583)
at org.apache.spark.sql.Dataset.toJavaRDD(Dataset.scala:2596)
Here is my pom:
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.12</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>2.11.12</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.7.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-scala_2.11</artifactId>
<version>2.6.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-paranamer</artifactId>
<version>2.6.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.6.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.6.7</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.2.1</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.2.1</version>
</dependency>
Here the output of maven dependency tree related to fasterxml ( mvn dependency:tree | grep -i com.fasterxml.jackson ):
[INFO] | | | +- com.fasterxml.jackson:jackson-datatype-guava:jar:1.9.1:compile
[INFO] | | | \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.4.5:compile
[INFO] | | | \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.4.5:compile
[INFO] | | | \- com.fasterxml.jackson.datatype:jackson-datatype-joda:jar:2.5.1:compile
[INFO] | +- com.fasterxml:jackson-xml-databind:jar:0.6.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.6.7.1:compile
[INFO] +- com.fasterxml.jackson.module:jackson-module-scala_2.11:jar:2.6.7:compile
[INFO] +- com.fasterxml.jackson.module:jackson-module-paranamer:jar:2.6.7:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.7:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.6.7:compile
I have tried some more versions of fasterxml, but they are also printing same exception. Downgrading as well as upgrading the version is not working.
What should be my next steps?
Update::::
I have updated the version to 2.9.2, but even with that i am getting the same error.
here is the maven dependency tree after that
mvn dependency:tree | grep "com.fasterxml.jackson"
[INFO] | | | +- com.fasterxml.jackson:jackson-datatype-guava:jar:1.9.1:compile
[INFO] | | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.4.5:compile
[INFO] | | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.4.5:compile
[INFO] | | | \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.4.5:compile
[INFO] | | | \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.4.5:compile
[INFO] | | | \- com.fasterxml.jackson.datatype:jackson-datatype-joda:jar:2.5.1:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.9.2:compile
[INFO] +- com.fasterxml.jackson.module:jackson-module-scala_2.11:jar:2.9.2:compile
[INFO] +- com.fasterxml.jackson.module:jackson-module-paranamer:jar:2.9.2:compile

Spring class-loading issues while deploying EAR application on WebSphere 9 [duplicate]

I got several IllegalStateException,CannotCompileException and LinkageError at the time of application running on WebSphere 9.0 java 8 . These this is stack trace of error :
Caused by: java.lang.IllegalStateException: javassist.CannotCompileException: by java.lang.LinkageError: org.springframework.aop.framework.ProxyCreatorSupport
at org.springframework.aop.framework.JavassistApplicationContext.<clinit>(JavassistApplicationContext.java:61)
... 114 more
Caused by: javassist.CannotCompileException: by java.lang.LinkageError: org.springframework.aop.framework.ProxyCreatorSupport
at javassist.ClassPool.toClass(ClassPool.java:1120)
at javassist.ClassPool.toClass(ClassPool.java:1063)
at javassist.ClassPool.toClass(ClassPool.java:1021)
at javassist.CtClass.toClass(CtClass.java:1259)
at org.springframework.aop.framework.JavassistApplicationContext.<clinit>(JavassistApplicationContext.java:59)
... 114 more
Caused by: java.lang.LinkageError: org.springframework.aop.framework.ProxyCreatorSupport
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:346)
at java.lang.ClassLoader.defineClass(ClassLoader.java:283)
at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:508)
at javassist.ClassPool.toClass2(ClassPool.java:1133)
at javassist.ClassPool.toClass(ClassPool.java:1114)
... 118 more
and also i am getting java.lang.ExceptionInInitializerError :
com.ibm.ws.webcontainer.webapp.WebApp notifyServletContextCreated SRVE0283E:
Exception caught while initializing context: {0} java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.ensureError(J9VMInternals.java:141)
at java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:130)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:88)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
at java.lang.reflect.Constructor.newInstance(Constructor.java:437)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:104)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:258)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
And in pom.xml File, I have following dependency.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.16</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
</dependency>
<!-- Javassist -->
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.19.0-GA</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>[1.1.1,)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging-api</artifactId>
<version>[1.0.3,)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4jVersion}</version>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4jVersion}</version>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4jVersion}</version>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<!--<scope>provided</scope>-->
</dependency>
<!-- Global Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>ibmpkcs</artifactId>
<version>8.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<showDeprecation>${maven.compiler.showDeprecation}</showDeprecation>
<showWarnings>${maven.compiler.showWarnings}</showWarnings>
<encoding>UTF-8</encoding>
<debug>${maven.compiler.debug}</debug>
<optimize>${maven.compiler.optimize}</optimize>
</configuration>
</plugin>
</build>
<properties>
<spring.version>4.2.5.RELEASE</spring.version>
<spring-ws.version>2.4.0.RELEASE</spring-ws.version>
<spring-security.version>4.0.0.RELEASE</spring-security.version>
<slf4jVersion>1.6.1</slf4jVersion>
<maven.test.skip>true</maven.test.skip>
<junit.version>4.8.2</junit.version>
<hibernate.version>3.5.6-Final</hibernate.version>
</properties>
i am using spring 4.2.5.RELEASE version and javassist 3.19.0-GA version .
and in the web app, I can see following jar files after installing the application on WebSphere /WEB-INF/lib
aopalliance-1.0.jar
commons-io-1.4.jar
jcl-over-slf4j-1.6.1.jar
spring-aop-4.2.5.RELEASE.jar
spring-expression-4.2.5.RELEASE.jar
bcprov-jdk16-1.46.jar
freemarker-2.3.16.jar
log4j-1.2.14.jar
spring-beans-4.2.5.RELEASE.jar
spring-web-4.2.5.RELEASE.jar
commons-codec-1.4.jar
ibmpkcs-8.0.jar
slf4j-api-1.6.1.jar
spring-context-4.2.5.RELEASE.jar
spring-webmvc-4.2.5.RELEASE.jar
commons-fileupload-1.2.2.jar
javassist-3.19.0-GA.jar
slf4j-log4j12-1.6.1.jar
spring-core-4.2.5.RELEASE.jar
also in web.xml i am using org.springframework.aop.framework.JavassistApplicationContext
<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.aop.framework.JavassistApplicationContext</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listenerclass>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
and in class path /WEB-INF/classes/org/springframework/aop/framework i have some javassist classes .
JavassistAopProxy$1.class
JavassistAopProxy$EqualsInterceptor.class
JavassistAopProxy$JavassistMethodInvocation.class
JavassistAopProxy.class JavassistAopProxy$AdvisedDispatcher.class
JavassistAopProxy$ExProxyFactory.class JavassistAopProxy$MethodInterceptor.class
JavassistAopProxyFactory.class JavassistAopProxy$CompositeInterceptor.class
JavassistAopProxy$FixedChainStaticTargetInterceptor.class
JavassistAopProxy$StaticDispatcher.class JavassistApplicationContext.class JavassistAopProxy$DynamicAdvisedInterceptor.class
JavassistAopProxy$HashCodeInterceptor.class
JavassistAopProxy$UnadvisedInterceptor.class
Any suggestions on this error? I have tried following methods to
class loader parent last method on server and application
Update spring to latest version
removed javascript jar files from /WEB-INF/lib path
I can't understand what is this error means. Any explanations and suggestions to solve this error. It was working fine in WebSphere 6 with Java 1.6
update :
mvn dependency:tree
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # myapp-parent ---
[INFO] com.test:myapp-parent:pom:6.2.0
[INFO] +- commons-logging:commons-logging:jar:1.2:provided
[INFO] +- commons-logging:commons-logging-api:jar:1.1:provided
[INFO] +- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.6.1:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.1:compile
[INFO] +- log4j:log4j:jar:1.2.14:compile
[INFO] +- junit:junit:jar:4.8.2:test
[INFO] \- com.ibm:ibmpkcs:jar:8.0:compile
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Web Application Package 6.2.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # myapp-webapp ---
[INFO] com.test:myapp-webapp:war:6.2.0
[INFO] +- org.springframework:spring-webmvc:jar:4.2.5.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.2.5.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:4.2.5.RELEASE:compile
[INFO] | | \- org.springframework:spring-aop:jar:4.2.5.RELEASE:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-core:jar:4.2.5.RELEASE:compile
[INFO] | +- org.springframework:spring-expression:jar:4.2.5.RELEASE:compile
[INFO] | \- org.springframework:spring-web:jar:4.2.5.RELEASE:compile
[INFO] +- commons-codec:commons-codec:jar:1.4:compile
[INFO] +- commons-io:commons-io:jar:1.4:compile
[INFO] +- commons-fileupload:commons-fileupload:jar:1.2.2:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- org.freemarker:freemarker:jar:2.3.16:compile
[INFO] +- org.springframework:spring-test:jar:4.2.5.RELEASE:test
[INFO] +- org.javassist:javassist:jar:3.21.0-GA:compile
[INFO] +- org.bouncycastle:bcprov-jdk16:jar:1.46:compile
[INFO] +- commons-logging:commons-logging:jar:1.2:provided
[INFO] +- commons-logging:commons-logging-api:jar:1.1:provided
[INFO] +- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.6.1:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.1:compile
[INFO] +- log4j:log4j:jar:1.2.14:compile
[INFO] +- junit:junit:jar:4.8.2:test
[INFO] \- com.ibm:ibmpkcs:jar:8.0:compile
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Enterprise Application Package 6.2.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # myapp-ear ---
[INFO] com.test:myapp-ear:ear:6.2.0
[INFO] +- com.test:myapp-webapp:war:6.2.0:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.6.1:provided
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.6.1:provided
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.1:provided
[INFO] +- log4j:log4j:jar:1.2.14:provided
[INFO] +- commons-logging:commons-logging:jar:1.2:provided
[INFO] +- commons-logging:commons-logging-api:jar:1.1:provided
[INFO] +- junit:junit:jar:4.8.2:test
[INFO] \- com.ibm:ibmpkcs:jar:8.0:compile
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] my application...................................... SUCCESS [ 9.465 s]
[INFO] Web Application Package ............................ SUCCESS [ 0.104 s]
[INFO] Enterprise Application Package ..................... SUCCESS [ 0.044 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.721 s
[INFO] Finished at: 2017-09-18T13:33:51+05:30
[INFO] Final Memory: 13M/245M
[INFO] ------------------------------------------------------------------------
Update
And now i think the problem due to javassist file . I am loading a specific class using javassist in my code .org.spring.aop.framework.ProxyCreatorSupport is a class that will be loaded by the class loader . But i am getting some IllegalStateException , cannot compile exceptions when i deploy .EAR file to WebSphere .
Using ClassPool.getDefault(), I am looking up information from the system class path . Added the class loader that is handed over by the transformation method as an argument. I have appended class loader to Javassist's search path .
package org.spring.aop.framework;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtConstructor;
import javassist.LoaderClassPath;
import org.springframework.web.context.support.XmlWebApplicationContext;
public class JavassistApplicationContext extends XmlWebApplicationContext {
static {
ClassPool classPool = ClassPool.getDefault();
try {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
classPool.appendClassPath(new LoaderClassPath(classLoader));
CtClass cc = classPool.get("org.spring.aop.framework.ProxyCreatorSupport");
CtConstructor c = cc.getConstructors()[0];
c.insertAfter("$0.aopProxyFactory = new org.spring.aop.framework.JavassistAopProxyFactory();");
cc.toClass();
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
}
It was working fine with java 1.6 WebSphere 8 . After update to java 8 WebSphere 9 , i am getting these kind of exceptions .I think Javassist toClass() causing exceptions in websphere . Also CtClass cc = classPool.get("org.spring.aop.framework.ProxyCreatorSupport");making some linkage issues . Any suggestion now ?

Categories

Resources