Every thing seems to be perfect until i launch all project unit tests.
After upgrade my project to struts 2.3.15.1 from 2.2.1.1 I got these errors :
java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V
at net.sf.cglib.core.DebuggingClassWriter.<init>(DebuggingClassWriter.java:47)
at net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter(DefaultGeneratorStrategy.java:30)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
The problem was in fact struts 2.3.15.1 use another version of asm framework which is different from the previous one . here the result of mvn tree
[INFO] | +- com.holly.project:ejbMex:ejb-client:client:8.13.0-SNAPSHOT:compile
[INFO] | | +- com.holly.project:commons-care:jar:8.13.0-SNAPSHOT:compile
[INFO] | | | +- org.hibernate:hibernate:jar:3.2.5.ga:compile
[INFO] | | | | +- net.sf.ehcache:ehcache:jar:1.2.3:compile
[INFO] | | | | +- asm:asm-attrs:jar:1.5.3:compile
[INFO] | | | | +- antlr:antlr:jar:2.7.6:compile
[INFO] | | | | \- cglib:cglib:jar:2.1_3:compile
+- org.apache.struts:struts2-core:jar:2.3.15.1:compile
[INFO] | +- org.apache.struts.xwork:xwork-core:jar:2.3.15.1:compile
[INFO] | | +- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] | | +- asm:asm:jar:3.3:compile
[INFO] | | \- asm:asm-commons:jar:3.3:compile
[INFO] | | \- asm:asm-tree:jar:3.3:compile
[INFO] | +- org.freemarker:freemarker:jar:2.3.19:compile
[INFO] | +- ognl:ognl:jar:3.0.6:compile
[INFO] | | \- javassist:javassist:jar:3.11.0.GA:compile
[INFO] | +- commons-fileupload:commons-fileupload:jar:1.3:compile
[INFO] | \- commons-io:commons-io:jar:1.4:compile
as you can see struts use asm 3.3 which is not the one defined in hibernate transitive dependency . i solution i excluded this dependency from my struts declaration
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.15.1</version>
<exclusions>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
</exclusions>
</dependency>
The problem was solved but i'm getting now new errors which i can't figure out about what .?
java.lang.VerifyError: Instruction type does not match stack map in method holly.commons.ihm.utils.ServiceLocator.getMePage()Lcom.holly.project/service/IMEPage; at offset 959
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getMethod0(Class.java:2685)
at java.lang.Class.getMethod(Class.java:1620)
at org.easymock.internal.ObjectMethodsFilter.<init>(ObjectMethodsFilter.java:55)
at org.easymock.internal.MocksControl.createMock(MocksControl.java:59)
at org.easymock.EasyMock.createMock(EasyMock.java:103)
at holly.commons.ihm.remote.TemplMePageTest.<init>(TemplMePageTest.java:63)
#AleksandrM as Always, Thank You for your cooperation :)
In fact the problem was resolved after the exclusion also of the ognl artifact from struts core transitive dependency. it seems the version which is used to compile all the Unit Test was different from the one used to run theses ones.
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.15.1</version>
<exclusions>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
<exclusion>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
</exclusion>
</exclusions>
</dependency>
Related
Can anyone help me with this one? I already tried different solutions posted here but nothing works.
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:1239)
The following method did not exist:
javax.persistence.Table.indexes()[Ljavax/persistence/Index;
The calling method's class, org.hibernate.cfg.annotations.EntityBinder, was loaded from the following location:
jar:file:/C:/Users/csatl/.m2/repository/org/hibernate/hibernate-core/5.6.5.Final/hibernate-core-5.6.5.Final.jar!/org/hibernate/cfg/annotations/EntityBinder.class
The called method's class, javax.persistence.Table, is available from the following locations:
jar:file:/C:/Users/csatl/Desktop/Facultate/An%203-sem2/SD/labs/lab2/lib/javax.persistence.jar!/javax/persistence/Table.class
jar:file:/C:/Users/csatl/.m2/repository/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar!/javax/persistence/Table.class
jar:file:/C:/Users/csatl/.m2/repository/javax/persistence/javax.persistence-api/2.2/javax.persistence-api-2.2.jar!/javax/persistence/Table.class
jar:file:/C:/Users/csatl/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar!/javax/persistence/Table.class
The called method's class hierarchy was loaded from the following locations:
javax.persistence.Table: file:/C:/Users/csatl/Desktop/Facultate/An%203-sem2/SD/labs/lab2/lib/javax.persistence.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes org.hibernate.cfg.annotations.EntityBinder and javax.persistence.Table
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: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
at ro.sd.firstapp.FirstAppApplication.main(FirstAppApplication.java:11)
Caused by: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:1239)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:826)
at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:225)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:239)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:282)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1460)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1494)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
... 16 more
Here is my 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>ro.sd</groupId>
<artifactId>first-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>first-app</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<frontend-maven-plugin.version>1.6</frontend-maven-plugin.version>
<node.version>v14.8.0</node.version>
<yarn.version>v1.12.1</yarn.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.6.5.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.6.5.Final</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.hibernate</groupId>-->
<!-- <artifactId>hibernate-core</artifactId>-->
<!-- <version>4.1.4.Final</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.hibernate</groupId>-->
<!-- <artifactId>hibernate-entitymanager</artifactId>-->
<!-- <version>5.2.3.Final</version>-->
<!-- </dependency>-->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>javax.persistence</groupId>-->
<!-- <artifactId>javax.persistence-api</artifactId>-->
<!-- <version>2.1</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.hibernate.javax.persistence</groupId>-->
<!-- <artifactId>hibernate-jpa-2.1-api</artifactId>-->
<!-- <version>1.0.0.Final</version>-->
<!-- </dependency>-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${project.parent.version}</version>
</plugin>
</plugins>
</build>
</project>
The BeanCreationException is from my main class. I used a try catch.
package ro.sd.firstapp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class FirstAppApplication {
public static void main(String[] args) {
try{
SpringApplication.run(FirstAppApplication.class, args);
}catch (Exception e)
{
e.printStackTrace();
}
}
I tried changing the env variables. I tried including more dependencies, delete dependencies. I don't know what's wrong.
Here is my mvn dependency:tree
[INFO] --- maven-dependency-plugin:3.2.0:tree (default-cli) # first-app ---
[INFO] ro.sd:first-app:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.6.4:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:2.6.4:compile
[INFO] | | +- org.springframework:spring-aop:jar:5.3.16:compile
[INFO] | | \- org.aspectj:aspectjweaver:jar:1.9.7:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.6.4:compile
[INFO] | | +- com.zaxxer:HikariCP:jar:4.0.3:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:5.3.16:compile
[INFO] | +- jakarta.transaction:jakarta.transaction-api:jar:1.3.3:compile
[INFO] | +- jakarta.persistence:jakarta.persistence-api:jar:2.2.3:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:2.6.2:compile
[INFO] | | +- org.springframework.data:spring-data-commons:jar:2.6.2:compile
[INFO] | | +- org.springframework:spring-orm:jar:5.3.16:compile
[INFO] | | +- org.springframework:spring-context:jar:5.3.16:compile
[INFO] | | +- org.springframework:spring-tx:jar:5.3.16:compile
[INFO] | | +- org.springframework:spring-beans:jar:5.3.16:compile
[INFO] | | \- org.slf4j:slf4j-api:jar:1.7.36:compile
[INFO] | \- org.springframework:spring-aspects:jar:5.3.16:compile
[INFO] +- org.springframework.boot:spring-boot-starter:jar:2.6.4:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:2.6.4:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.6.4:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-logging:jar:2.6.4:compile
[INFO] | | +- ch.qos.logback:logback-classic:jar:1.2.10:compile
[INFO] | | | \- ch.qos.logback:logback-core:jar:1.2.10:compile
[INFO] | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.17.1:compile
[INFO] | | | \- org.apache.logging.log4j:log4j-api:jar:2.17.1:compile
[INFO] | | \- org.slf4j:jul-to-slf4j:jar:1.7.36:compile
[INFO] | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] | +- org.springframework:spring-core:jar:5.3.16:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.3.16:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.29:compile
[INFO] +- org.springframework.security:spring-security-crypto:jar:5.6.2:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.6.4:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.6.4:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.13.1:compile
[INFO] | | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.13.1:compile
[INFO] | | | \- com.fasterxml.jackson.core:jackson-core:jar:2.13.1:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.13.1:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.1:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.13.1:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.6.4:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.58:compile
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.58:compile
[INFO] | +- org.springframework:spring-web:jar:5.3.16:compile
[INFO] | \- org.springframework:spring-webmvc:jar:5.3.16:compile
[INFO] | \- org.springframework:spring-expression:jar:5.3.16:compile
[INFO] +- org.springframework.boot:spring-boot-starter-validation:jar:2.6.4:compile
[INFO] | +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.58:compile
[INFO] | \- org.hibernate.validator:hibernate-validator:jar:6.2.2.Final:compile
[INFO] | \- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.6.4:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.6.4:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.6.4:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.6.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.4.8:test
[INFO] | | \- net.minidev:accessors-smart:jar:2.4.8:test
[INFO] | | \- org.ow2.asm:asm:jar:9.1:test
[INFO] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
[INFO] | | \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile
[INFO] | +- org.assertj:assertj-core:jar:3.21.0:test
[INFO] | +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] | +- org.junit.jupiter:junit-jupiter:jar:5.8.2:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-api:jar:5.8.2:test
[INFO] | | | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | | | +- org.junit.platform:junit-platform-commons:jar:1.8.2:test
[INFO] | | | \- org.apiguardian:apiguardian-api:jar:1.1.2:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-params:jar:5.8.2:test
[INFO] | | \- org.junit.jupiter:junit-jupiter-engine:jar:5.8.2:test
[INFO] | | \- org.junit.platform:junit-platform-engine:jar:1.8.2:test
[INFO] | +- org.mockito:mockito-core:jar:4.0.0:test
[INFO] | | +- net.bytebuddy:byte-buddy-agent:jar:1.11.22:test
[INFO] | | \- org.objenesis:objenesis:jar:3.2:test
[INFO] | +- org.mockito:mockito-junit-jupiter:jar:4.0.0:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | +- org.springframework:spring-test:jar:5.3.16:test
[INFO] | \- org.xmlunit:xmlunit-core:jar:2.8.4:test
[INFO] +- org.projectlombok:lombok:jar:1.18.22:compile
[INFO] +- mysql:mysql-connector-java:jar:8.0.28:runtime
[INFO] +- org.hibernate:hibernate-core:jar:5.6.5.Final:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.4.3.Final:compile
[INFO] | +- javax.persistence:javax.persistence-api:jar:2.2:compile
[INFO] | +- net.bytebuddy:byte-buddy:jar:1.11.22:compile
[INFO] | +- antlr:antlr:jar:2.7.7:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.1.1.Final:compile
[INFO] | +- org.jboss:jandex:jar:2.4.2.Final:compile
[INFO] | +- com.fasterxml:classmate:jar:1.5.1:compile
[INFO] | +- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] | +- org.hibernate.common:hibernate-commons-annotations:jar:5.1.2.Final:compile
[INFO] | \- org.glassfish.jaxb:jaxb-runtime:jar:2.3.6:compile
[INFO] | +- org.glassfish.jaxb:txw2:jar:2.3.6:compile
[INFO] | +- com.sun.istack:istack-commons-runtime:jar:3.0.12:compile
[INFO] | \- com.sun.activation:jakarta.activation:jar:1.2.2:runtime
[INFO] +- org.hibernate:hibernate-entitymanager:jar:5.6.5.Final:compile
[INFO] +- javax.xml.bind:jaxb-api:jar:2.3.0:compile
[INFO] \- javax.persistence:persistence-api:jar:1.0.2:compile
I would like to upgrade version of spring-boot-starter-logging, but I am facing the problem with overriding maven dependency.
Dependency tree before any changes:
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:2.0.1.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.0.1.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.1.RELEASE:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] | | | | \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] | | | \- org.slf4j:jul-to-slf4j:jar:1.7.21:compile
By modifying parent pom and overriding dependency in dependencyManagement block:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
<version>2.6.2</version>
</dependency>
</dependencies>
</dependencyManagement>
I am able to override "sole dependency" - only spring-boot-starter-logging version is updated, but child dependencies (logback-classic and log4j-to-slf4j) exists still in old versions:
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:2.0.1.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.0.1.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.6.2:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] | | | | \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] | | | \- org.slf4j:jul-to-slf4j:jar:1.7.21:compile
Is it possible to upgrade child dependency versions by overriding version of spring-boot-starter-logging so that new versions of child dependencies will be taken from spring-boot-starter-logging pom?
I know that I can override all the child versions one by one in dependencyManagement block, but I would like to know if there is another possibility.
I get the following message when I deploy my war to the Tomcat 7:
nested exception is java.lang.NoClassDefFoundError: javax/el/ELManager
I added <tomcat.version>7.0.61</tomcat.version> to my pom.xml and can now reproduce the error on my development environment.
The error happens after the bean creation, the other changes that were necessary to get the war to run I made.
I tried to change my pom.xml so that it uses old versions which might play nice with tomcat 7, but failed to remove the problem. I don't know which package produces the problem.
See pom.xml:
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.xxx</groupId>
<artifactId>monitormonitor</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>monitormonitor</name>
<description>Web Service Monitoring project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<start-class>com.xxx.monitormonitor.MonitormonitorApplication</start-class>
<!-- deploying war-file on tomcat 7 -->
<tomcat.version>7.0.61</tomcat.version><!-- nested exception is java.lang.NoClassDefFoundError: javax/el/ELManager -->
<servlet-api.version>3.0.1</servlet-api.version>
</properties>
<packaging>war</packaging>
<dependencies>
<!-- added other version of log4j for invalid byte tag error -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<!-- changed version vs. ClassFormatException: Invalid byte tag in constant pool: 19 -->
<!--<version>2.11.1</version>-->
<version>2.7</version>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- <scope>provided</scope> -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>1.1.6.RELEASE</version>
<scope>provided</scope>
</dependency>
-->
<!-- added vs java.lang.NoClassDefFoundError: javax/el/ELManager -->
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
-->
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
<version>2.2.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.xxx.monitormonitor.MonitormonitorApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
dependency tree:
[INFO] com.xxx:monitormonitor:war:0.0.1-SNAPSHOT
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.7:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.7:compile
[INFO] +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.1.2.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.1.2.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.1.2.RELEASE:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.11.1:compile
[INFO] | | | \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.23:runtime
[INFO] | +- com.zaxxer:HikariCP:jar:3.2.0:compile
[INFO] | | \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] | \- org.springframework:spring-jdbc:jar:5.1.4.RELEASE:compile
[INFO] | \- org.springframework:spring-tx:jar:5.1.4.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-mail:jar:2.1.2.RELEASE:compile
[INFO] | \- com.sun.mail:javax.mail:jar:1.6.2:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.1.2.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.1.2.RELEASE:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.8:compile
[INFO] | | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] | | | \- com.fasterxml.jackson.core:jackson-core:jar:2.9.8:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.8:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.8:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.8:compile
[INFO] | +- org.hibernate.validator:hibernate-validator:jar:6.0.14.Final:compile
[INFO] | | +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] | | \- com.fasterxml:classmate:jar:1.4.0:compile
[INFO] | +- org.springframework:spring-web:jar:5.1.4.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc:jar:5.1.4.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:5.1.4.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:5.1.4.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.1.2.RELEASE:provided
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] | +- org.apache.tomcat.embed:tomcat-embed-core:jar:7.0.61:provided
[INFO] | +- org.apache.tomcat.embed:tomcat-embed-el:jar:7.0.61:provided
[INFO] | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:7.0.61:provided
[INFO] +- org.springframework.boot:spring-boot-devtools:jar:2.1.2.RELEASE:runtime
[INFO] | +- org.springframework.boot:spring-boot:jar:2.1.2.RELEASE:compile
[INFO] | \- org.springframework.boot:spring-boot-autoconfigure:jar:2.1.2.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.1.2.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.1.2.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.1.2.RELEASE:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.3:test
[INFO] | | \- net.minidev:accessors-smart:jar:1.2:test
[INFO] | | \- org.ow2.asm:asm:jar:5.0.4:test
[INFO] | +- junit:junit:jar:4.12:test
[INFO] | +- org.assertj:assertj-core:jar:3.11.1:test
[INFO] | +- org.mockito:mockito-core:jar:2.23.4:test
[INFO] | | +- net.bytebuddy:byte-buddy:jar:1.9.7:test
[INFO] | | +- net.bytebuddy:byte-buddy-agent:jar:1.9.7:test
[INFO] | | \- org.objenesis:objenesis:jar:2.6:test
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | +- org.springframework:spring-core:jar:5.1.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.1.4.RELEASE:compile
[INFO] | +- org.springframework:spring-test:jar:5.1.4.RELEASE:test
[INFO] | \- org.xmlunit:xmlunit-core:jar:2.6.2:test
[INFO] +- org.springframework:spring-context-support:jar:5.1.4.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:5.1.4.RELEASE:compile
[INFO] | \- org.springframework:spring-context:jar:5.1.4.RELEASE:compile
[INFO] +- javax.el:javax.el-api:jar:2.2.4:provided
[INFO] \- org.glassfish.web:javax.el:jar:2.2.4:provided
spring boot 2.1.2 release supports any Servlet 3.1+ compatible container.
Tomcat 7 is not one of them
spring boot docs
Use tomcat 8 or beyond http://tomcat.apache.org/whichversion.html
Spring Boot 2.1 requires a Servlet 3.1 compatible container. Tomcat 7 is a Servlet 3.0 container so you cannot use it with Spring Boot 2.1.
You'll need to upgrade to Tomcat 8.5.x or 9.0.x.
It is because javax/el/ELManager was introduced in el-api 3.0 and tomcat 7 is using el-api 2.2 so this class is not present in it.
Please make sure your dev and prod environment are the same when you are developing.
Or you can add following dependency in your pom.xml
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
</dependency>
I have developed a project using jersey 2 and spring 4,but i had to replace jersey 2 with jersey 1.19,when I did this i am getting an exception called "java.lang.ClassNotFoundException: com.sun.jersey.core.util.FeaturesAndProperties", when running on tomcat server.Is the migration from jersey 2 to jersey 1.19 causing this exception?.Thanks
My web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<!-- Spring Listener -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Jersey Servlet -->
<servlet>
<servlet-name>FITransXT</servlet-name>
<servlet-class>
com.sun.jersey.spi.spring.container.servlet.SpringServlet
</servlet-class>
<!-- Register resources and providers -->
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.mobileware.fitransxt</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FITransXT</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<!-- loading Spring Context for registering beans with ApplicationContext -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/FITransXT-servlet.xml</param-value>
</context-param>
</web-app>
my 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>
<!-- <dependencyManagement>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
</dependencyManagement> -->
<parent>
<groupId>com.mobileware.fitransxt</groupId>
<artifactId>FITransXT</artifactId>
<version>0.0.1</version>
</parent>
<artifactId>FITransXT-Impl</artifactId>
<dependencies>
<dependency>
<groupId>com.mobileware.fitransxt</groupId>
<artifactId>FITransXT-Type</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.mobileware.fitransxt</groupId>
<artifactId>FITransXT-BOImpl</artifactId>
<version>0.0.1</version>
</dependency>
<!-- <dependency>
<groupId>com.mobileware.fitransxt</groupId>
<artifactId>FITransXT-DaoImpl</artifactId>
<version>0.0.1</version>
</dependency> -->
<!-- Jersey core Servlet 2.x implementation -->
<!-- <dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>${jersey.version}</version>
<scope>compile</scope>
</dependency> -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-core -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>${jersey.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-servlet -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>${jersey.version}</version>
</dependency>
<!-- Jersey JSON Jackson (2.x) entity providers support module -->
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.7.3</version>
</dependency>
<!-- Jersey extension module providing support for Spring 3 integration -->
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
<version>${jersey.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-asm</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.ext/jersey-bean-validation -->
<!-- Spring Framework-4.x -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</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-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>4.3.1.RELEASE</spring.version>
<jersey.version>1.19</jersey.version>
<slf4j.version>1.7.2</slf4j.version>
<jdk.source.version>1.8</jdk.source.version>
<jdk.target.version>1.8</jdk.target.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
Dependency Tree
-- maven-dependency-plugin:2.8:tree (default-cli) # FITransXT-Web ---
[INFO] com.mobileware.fitransxt:FITransXT-Web:war:0.0.1
[INFO] +- com.mobileware.fitransxt:FITransXT-Impl:jar:0.0.1:compile
[INFO] | +- com.mobileware.fitransxt:FITransXT-Type:jar:0.0.1:compile
[INFO] | | +- (org.springframework:spring-context:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-context-support:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (com.google.code.gson:gson:jar:2.3.1:compile - omitted for duplicate)
[INFO] | | +- (org.slf4j:slf4j-api:jar:1.7.6:compile - omitted for duplicate)
[INFO] | | +- (org.slf4j:slf4j-log4j12:jar:1.7.5:compile - omitted for duplicate)
[INFO] | | \- (org.json:json:jar:20160810:compile - omitted for duplicate)
[INFO] | +- com.mobileware.fitransxt:FITransXT-BOImpl:jar:0.0.1:compile
[INFO] | | +- com.mobileware.fitransxt:FITransXT-BOIntf:jar:0.0.1:compile
[INFO] | | | +- (com.mobileware.fitransxt:FITransXT-Type:jar:0.0.1:compile - omitted for duplicate)
[INFO] | | | +- (com.google.code.gson:gson:jar:2.3.1:compile - omitted for duplicate)
[INFO] | | | +- (org.slf4j:slf4j-api:jar:1.7.6:compile - omitted for duplicate)
[INFO] | | | +- (org.slf4j:slf4j-log4j12:jar:1.7.5:compile - omitted for duplicate)
[INFO] | | | \- (org.json:json:jar:20160810:compile - omitted for duplicate)
[INFO] | | +- com.mobileware.fitransxt:FITransXT-DaoImpl:jar:0.0.1:compile
[INFO] | | | +- commons-dbcp:commons-dbcp:jar:1.4:compile
[INFO] | | | | \- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] | | | +- com.mobileware.fitransxt:FITransXT-Dao:jar:0.0.1:compile
[INFO] | | | | +- (com.mobileware.fitransxt:FITransXT-Type:jar:0.0.1:compile - omitted for duplicate)
[INFO] | | | | +- mysql:mysql-connector-java:jar:5.1.6:compile
[INFO] | | | | +- org.apache.commons:commons-dbcp2:jar:2.1:compile
[INFO] | | | | | +- org.apache.commons:commons-pool2:jar:2.3:compile
[INFO] | | | | | \- (commons-logging:commons-logging:jar:1.2:compile - omitted for duplicate)
[INFO] | | | | +- (com.google.code.gson:gson:jar:2.3.1:compile - omitted for duplicate)
[INFO] | | | | +- (org.slf4j:slf4j-api:jar:1.7.6:compile - omitted for duplicate)
[INFO] | | | | +- (org.slf4j:slf4j-log4j12:jar:1.7.5:compile - omitted for duplicate)
[INFO] | | | | \- (org.json:json:jar:20160810:compile - omitted for duplicate)
[INFO] | | | +- com.oracle:ojdbc6:jar:11.2.0:compile
[INFO] | | | +- (com.google.code.gson:gson:jar:2.3.1:compile - omitted for duplicate)
[INFO] | | | +- (org.slf4j:slf4j-api:jar:1.7.6:compile - omitted for duplicate)
[INFO] | | | +- (org.slf4j:slf4j-log4j12:jar:1.7.5:compile - omitted for duplicate)
[INFO] | | | \- (org.json:json:jar:20160810:compile - omitted for duplicate)
[INFO] | | +- (org.json:json:jar:20160810:compile - omitted for duplicate)
[INFO] | | +- (log4j:log4j:jar:1.2.14:compile - omitted for conflict with 1.2.17)
[INFO] | | +- org.apache.httpcomponents:httpclient:jar:4.3.4:compile
[INFO] | | | +- org.apache.httpcomponents:httpcore:jar:4.3.2:compile
[INFO] | | | +- (commons-logging:commons-logging:jar:1.1.3:compile - omitted for conflict with 1.2)
[INFO] | | | \- commons-codec:commons-codec:jar:1.6:compile
[INFO] | | +- (com.google.code.gson:gson:jar:2.3.1:compile - omitted for duplicate)
[INFO] | | +- (org.slf4j:slf4j-api:jar:1.7.6:compile - omitted for duplicate)
[INFO] | | \- (org.slf4j:slf4j-log4j12:jar:1.7.5:compile - omitted for duplicate)
[INFO] | +- com.sun.jersey:jersey-server:jar:1.19:compile
[INFO] | | \- (com.sun.jersey:jersey-core:jar:1.19:compile - omitted for duplicate)
[INFO] | +- com.sun.jersey:jersey-core:jar:1.19:compile
[INFO] | | \- javax.ws.rs:jsr311-api:jar:1.1.1:compile
[INFO] | +- com.sun.jersey:jersey-servlet:jar:1.19:compile
[INFO] | | \- (com.sun.jersey:jersey-server:jar:1.19:compile - omitted for duplicate)
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.7.3:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.7.0:compile
[INFO] | | \- (com.fasterxml.jackson.core:jackson-core:jar:2.7.3:compile - omitted for duplicate)
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.7.3:compile
[INFO] | +- com.sun.jersey.contribs:jersey-spring:jar:1.19:compile
[INFO] | | \- (com.sun.jersey:jersey-servlet:jar:1.19:compile - omitted for duplicate)
[INFO] | +- org.springframework:spring-core:jar:4.3.1.RELEASE:compile
[INFO] | | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] | +- org.springframework:spring-context:jar:4.3.1.RELEASE:compile
[INFO] | | +- (org.springframework:spring-aop:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | +- org.springframework:spring-beans:jar:4.3.1.RELEASE:compile
[INFO] | | | \- (org.springframework:spring-core:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-core:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | \- org.springframework:spring-expression:jar:4.3.1.RELEASE:compile
[INFO] | | \- (org.springframework:spring-core:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | +- org.springframework:spring-context-support:jar:4.3.1.RELEASE:compile
[INFO] | | +- (org.springframework:spring-beans:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-context:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | \- (org.springframework:spring-core:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | +- org.springframework:spring-web:jar:4.3.1.RELEASE:compile
[INFO] | | +- (org.springframework:spring-aop:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-beans:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-context:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | \- (org.springframework:spring-core:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | +- org.springframework:spring-aop:jar:4.3.1.RELEASE:compile
[INFO] | | +- (org.springframework:spring-beans:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | \- (org.springframework:spring-core:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | +- org.springframework:spring-webmvc:jar:4.3.1.RELEASE:compile
[INFO] | | +- (org.springframework:spring-aop:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-beans:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-context:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-core:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-expression:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | | \- (org.springframework:spring-web:jar:4.3.1.RELEASE:compile - omitted for duplicate)
[INFO] | +- (com.google.code.gson:gson:jar:2.3.1:compile - omitted for duplicate)
[INFO] | +- (org.slf4j:slf4j-api:jar:1.7.6:compile - omitted for duplicate)
[INFO] | +- (org.slf4j:slf4j-log4j12:jar:1.7.5:compile - omitted for duplicate)
[INFO] | \- (org.json:json:jar:20160810:compile - omitted for duplicate)
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] +- com.google.code.gson:gson:jar:2.3.1:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.6:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.5:compile
[INFO] | +- (org.slf4j:slf4j-api:jar:1.7.5:compile - omitted for conflict with 1.7.6)
[INFO] | \- log4j:log4j:jar:1.2.17:compile
[INFO] \- org.json:json:jar:20160810:compile
Edited:
on console:
java.lang.ClassNotFoundException: com.sun.jersey.core.util.FeaturesAndProperties
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
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:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1141)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
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:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1141)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
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:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1141)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.newInstance(Class.java:412)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1116)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
at org.apache.catalina.startup.Embedded.start(Embedded.java:825)
at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:558)
at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:255)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Ways to handle these kind of problem-
First close your IDE and remove target, .setting and .classpath from your project directory.
1) Double check if you have multiple dependency of same with different version in pom.xml, if yes remove it and run command mvn clean install -U. If it's not work then
2) Find .m2 directory and inside this directory search for lastupdate file and remove all these files and run command mvn clean install -U. If it's not work then
3) Remove .m2 direcory and clean and install maven.
I am using following libraries in my web project:
slf4j-log4j12-1.6.4.jar
slf4j-api-1.6.0.jar
log4j-1.2.16.jar
jcl-over-slf4j-1.6.0.jar
Bu when I assembly war an extra commons-logging-1.0.4.jar library is copied to WEB-INF/lib. I think this is because of one of my libraries which depends on commons-logging-1.0.4.jar.
I want to exclude commons-logging-1.0.4.jar (due to jcl-over-slf4j-1.6.0.jar is already here) using
<dependency>
<groupId></groupId>
<artifactId></artifactId>
<version></version>
<exclusions>
...
</exclusions>
</dependency>
For this purpose I need to find what library in my pom depends on commons-logging.
You can find the dependency tree using mvn dependency:tree command.
From the tree, you can exclude the artifact.
Example output:
[INFO] | +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.20.0:test
[INFO] | | +- org.seleniumhq.selenium:selenium-api:jar:2.20.0:test
[INFO] | | +- net.sourceforge.htmlunit:htmlunit:jar:2.9:test
[INFO] | | | +- xalan:xalan:jar:2.7.1:test
[INFO] | | | | \- xalan:serializer:jar:2.7.1:test
[INFO] | | | +- commons-collections:commons-collections:jar:3.2.1:test
[INFO] | | | +- commons-lang:commons-lang:jar:2.6:test
[INFO] | | | +- org.apache.httpcomponents:httpmime:jar:4.1.2:test
[INFO] | | | +- commons-codec:commons-codec:jar:1.4:test
[INFO] | | | +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.9:test
[INFO] | | | +- xerces:xercesImpl:jar:2.9.1:test
[INFO] | | | | \- xml-apis:xml-apis:jar:1.3.04:test
In case the dependency is transitive, you can do as follow based on the above tree:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.20</version>
</dependency>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.9</version>
<!-- i dont want u -->
<exclusions>
<exclusion>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</exclusion>
</exclusions>
</dependency>
If you're using the WAR overlay feature and the other answer with the dependency tree does not work, please check that the library in question does not come in through one of the WAR files that's overlayed. As part of the overlay, Maven is expanding the overlayed WAR file's WEB-INF/lib folder, basically including everything that's in there in your resulting WAR file.
To exclude some of the files coming in this way, you can use the WAR plugin's dependentWarExcludes feature: http://maven.apache.org/plugins/maven-war-plugin/examples/war-overlay.html