I’m using Java 6, Maven 3.3, JUnit 4.11 and PowerMock 1.6.2. Although I can run my unit tests properly on my local machine, when I run my tests through Jenkins, I get the following errors …
org.mainco.subco.myproject.validator.ResetPasswordValidatorTest Time elapsed: 2.431 sec <<< ERROR!
java.lang.UnsupportedClassVersionError: org/junit/internal/AssumptionViolatedException
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
Here is the output from Maven dependency:tree …
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # myproject ---
[INFO] org.mainco.subco:myproject:war:91.0.0-SNAPSHOT
[INFO] +- log4j:log4j:jar:1.2.15:compile
[INFO] +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.1.Final:provided
[INFO] +- commons-beanutils:commons-beanutils:jar:1.8.3:provided
[INFO] +- javax.servlet:javax.servlet-api:jar:3.0.1:provided
[INFO] +- org.directwebremoting:dwr:jar:3.0.0-rc2:compile
[INFO] +- it.sauronsoftware:cron4j:jar:2.2.5:compile
[INFO] +- org.mainco.subco:orders:jar:91.0.0-SNAPSHOT:compile
[INFO] | +- org.mainco.subco:core:jar:91.0.0-SNAPSHOT:compile
[INFO] | +- com.itextpdf:itextpdf:jar:5.1.0:compile
[INFO] | \- org.springframework:spring-aspects:jar:3.2.11.RELEASE:compile
[INFO] +- javax.validation:validation-api:jar:1.0.0.GA:provided
[INFO] +- commons-lang:commons-lang:jar:2.6:provided
[INFO] +- commons-collections:commons-collections:jar:3.2.1:provided
[INFO] +- commons-codec:commons-codec:jar:1.4:provided
[INFO] +- commons-logging:commons-logging:jar:1.1.1:test
[INFO] +- org.hamcrest:java-hamcrest:jar:2.0.0.0:test
[INFO] +- com.jayway.jsonpath:json-path-assert:jar:0.8.1:compile
[INFO] | +- com.jayway.jsonpath:json-path:jar:0.8.1:compile
[INFO] | +- net.minidev:json-smart:jar:1.1.1:compile
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.2.1:compile
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.2.1:compile
[INFO] +- org.apache.velocity:velocity:jar:1.6.3:provided
[INFO] | \- oro:oro:jar:2.0.8:provided
[INFO] +- javax.mail:mail:jar:1.4.4:provided
[INFO] | \- javax.activation:activation:jar:1.1:provided
[INFO] +- org.powermock:powermock-module-junit4:jar:1.6.2:test
[INFO] | +- junit:junit:jar:4.12:test
[INFO] | \- org.powermock:powermock-module-junit4-common:jar:1.6.2:test
[INFO] | +- org.powermock:powermock-core:jar:1.6.2:test
[INFO] | \- org.powermock:powermock-reflect:jar:1.6.2:test
[INFO] +- org.powermock:powermock-api-easymock:jar:1.6.2:test
[INFO] | \- org.powermock:powermock-api-support:jar:1.6.2:test
[INFO] +- org.easymock:easymock:jar:3.1:test
[INFO] | \- org.objenesis:objenesis:jar:1.2:test
[INFO] +- commons-fileupload:commons-fileupload:jar:1.2.2:compile
[INFO] +- commons-io:commons-io:jar:2.1:provided
[INFO] +- antlr:antlr:jar:2.7.7:provided
[INFO] +- dom4j:dom4j:jar:1.6.1:provided
[INFO] +- org.springframework.boot:spring-boot:jar:1.3.5.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-autoconfigure:jar:1.2.7.RELEASE:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.14:compile
[INFO] +- org.springframework:spring-aop:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-expression:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework.security.oauth:spring-security-oauth2:jar:2.0.7.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc:jar:3.2.11.RELEASE:compile
What dependencies do I need to include/exclude in order to fix the above?
Related
I'm relatively new with Spring tests. I'm triying to test repositories.
After reading different posts about the same issue it seems to be a dependencies problem.
But I haven't found any conflict after checking it (see bellow).
This is the test class:
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration
public class ActionRepositoryTest2 {
#Autowired ActionRepository actionRepository;
#Test
public void actionRepository() {
Command command = new Command();
Action action = new Action();
action.setText("TestAction");
actionRepository.save(action);
List<Action> actions = (List<Action>)
actionRepository.findAll();
assertNotNull(action);
assertEquals(actions.size(),1);
}
#Configuration
public static class InnerConf2 {
#Bean
ActionRepository actionRepository() {
return new ActionRepositoryImpl();
}
#Bean
CommandRepository commandRepository() {
return new CommandRepositoryImpl();
}
#Bean
OrderRepository orderRepository() {
return new OrderRepositoryImpl();
}
}
}
This is the exception I get:
ava.lang.IllegalStateException: Could not load TestContextBootstrapper [null]. Specify #BootstrapWith's 'value' attribute or make the default bootstrapper class available.
at org.springframework.test.context.BootstrapUtils.resolveTestContextBootstrapper(BootstrapUtils.java:144)
...
This is the dependency check:
[INFO]
[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) # emorobots ---
[INFO] Verbose not supported since maven-dependency-plugin 3.0
[INFO] com.res:emorobots:jar:0.0.1-SNAPSHOT
[INFO] +- org.jpl7:jpl:jar:7.8.0:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.slf4j:slf4j-api:jar:1.8.0-beta2:runtime
[INFO] +- org.apache.commons:commons-lang3:jar:3.8.1:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.11.1:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.11.1:runtime
[INFO] +- org.apache.logging.log4j:log4j-jcl:jar:2.11.1:runtime
[INFO] | \- commons-logging:commons-logging:jar:1.2:runtime
[INFO] +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.11.1:runtime
[INFO] +- org.picocontainer:picocontainer:jar:2.15:compile
[INFO] +- javax.inject:javax.inject:jar:1:compile
[INFO] +- javax.annotation:javax.annotation-api:jar:1.3.2:runtime
[INFO] +- org.springframework:spring-core:jar:5.1.2.RELEASE:compile
[INFO] | \- org.springframework:spring-jcl:jar:5.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:5.1.2.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:5.1.2.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:5.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:5.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:5.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-oxm:jar:5.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:5.1.2.RELEASE:compile
[INFO] +- org.springframework.data:spring-data-jpa:jar:1.10.1.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:1.12.1.RELEASE:compile
[INFO] | +- org.springframework:spring-orm:jar:4.2.5.RELEASE:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:4.2.5.RELEASE:compile
[INFO] | +- org.springframework:spring-tx:jar:4.2.5.RELEASE:compile
[INFO] | \- org.aspectj:aspectjrt:jar:1.8.9:compile
[INFO] +- org.eclipse.persistence:javax.persistence:jar:2.1.0:compile
[INFO] +- javax.transaction:javax.transaction-api:jar:1.3:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:5.3.7.Final:compile
[INFO] | +- org.hibernate:hibernate-core:jar:5.3.7.Final:compile
[INFO] | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | +- org.jboss:jandex:jar:2.0.5.Final:compile
[INFO] | | +- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] | | \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] | +- org.dom4j:dom4j:jar:2.1.1:compile
[INFO] | +- org.hibernate.common:hibernate-commons-annotations:jar:5.0.4.Final:compile
[INFO] | +- javax.persistence:javax.persistence-api:jar:2.2:compile
[INFO] | \- net.bytebuddy:byte-buddy:jar:1.8.17:compile
[INFO] +- org.javassist:javassist:jar:3.24.0-GA:compile
[INFO] \- mysql:mysql-connector-java:jar:8.0.13:runtime
[INFO] \- com.google.protobuf:protobuf-java:jar:3.6.1:runtime
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
Is there a way (the last option I consider) to trace SpringJUnit4ClassRunner?
Thanks.
Problem is with the maven dependency. Needs to keep the same spring-core and spring-test version which will solve the issue.
For some reason maven assembly:single throws the error below. But maven-assembly-plugin dependency tree doesn't show the jmxtools. maven central doesn't have the jar file. http://central.maven.org/maven2/com/sun/jdmk/jmxtools/1.2.1/
I am perplexed, what am I missing ? Any help is appreciated.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:3.1.0:single (ci) on project extracense: Failed to create assembly: Error creating assembly archive ci: C:\Users\v493289\.m2\repository\com\sun\jdmk\jmxtools\1.2.1\jmxtools-1.2.1.jar -> [Help 1]
Here is the maven dependency tree.
[INFO] \- org.apache.maven.plugins:maven-assembly-plugin:jar:3.1.0:compile
[INFO] +- org.apache.maven:maven-plugin-api:jar:3.0:compile
[INFO] | \- org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2:compile
[INFO] | \- org.sonatype.sisu:sisu-inject-bean:jar:1.4.2:compile
[INFO] | \- org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7:compile
[INFO] +- org.apache.maven:maven-core:jar:3.0:compile
[INFO] | +- org.apache.maven:maven-settings:jar:3.0:compile
[INFO] | +- org.apache.maven:maven-settings-builder:jar:3.0:compile
[INFO] | +- org.apache.maven:maven-repository-metadata:jar:3.0:compile
[INFO] | +- org.apache.maven:maven-model-builder:jar:3.0:compile
[INFO] | +- org.apache.maven:maven-aether-provider:jar:3.0:runtime
[INFO] | +- org.sonatype.aether:aether-impl:jar:1.7:compile
[INFO] | | \- org.sonatype.aether:aether-spi:jar:1.7:compile
[INFO] | +- org.sonatype.aether:aether-api:jar:1.7:compile
[INFO] | +- org.sonatype.aether:aether-util:jar:1.7:compile
[INFO] | +- org.codehaus.plexus:plexus-classworlds:jar:2.2.3:compile
[INFO] | +- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile
[INFO] | \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile
[INFO] | \- org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[INFO] +- org.apache.maven:maven-artifact:jar:3.0:compile
[INFO] +- org.apache.maven:maven-model:jar:3.0:compile
[INFO] +- org.apache.maven.shared:maven-common-artifact-filters:jar:3.0.1:compile
[INFO] | \- org.apache.maven.shared:maven-shared-utils:jar:3.1.0:compile
[INFO] +- org.apache.maven.shared:maven-artifact-transfer:jar:0.9.0:compile
[INFO] +- org.codehaus.plexus:plexus-interpolation:jar:1.24:compile
[INFO] +- org.codehaus.plexus:plexus-archiver:jar:3.5:compile
[INFO] | +- org.apache.commons:commons-compress:jar:1.14:compile
[INFO] | +- org.iq80.snappy:snappy:jar:0.4:compile
[INFO] | \- org.tukaani:xz:jar:1.6:runtime
[INFO] +- org.apache.maven.shared:file-management:jar:3.0.0:compile
[INFO] +- org.apache.maven.shared:maven-shared-io:jar:3.0.0:compile
[INFO] | +- org.apache.maven:maven-compat:jar:3.0:compile
[INFO] | \- org.apache.maven.wagon:wagon-provider-api:jar:2.10:compile
[INFO] +- org.apache.maven.shared:maven-filtering:jar:3.1.1:compile
[INFO] | \- org.sonatype.plexus:plexus-build-api:jar:0.0.7:compile
[INFO] +- org.codehaus.plexus:plexus-io:jar:3.0.0:compile
[INFO] +- org.apache.maven:maven-archiver:jar:3.2.0:compile
[INFO] \- org.codehaus.plexus:plexus-utils:jar:3.1.0:compile
Collegues, when i run any test i receive the next stack trace:
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found
binding in
[jar:file:/C:/Users/someuser/.m2/repository/org/slf4j/slf4j-simple/1.7.22/slf4j-simple-1.7.22.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in
[jar:file:/C:/Users/someuser/.m2/repository/ch/qos/logback/logback-classic/1.1.9/logback-classic-1.1.9.jar!/org/slf4j/impl/StaticLoggerBinder.class]
My dependency tree looks like:
C:\Users\someuser\Documents\GIT\same-integration\same-ftp>mvn dependency:tree
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten t
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support buildin
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building same :: FTP 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # same-ftp ---
[INFO] com.ac.same:same-ftp:jar:1.0-SNAPSHOT
[INFO] +- org.springframework:spring-context:jar:4.3.5.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.3.5.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.3.5.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:4.3.5.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:4.3.5.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:4.3.5.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:4.3.5.RELEASE:test
[INFO] +- org.springframework:spring-orm:jar:4.3.5.RELEASE:compile
[INFO] | \- org.springframework:spring-jdbc:jar:4.3.5.RELEASE:compile
[INFO] +- org.hibernate:hibernate-core:jar:5.2.6.Final:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Fin
[INFO] | +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] | +- antlr:antlr:jar:2.7.7:compile
[INFO] | +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] | +- org.jboss:jandex:jar:2.0.3.Final:compile
[INFO] | +- com.fasterxml:classmate:jar:1.3.0:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | +- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:
[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
[INFO] | +- javax.annotation:jsr250-api:jar:1.0:compile
[INFO] | \- javax.inject:javax.inject:jar:1:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.9:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.22:compile
[INFO] +- ch.qos.logback:logback-core:jar:1.1.9:compile
[INFO] +- me.moocar:logback-gelf:jar:0.3:compile
[INFO] | +- com.google.code.gson:gson:jar:2.3.1:compile
[INFO] | \- me.moocar:socket-encoder-appender:jar:0.1beta1:compile
[INFO] +- org.slf4j:jul-to-slf4j:jar:1.7.22:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.22:compile
[INFO] +- com.typesafe:config:jar:1.3.0:compile
[INFO] +- commons-io:commons-io:jar:2.2:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.5:compile
[INFO] +- org.apache.camel:camel-core:jar:2.18.1:compile
[INFO] | +- com.sun.xml.bind:jaxb-core:jar:2.2.11:compile
[INFO] | \- com.sun.xml.bind:jaxb-impl:jar:2.2.11:compile
[INFO] +- org.apache.camel:camel-ftp:jar:2.18.1:compile
[INFO] | \- commons-net:commons-net:jar:3.3:compile
[INFO] +- org.apache.camel:camel-spring:jar:2.18.1:compile
[INFO] +- org.apache.camel:camel-quartz2:jar:2.18.1:compile
[INFO] | +- org.quartz-scheduler:quartz:jar:2.2.3:compile
[INFO] | \- com.mchange:c3p0:jar:0.9.5.2:compile
[INFO] | \- com.mchange:mchange-commons-java:jar:0.2.11:compile
[INFO] +- org.apache.camel:camel-jdbc:jar:2.18.1:compile
[INFO] +- com.jcraft:jsch:jar:0.1.42:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- pl.touk:tsc-reload:jar:0.3.0:compile
[INFO] | \- com.javaslang:javaslang:jar:2.0.0-RC3:compile
[INFO] +- commons-collections:commons-collections:jar:3.0:compile
[INFO] +- org.apache.maven.plugins:maven-shade-plugin:jar:2.4.3:compile
[INFO] | +- org.apache.maven:maven-plugin-api:jar:3.0:compile
[INFO] | | \- org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2:compile
[INFO] | | \- org.sonatype.sisu:sisu-inject-bean:jar:1.4.2:compile
[INFO] | | \- org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7:compile
[INFO] | +- org.apache.maven:maven-model:jar:3.0:compile
[INFO] | +- org.apache.maven:maven-core:jar:3.0:compile
[INFO] | | +- org.apache.maven:maven-settings:jar:3.0:compile
[INFO] | | +- org.apache.maven:maven-settings-builder:jar:3.0:compile
[INFO] | | +- org.apache.maven:maven-repository-metadata:jar:3.0:compile
[INFO] | | +- org.apache.maven:maven-model-builder:jar:3.0:compile
[INFO] | | +- org.apache.maven:maven-aether-provider:jar:3.0:runtime
[INFO] | | +- org.sonatype.aether:aether-impl:jar:1.7:compile
[INFO] | | | \- org.sonatype.aether:aether-spi:jar:1.7:compile
[INFO] | | +- org.sonatype.aether:aether-api:jar:1.7:compile
[INFO] | | +- org.sonatype.aether:aether-util:jar:1.7:compile
[INFO] | | +- org.codehaus.plexus:plexus-interpolation:jar:1.14:compile
[INFO] | | +- org.codehaus.plexus:plexus-classworlds:jar:2.2.3:compile
[INFO] | | +- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compi
[INFO] | | \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile
[INFO] | | \- org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[INFO] | +- org.apache.maven:maven-compat:jar:3.0:compile
[INFO] | | \- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-6:compile
[INFO] | +- org.apache.maven:maven-artifact:jar:3.0:compile
[INFO] | +- org.codehaus.plexus:plexus-utils:jar:3.0.22:compile
[INFO] | +- org.ow2.asm:asm:jar:5.0.2:compile
[INFO] | +- org.ow2.asm:asm-commons:jar:5.0.2:compile
[INFO] | | \- org.ow2.asm:asm-tree:jar:5.0.2:compile
[INFO] | +- org.jdom:jdom:jar:1.1:compile
[INFO] | +- org.apache.maven.shared:maven-dependency-tree:jar:2.2:compile
[INFO] | | \- org.eclipse.aether:aether-util:jar:0.9.0.M2:compile
[INFO] | +- org.vafer:jdependency:jar:1.1:compile
[INFO] | | +- org.ow2.asm:asm-analysis:jar:5.0.4:compile
[INFO] | | \- org.ow2.asm:asm-util:jar:5.0.4:compile
[INFO] | \- com.google.guava:guava:jar:11.0.2:compile
[INFO] | \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] +- org.springframework:spring-context-support:jar:4.2.4.RELEASE:compile
[INFO] +- org.thymeleaf:thymeleaf:jar:3.0.2.RELEASE:compile
[INFO] | +- ognl:ognl:jar:3.1.10:compile
[INFO] | +- org.attoparser:attoparser:jar:2.0.1.RELEASE:compile
[INFO] | \- org.unbescape:unbescape:jar:1.1.4.RELEASE:compile
[INFO] +- org.thymeleaf:thymeleaf-spring4:jar:3.0.2.RELEASE:compile
[INFO] +- javax.mail:mail:jar:1.4.7:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] +- org.apache.commons:commons-dbcp2:jar:2.1.1:compile
[INFO] | \- org.apache.commons:commons-pool2:jar:2.4.2:compile
[INFO] \- com.microsoft.sqlserver:sqljdbc4:jar:4.2:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.583 s
[INFO] Finished at: 2017-02-15T13:42:27+03:00
[INFO] Final Memory: 20M/236M
[INFO] ------------------------------------------------------------------------
I'am trying to add any exclusions but it doesn't help.
May you tell me how to fix the ptroblem?
Assuming you want to use logback-classic, you need to exclude the others :
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.6.Final</version>
<exclusions>
<exclusion>
<groupId>me.moocar:logback-gelf</groupId>
<artifactId>me.moocar:logback-gelf</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jul-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>me.moocar:logback-gelf</groupId>
<artifactId>me.moocar:logback-gelf</artifactId>
</exclusion>
</exclusions>
</dependency>
I’m using Maven 3.2.3. In my pom I have this test dependency
<dependency>
<groupId>org.mainco.subco</groupId>
<artifactId>core</artifactId>
<version>${project.parent.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
However, I notice that Maven is bringing in JAR files that the test-jar is dependent on as compile time. Below is an excerpt from
mvn dependency:tree …
[INFO] +- org.mockito:mockito-all:jar:1.9.5:test
[INFO] \- org.mainco.subco:core:test-jar:tests:80.0.0-SNAPSHOT:test
[INFO] +- org.mainco.subco:session:jar:80.0.0-SNAPSHOT:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:1.1.0.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-commons-core:jar:1.3.0.RELEASE:compile
[INFO] | | \- org.slf4j:jcl-over-slf4j:jar:1.6.1:runtime
[INFO] | \- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.3.4:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.3.2:compile
[INFO] | \- commons-codec:commons-codec:jar:1.6:compile
[INFO] +- com.amazonaws:aws-java-sdk:jar:1.8.5:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.1.1:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.1.1:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.1.1:compile
[INFO] | \- joda-time:joda-time:jar:2.8.1:compile (version selected from constraint [2.2,))
How can I suppress Maven from compiling dependencies into my WAR if they were included from a test-scoped dependency?
Edit Per the comment, below is the copmlete output from mvn depdency:tree
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # myproject ---
[INFO] org.mainco.subco:myproject:war:80.0.0-SNAPSHOT
[INFO] +- org.directwebremoting:dwr:jar:3.0.0-rc2:compile
[INFO] +- javax.mail:mail:jar:1.4:provided
[INFO] | \- javax.activation:activation:jar:1.1:provided
[INFO] +- org.mainco.subco:database:jar:80.0.0-SNAPSHOT:test
[INFO] +- org.mainco.subco:orders:jar:80.0.0-SNAPSHOT:compile
[INFO] | +- quickbase:quickbase:jar:1.0:compile
[INFO] | +- org.mainco.subco.sf:enterprise:jar:1.0:compile
[INFO] | +- org.mainco.subco.sf:metadata:jar:1.0:compile
[INFO] | +- org.mainco.subco.sf:partner:jar:1.0:compile
[INFO] | +- com.salesforce:force-wsc-uber:jar:33.0.2:compile
[INFO] | +- org.mainco.subco:core:jar:80.0.0-SNAPSHOT:compile
[INFO] | +- net.sf.opencsv:opencsv:jar:2.3:compile
[INFO] | +- com.itextpdf:itextpdf:jar:5.1.0:compile
[INFO] | +- com.lowagie:itext:jar:2.1.7:compile
[INFO] | | +- bouncycastle:bcmail-jdk14:jar:138:compile
[INFO] | | +- bouncycastle:bcprov-jdk14:jar:138:compile
[INFO] | | \- org.bouncycastle:bctsp-jdk14:jar:1.38:compile
[INFO] | | +- org.bouncycastle:bcprov-jdk14:jar:1.38:compile
[INFO] | | \- org.bouncycastle:bcmail-jdk14:jar:1.38:compile
[INFO] | \- org.springframework:spring-aspects:jar:3.2.11.RELEASE:compile
[INFO] +- org.quartz-scheduler:quartz:jar:1.8.5:compile
[INFO] | +- javax.transaction:jta:jar:1.1:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.6.0:compile
[INFO] +- org.springframework:spring-aop:jar:3.2.11.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-beans:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-expression:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:3.2.11.RELEASE:compile
[INFO] +- org.apache.velocity:velocity:jar:1.6.3:provided
[INFO] +- org.springframework:spring-test:jar:3.2.11.RELEASE:test
[INFO] +- org.springframework:spring-web:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-core:jar: 3.1.4.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:3.1.4.RELEASE:compile
[INFO] +- cglib:cglib-nodep:jar:2.2.2:compile
[INFO] +- taglibs:standard:jar:1.1.2:compile
[INFO] +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.22:test
[INFO] +- junit:junit:jar:4.11:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.3:provided
[INFO] +- org.codehaus.jackson:jackson-core-asl:jar:1.9.3:provided
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.2:provided
[INFO] | \- log4j:log4j:jar:1.2.17:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- org.bouncycastle:bcprov-jdk16:jar:1.46:provided
[INFO] +- org.mockito:mockito-all:jar:1.9.5:test
[INFO] \- org.mainco.subco:core:test-jar:tests:80.0.0-SNAPSHOT:test
[INFO] +- org.mainco.subco:session:jar:80.0.0-SNAPSHOT:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:1.1.0.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-commons-core:jar:1.3.0.RELEASE:compile
[INFO] | | \- org.slf4j:jcl-over-slf4j:jar:1.6.1:runtime
[INFO] | \- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.3.4:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.3.2:compile
[INFO] | \- commons-codec:commons-codec:jar:1.6:compile
[INFO] +- com.amazonaws:aws-java-sdk:jar:1.8.5:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.1.1:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.1.1:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.1.1:compile
[INFO] | \- joda-time:joda-time:jar:2.8.1:compile (version selected from constraint [2.2,))
[INFO] +- com.google.code.gson:gson:jar:2.2.2:compile
[INFO] +- spy:spymemcached:jar:2.8.4:compile
[INFO] +- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- org.jasypt:jasypt:jar:1.9.0:compile
[INFO] +- org.jasypt:jasypt-springsecurity3:jar:1.9.0:compile
[INFO] +- org.jasypt:jasypt-hibernate4:jar:1.9.0:compile
[INFO] +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] +- org.hibernate:hibernate-validator:jar:4.3.0.Final:compile
[INFO] | +- javax.validation:validation-api:jar:1.0.0.GA:compile
[INFO] | \- org.jboss.logging:jboss-logging:jar:3.1.0.CR2:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:4.3.6.Final:compile
[INFO] | +- org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile
[INFO] | +- org.hibernate:hibernate-core:jar:4.3.6.Final:compile
[INFO] | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | \- org.jboss:jandex:jar:1.1.0.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:4.0.5.Final:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.0.Final:compile
[INFO] | \- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] +- org.hibernate:hibernate-ehcache:jar:4.3.6.Final:compile
[INFO] | \- net.sf.ehcache:ehcache-core:jar:2.4.3:compile
[INFO] +- org.springframework:spring-context-support:jar:3.2.11.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-web:jar:3.1.4.RELEASE:compile
[INFO] +- eu.bitwalker:UserAgentUtils:jar:1.15:compile
[INFO] +- net.jeremybrooks:knicker:jar:2.3.3:compile
[INFO] +- net.java.dev.jets3t:jets3t:jar:0.9.0:compile
[INFO] | \- com.jamesmurty.utils:java-xmlbuilder:jar:0.4:compile
[INFO] +- org.apache.poi:poi:jar:3.9:compile
[INFO] +- net.sf.json-lib:json-lib:jar:jdk15:2.4:compile
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.8.0:compile
[INFO] | +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] | \- net.sf.ezmorph:ezmorph:jar:1.0.6:compile
[INFO] +- org.aspectj:aspectjweaver:jar:1.8.2:compile
[INFO] +- org.aspectj:aspectjrt:jar:1.8.2:compile
[INFO] +- org.owasp.esapi:esapi:jar:2.1.0:compile
[INFO] | +- commons-configuration:commons-configuration:jar:1.5:compile
[INFO] | | \- commons-digester:commons-digester:jar:1.8:compile
[INFO] | +- commons-beanutils:commons-beanutils-core:jar:1.7.0:compile
[INFO] | +- commons-fileupload:commons-fileupload:jar:1.2:compile
[INFO] | +- xom:xom:jar:1.2.5:compile
[INFO] | | +- xerces:xercesImpl:jar:2.8.0:compile
[INFO] | | \- xalan:xalan:jar:2.7.0:compile
[INFO] | \- org.beanshell:bsh-core:jar:2.0b4:compile
[INFO] \- org.owasp.antisamy:antisamy:jar:1.5.3:compile
[INFO] +- org.apache.xmlgraphics:batik-css:jar:1.7:compile
[INFO] | +- org.apache.xmlgraphics:batik-ext:jar:1.7:compile
[INFO] | +- org.apache.xmlgraphics:batik-util:jar:1.7:compile
[INFO] | \- xml-apis:xml-apis-ext:jar:1.3.04:compile
[INFO] +- net.sourceforge.nekohtml:nekohtml:jar:1.9.16:compile
[INFO] \- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
I was trying the spring batch word count program and faced a version issue like this :
ERROR [org.springframework.batch.core.step.AbstractStep] - <Encountered an error executing the step>
java.lang.IncompatibleClassChangeError: Found interface org.apache.hadoop.mapreduce.Counter, but class was expected
I use Cloudera Hadoop2 cdh4.5.0 and Spring hadoop version 1.0.1.RELEASE. I cant identify the exact problem as Spring batch is compatible with hadoop cdh4.
My dependency tree is as shown below.
[INFO] org.springframework.data:batch-wordcount:jar:0.0.1
[INFO] +- org.springframework:spring-context:jar:3.0.5.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
[INFO] | +- org.springframework:spring-expression:jar:3.0.5.RELEASE:compile
[INFO] | \- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework:spring-tx:jar:3.0.5.RELEASE:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework.batch:spring-batch-core:jar:2.2.0.RELEASE:compile
[INFO] | +- com.thoughtworks.xstream:xstream:jar:1.3:compile
[INFO] | | \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] | +- org.codehaus.jettison:jettison:jar:1.1:compile
[INFO] +- org.springframework.batch:spring-batch-infrastructure:jar:2.2.0.RELEASE:compile
[INFO] | \- org.springframework.retry:spring-retry:jar:1.0.2.RELEASE:compile
[INFO] +- org.springframework.batch:spring-batch-test:jar:2.2.0.RELEASE:compile
[INFO] | +- (junit:junit:jar:4.10:compile - omitted for conflict with 4.11)
[INFO] | +- (org.springframework:spring-test:jar:3.2.0.RELEASE:compile - omitted for conflict with 3.0.5.RELEASE)
[INFO] | +- commons-io:commons-io:jar:1.4:compile
[INFO] | +- commons-dbcp:commons-dbcp:jar:1.2.2:compile
[INFO] | | \- commons-pool:commons-pool:jar:1.3:compile
[INFO] | \- commons-collections:commons-collections:jar:3.2:compile
[INFO] +- junit:junit:jar:4.11:test (scope not updated to compile)
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.springframework.data:spring-data-hadoop:jar:1.0.2.RELEASE:compile
[INFO] +- org.apache.hadoop:hadoop-common:jar:2.0.0-cdh4.5.0:compile
[INFO] | +- org.apache.hadoop:hadoop-annotations:jar:2.0.0-cdh4.5.0:compile
[INFO] | | \- jdk.tools:jdk.tools:jar:1.6:system
[INFO] | +- com.google.guava:guava:jar:11.0.2:compile
[INFO] | +- commons-net:commons-net:jar:3.1:compile
[INFO] | +- javax.servlet:servlet-api:jar:2.5:compile
[INFO] | +- org.mortbay.jetty:jetty:jar:6.1.26.cloudera.2:compile
[INFO] | +- org.mortbay.jetty:jetty-util:jar:6.1.26.cloudera.2:compile
[INFO] | +- com.sun.jersey:jersey-core:jar:1.8:compile
[INFO] | +- com.sun.jersey:jersey-json:jar:1.8:compile
[INFO] | | +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
[INFO] | | | \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
[INFO] | | | \- javax.activation:activation:jar:1.1:compile
[INFO] | | \- (com.sun.jersey:jersey-core:jar:1.8:compile - omitted for duplicate)
[INFO] | +- log4j:log4j:jar:1.2.17:compile
[INFO] | +- org.apache.hadoop:cloudera-jets3t:jar:2.0.0-cdh4.5.0:compile
[INFO] | | \- (net.java.dev.jets3t:jets3t:jar:0.9.0:compile - omitted for conflict with 0.6.1)
[INFO] | +- net.java.dev.jets3t:jets3t:jar:0.6.1:compile
[INFO] | | +- (commons-codec:commons-codec:jar:1.3:compile - omitted for conflict with 1.4)
[INFO] | | +- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for duplicate)
[INFO] | | \- (commons-httpclient:commons-httpclient:jar:3.1:compile - omitted for duplicate)
[INFO] | +- (junit:junit:jar:4.8.2:compile - omitted for conflict with 4.11)
[INFO] | +- commons-lang:commons-lang:jar:2.5:compile
[INFO] | +- commons-configuration:commons-configuration:jar:1.6:compile
[INFO] | | +- commons-digester:commons-digester:jar:1.8:compile
[INFO] | | | +- commons-beanutils:commons-beanutils:jar:1.7.0:compile
[INFO] | | \- commons-beanutils:commons-beanutils-core:jar:1.8.0:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] | +- org.slf4j:slf4j-log4j12:jar:1.6.1:runtime
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.8.8:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.8.8:compile
[INFO] | +- net.sf.kosmosfs:kfs:jar:0.3:compile
[INFO] | +- com.google.protobuf:protobuf-java:jar:2.4.0a:compile
[INFO] | +- org.apache.hadoop:hadoop-auth:jar:2.0.0-cdh4.5.0:compile
[INFO] | +- com.jcraft:jsch:jar:0.1.42:compile
[INFO] | \- org.apache.zookeeper:zookeeper:jar:3.4.5-cdh4.5.0:compile
[INFO] | \- jline:jline:jar:0.9.94:compile
[INFO] +- org.apache.hadoop:hadoop-hdfs:jar:2.0.0-cdh4.5.0:compile
[INFO] | +- tomcat:jasper-runtime:jar:5.5.23:compile
[INFO] | | \- commons-el:commons-el:jar:1.0:compile
[INFO] +- org.apache.hadoop:hadoop-tools:jar:2.0.0-mr1-cdh4.5.0:compile
[INFO] | +- com.cloudera.cdh:hadoop-ant:pom:2.0.0-mr1-cdh4.5.0:compile
[INFO] | \- org.apache.hadoop:hadoop-core:jar:2.0.0-mr1-cdh4.5.0:compile
[INFO] | +- hsqldb:hsqldb:jar:1.8.0.10:compile
[INFO] | +- org.eclipse.jdt:core:jar:3.1.1:compile
[INFO] +- org.hamcrest:hamcrest-all:jar:1.1:compile
[INFO] +- org.apache.hadoop:hadoop-client:jar:2.0.0-mr1-cdh4.5.0:compile
[INFO] +- org.apache.hadoop:hadoop-streaming:jar:2.0.0-mr1-cdh4.5.0:compile
[INFO] \- org.springframework:spring-test:jar:3.0.5.RELEASE:compile
Also, Does ommited for duplicate dependencies cause any error ?
You should use the 1.0.2.RELEASE-cdh4 version with Cloudera CDH4 - these distro specific releases are available in the Spring repository:
<repository>
<id>spring-releases</id>
<name>Spring Release Repository</name>
<url>http://repo.spring.io/libs-release</url>
</repository>
More info here: https://github.com/spring-projects/spring-hadoop/wiki/Build-with-Cloudera-CDH4