NoSuchMethodError: com.mongodb.MongoClientSettings$Builder.uuidRepresentation - java

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>

Related

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

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

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

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 ?

Spring 4.3.0.RELEASE + Hibernate 5.2.0.Final + JPA Repository

I have this Error while trying to work with Spring JPA:
Could not open JPA EntityManager for transaction; nested exception is java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode()Lorg/hibernate/FlushMode;
** Update: Full Stack trace
It works in the same configuration in diffrent project
What could be the reason?
I`m using Java 1.8 & Dynamic Web Application 3.1 (As the parallel project that works)
pom.xml:
<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>Test</groupId>
<artifactId>Test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<webXml>WebContent\WEB-INF\web.xml</webXml>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>org.test.int1.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.0.RELEASE</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.3.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.10.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.1.0.RELEASE</version>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.3.0.Alpha1</version>
</dependency>
<!-- AspectJ -->
<dependency>
<groupId>aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.5.4</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.21</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.21</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
<scope>runtime</scope>
</dependency>
<!-- Apache Commons DBCP -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<!-- Javax -->
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</project>
Full Error:
[16/08/16 10:41:57:057 IDT] INFO web.DefaultSecurityFilterChain: Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher#1, [org.springframework.security.web.context.SecurityContextPersistenceFilter#2b00cbc, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#1e44b04e, org.springframework.security.web.header.HeaderWriterFilter#46828666, org.springframework.security.web.csrf.CsrfFilter#7d5376a4, org.springframework.security.web.authentication.logout.LogoutFilter#7f04505e, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#44f95930, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#161a567f, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#709ae44e, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#2d41cca3, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#23ff20e2, org.springframework.security.web.session.SessionManagementFilter#6792334c, org.springframework.security.web.access.ExceptionTranslationFilter#408d1364, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#638afb02]
[16/08/16 10:41:57:057 IDT] INFO http.DefaultFilterChainValidator: Checking whether login URL '/login' is accessible with your configuration
[16/08/16 10:41:57:057 IDT] INFO startup.StartupDbDataInit: -------------------------------------------------------
[16/08/16 10:41:57:057 IDT] INFO startup.StartupDbDataInit: StartupDbDataInit Working - Starting...
[16/08/16 10:41:57:057 IDT] INFO startup.StartupDbDataInit: -------------------------------------------------------
[16/08/16 10:41:57:057 IDT] DEBUG internal.TransactionImpl: begin
[16/08/16 10:41:57:057 IDT] DEBUG internal.TransactionImpl: rolling back
[16/08/16 10:41:57:057 IDT] DEBUG internal.LogicalConnectionManagedImpl: Initiating JDBC connection release from afterTransaction
[16/08/16 10:41:57:057 IDT] DEBUG internal.LogicalConnectionManagedImpl: Initiating JDBC connection release from afterTransaction
[16/08/16 10:41:57:057 IDT] INFO startup.StartupDbDataInit: StartupDbDataInit Failed!!!!!, Details=>>> Could not open JPA EntityManager for transaction; nested exception is java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode()Lorg/hibernate/FlushMode;
[16/08/16 10:41:57:057 IDT] WARN support.XmlWebApplicationContext: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'startupDbDataInit': Invocation of init method failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode()Lorg/hibernate/FlushMode;
[16/08/16 10:41:57:057 IDT] INFO jpa.LocalContainerEntityManagerFactoryBean: Closing JPA EntityManagerFactory for persistence unit 'default'
[16/08/16 10:41:57:057 IDT] DEBUG internal.SessionFactoryImpl: HHH000031: Closing
[16/08/16 10:41:57:057 IDT] DEBUG spi.CascadeStyles: External cascade style regsitration [persist : STYLE_PERSIST] overrode base registration [STYLE_PERSIST_SKIPLAZY]
[16/08/16 10:41:57:057 IDT] DEBUG internal.AbstractServiceRegistryImpl: Implicitly destroying ServiceRegistry on de-registration of all child ServiceRegistries
[16/08/16 10:41:57:057 IDT] DEBUG internal.BootstrapServiceRegistryImpl: Implicitly destroying Boot-strap registry on de-registration of all child ServiceRegistries
[16/08/16 10:41:57:057 IDT] ERROR context.ContextLoader: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'startupDbDataInit': Invocation of init method failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode()Lorg/hibernate/FlushMode;
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:775)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3858)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:291)
at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:5660)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1376)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1380)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1380)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1348)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode()Lorg/hibernate/FlushMode;
at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:431)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:427)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:276)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy83.count(Unknown Source)
at com.test.startup.StartupDbDataInit.onApplicationInit(StartupDbDataInit.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:365)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:310)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
... 25 more
Caused by: java.lang.NoSuchMethodError: org.hibernate.Session.getFlushMode()Lorg/hibernate/FlushMode;
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.prepareFlushMode(HibernateJpaDialect.java:187)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.beginTransaction(HibernateJpaDialect.java:173)
at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:380)
... 46 more
Dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Monitor 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The artifact aspectj:aspectjrt:jar:1.5.4 has been relocated to org.aspectj:aspectjrt:jar:1.5.4
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # Monitor ---
[WARNING] The artifact aspectj:aspectjrt:jar:1.5.4 has been relocated to org.aspectj:aspectjrt:jar:1.5.4
[INFO] Monitor:Monitor:war:0.0.1-SNAPSHOT
[INFO] +- org.springframework:spring-context:jar:4.3.0.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.3.0.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.3.0.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:4.3.0.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:4.3.0.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.3.0.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:4.3.0.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:4.3.0.RELEASE:compile
[INFO] +- org.springframework.data:spring-data-jpa:jar:1.10.2.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:1.12.2.RELEASE:compile
[INFO] | \- org.springframework:spring-orm:jar:4.2.6.RELEASE:compile
[INFO] | \- org.springframework:spring-jdbc:jar:4.2.6.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:4.1.0.RELEASE:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | \- org.springframework.security:spring-security-core:jar:4.1.0.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-web:jar:4.1.0.RELEASE:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:5.2.2.Final:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | +- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] | +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] | \- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] +- org.hibernate:hibernate-core:jar:5.2.2.Final:compile
[INFO] | +- antlr:antlr:jar:2.7.7:compile
[INFO] | +- org.jboss:jandex:jar:2.0.0.Final:compile
[INFO] | +- com.fasterxml:classmate:jar:1.3.0:compile
[INFO] | \- javax.enterprise:cdi-api:jar:1.1:compile
[INFO] | +- javax.el:el-api:jar:2.2:compile
[INFO] | +- org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.1_spec:jar:1.0.0.Beta1:compile
[INFO] | +- javax.annotation:jsr250-api:jar:1.0:compile
[INFO] | \- javax.inject:javax.inject:jar:1:compile
[INFO] +- org.hibernate:hibernate-validator:jar:5.3.0.Alpha1:compile
[INFO] | \- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] +- org.aspectj:aspectjrt:jar:1.5.4:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.21:runtime
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.21:runtime
[INFO] +- log4j:log4j:jar:1.2.17:runtime
[INFO] +- commons-dbcp:commons-dbcp:jar:1.4:compile
[INFO] | \- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] +- javax.transaction:jta:jar:1.1:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] +- javax.servlet.jsp:jsp-api:jar:2.2:compile
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- org.jsoup:jsoup:jar:1.7.2:compile
[INFO] +- javax.mail:mail:jar:1.4.7:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] \- javax.mail:javax.mail-api:jar:1.5.5:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.467 s
[INFO] Finished at: 2016-08-16T12:18:23+03:00
[INFO] Final Memory: 13M/245M
[INFO] ------------------------------------------------------------------------
The module hibernate-entitymanager was removed in Hibernate 5.2.0 and the functionality was moved to hibernate-core. So you can just remove the hibernate-entitymanager dependency (and while you're on it, use the latest version 5.2.2):
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.2.Final</version>
</dependency>
If you still have the same error afterwards, it might be, that another dependency still depends on an older version of hibernate-entitymanager, which causes then conflicts. In this case, add the hibernate-entitymanager again with the newest version:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.2.Final</version>
</dependency>
Also since spring-data-jpa 1.10.2 depends on spring-orm 4.2.6, you should add the explicit dependency to spring-orm with the correct version:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.3.0.RELEASE</version>
</dependency>
You use incompatible libs.
The API has changed in hibernate 5:
FlushModeType getFlushMode()
For users of the Hibernate native APIs, we've had to rename this
method as defined by Hibernate historically because the JPA contract
defines a method of the same name, but returning the JPA FlushModeType
rather than Hibernate's FlushMode.
The following combination works fine for me:
<properties>
<project.mysql.connector.version>5.1.30</project.mysql.connector.version>
<project.hibernate.version>5.2.2.Final</project.hibernate.version>
<project.spring.orm.version>4.3.3.RELEASE</project.spring.orm.version>
<project.spring.data.jpa.version>1.10.3.RELEASE</project.spring.data.jpa.version>
</properties>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${project.mysql.connector.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${project.hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>${project.spring.data.jpa.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${project.spring.orm.version}</version>
</dependency>
But, while using the MULTI-TENANCY (currently configured for SCHEMA), it is not able to create the tables before trying to insert data and throws exception that table is not present. I really don't want to use the sql import as that takes away all the benefit of automatic schema management.
This looks as a Jar conflict.
I am using Spring Framework 4.3.5.RELEASE version and I downgrade hibernate to hibernate-core-5.1.0.Final.
It works for me.

Hibernate 5 java.lang.NoSuchMethodError org.jboss.logging.Logger.debugf

I have a problem when I deploy a webapp with hibernate 5
Caused by: java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
at org.hibernate.internal.NamedQueryRepository.checkNamedQueries(NamedQueryRepository.java:149) [hibernate-core-5.0.0.CR2.jar:5.0.0.CR2]
at org.hibernate.internal.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:759) [hibernate-core-5.0.0.CR2.jar:5.0.0.CR2]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:490) [hibernate-core-5.0.0.CR2.jar:5.0.0.CR2]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444) [hibernate-core-5.0.0.CR2.jar:5.0.0.CR2]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708) [hibernate-core-5.0.0.CR2.jar:5.0.0.CR2]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724) [hibernate-core-5.0.0.CR2.jar:5.0.0.CR2]
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:372) [spring-orm-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:454) [spring-orm-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:439) [spring-orm-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633) [spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570) [spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
... 23 more
With Hibernate 4 everything is OK.
I had a look at the class NamedQueryRepository at line 149. That class is calling the method debugf in this way
log.debugf( "Checking %s named HQL queries", namedQueryDefinitionMap.size() );
I can not see the problem
Here is my dependency tree
[INFO] ------------------------------------------------------------------------
[INFO] Building app Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # app---
[INFO] +- org.springframework:spring-aspects:jar:4.1.7.RELEASE:compile
[INFO] | \- org.aspectj:aspectjweaver:jar:1.8.6:compile
[INFO] +- org.springframework:spring-tx:jar:4.1.7.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:4.1.7.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:4.1.7.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:4.1.7.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:4.1.7.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:4.1.7.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.springframework:spring-orm:jar:4.1.7.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:4.1.7.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:4.1.7.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-jdbc:jar:4.1.7.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:4.1.7.RELEASE:test
[INFO] +- junit:junit:jar:4.12:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.hibernate:hibernate-entitymanager:jar:5.0.0.CR2:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] | +- org.hibernate:hibernate-core:jar:5.0.0.CR2:compile
[INFO] | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | \- org.jboss:jandex:jar:1.2.2.Final:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] | +- org.hibernate.common:hibernate-commons-annotations:jar:5.0.0.Final:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] | +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] | \- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] +- org.hibernate:hibernate-c3p0:jar:5.0.0.CR2:compile
[INFO] | \- com.mchange:c3p0:jar:0.9.2.1:compile
[INFO] | \- com.mchange:mchange-commons-java:jar:0.2.3.4:compile
[INFO] +- org.primefaces:primefaces:jar:5.2.RC3:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.2:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.2:compile
[INFO] \- net.sourceforge.jtds:jtds:jar:1.2.8:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
In glass fish This problem is caused by collision with dependencies of glassfish modules. If you check lib list in glassfishdir/modules you would see boss-logging.jar. You can delete it and replace with latest such as org.jboss.logging:jboss-logging:jar:3.3.0.Final. It worked for me.
In my case the culprit was the Jersey bean validator artifact.
One of its dependencies, bean-validation-2.4.0-b06.jar contains Jboss logging classes, for some reason.
I had to exclude the jersey-bean-validation and bean-validator artifacts from the spring-boot-starter-jersey dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
<exclusions>
<exclusion>
<artifactId>jersey-bean-validation</artifactId>
<groupId>org.glassfish.jersey.ext</groupId>
</exclusion>
<exclusion>
<artifactId>bean-validator</artifactId>
<groupId>org.glassfish.hk2.external</groupId>
</exclusion>
</exclusions>
</dependency>
EDIT: As of spring-boot 1.3.0, this is fixed and the exclusions above are not necessary anymore.
Try upgrading jboss-logging.jar to a more recent version. The one you are using does not seem to be compatible with Hibernate 5.
I also faced with such kind of problem when deployed ear on weblogic server.
Apparently, weblogic also use jboss logging system, and use old version of it.
My fix:
Add "weblogic-application.xml" to META-INF folder with this content:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application>
<prefer-application-packages>
<package-name>org.jboss.logging.*</package-name>
</prefer-application-packages>
<prefer-application-resources>
<resource-name>org/jboss/logging/Logger.class</resource-name>
</prefer-application-resources>
</weblogic-application>
I was getting the same error using jersey-spring-3 and hibernate 5.0.1.Final.Excluding org.glassfish.hk2.external:bean-validator from jersy-spring-3 and adding org.glassfish.jersey.ext:jersey-bean-validation worked for me.Here is my final dependency.
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<version>2.22.2</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>bean-validator</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-bean-validation</artifactId>
<version>2.22.2</version>
</dependency>
from :
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<version>2.22.2</version>
</dependency>
In all probability you've got an outdated JBoss Logging JAR on the application's classpath. The ...f methods are a relatively new addition to the Logger API. Hibernate 5 directly depends on Logging version 3.3.0, but it is possible that somehwere in your pom.xml you have an overriding dependency to an earlier version. Another possibility is that you are deploying to a JBoss container where the logging API is container-provided. Then you may need to upgrade the JBoss server, or introduce a workaround to prefer classes contributed by your application.
Check my answer at NoSuchMethodError: org.jboss.logging.Logger.debugf
Even I was having issues after upgrading to Hibernate 5.2 , and the culprit was "jboss-logging 3.3.0.Final" which I see present in your dependencies too.
Following the steps on the link shared in the answer, you can reduce the dependency jboss-logging to 3.2 level which has the required function.
In my case the issue was caused by an older version of jboss-logging coming as transitive dependency from hibernate-ehcache, which I found by looking into the maven dependencies tree. I solved it by adding the exclusion:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>${hibernate.version}</version>
<exclusions>
<exclusion>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
I had the same error, it is solved by
First add the dependency of jboss logging jar as follows
<!-- https://mvnrepository.com/artifact/org.jboss.logging/jboss-logging -->
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.3.0.Final</version>
</dependency>
And if the error still exists then add following exlcusion to the maven dependency.
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<version>2.12</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2</artifactId>
</exclusion>
</exclusions>
</dependency>
After doing these two things, it is working fine for me.I hope it will work for
you also.
Error that i got was "
Application run failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
:::
:::
Caused by: java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V"
i deleted the jboss-logging folder <.m2\repository\org\jboss\logging\jboss-logging> and restarted the jboss server.
The jars got addedback and the error was gone. (i got some other error after that, but atleast this error was gone)
I too faced this issue. This is what fixed it for me
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.1.RELEASE</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
I have the same problen with spring4.2.1+hibernate5.0.2+jersey2.23.1.
My solution is the same: Excluding org.glassfish.hk2.external:bean-validator from jersy-spring-3 and adding org.glassfish.jersey.ext:jersey-bean-validation.
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<version>2.23.1</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>bean-validator</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-bean-validation</artifactId>
<version>2.23.1</version>
</dependency>
In my product environment, just delete bean-validator-2.4.0-b34.jar and add jersey-bean-validation-2.23.1.jar
This can be caused if a dependency includes
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.6.2</version>
</dependency>
Exclude it using an exclusions element in dependency.
JBoss 6.1+??
I set org.jboss.logging for jboss-logging-3.3.0.Final-redhat-1.jar in modules of jboss.
Its works for me.
Att.,
You can use Eclipse to find out which jar is causing the problem:
Setup a project with all your jars on the classpath
Navigate -> Open Type...
Type in org.jboss.logging.Logger
This will give you a list of jars which include the class. One of these is out of date and needs to be excluded (refer to other answers for variations on this).
My error was caused by GlassFish and I fixed it by configuring glassfish-web.xml:
The Java Servlet specification recommends that a web module's class loader look in the local class loader before delegating to its parent. You can make this class loader follow the delegation inversion model in the Servlet specification by setting delegate="false" in the class-loader element of the glassfish-web.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
<context-root>/myContext</context-root>
<!–– Change this line "true" to "false" -->
<class-loader delegate="false"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</glassfish-web-app>

Categories

Resources