This is what I have in pom.xml:
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
This is what I see after mvn --debug war:war:
[...]
[DEBUG] com.sun.jersey.jersey-test-framework:jersey-test-framework-grizzly:jar:1.4:test
[DEBUG] com.sun.jersey.jersey-test-framework:jersey-test-framework-core:jar:1.4:test
[DEBUG] org.glassfish:javax.servlet:jar:3.0-b66:test
[DEBUG] com.sun.grizzly:grizzly-servlet-webserver:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-http:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-framework:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-rcm:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-portunif:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-http-servlet:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-utils:jar:1.9.18-i:test
[DEBUG] javax.servlet:servlet-api:jar:2.5:compile
[...]
Pay attention to the last line. Why it's not "test", but "compile"?
ps. Indeed it's very weird. This is my complete pom.xml (sorry, it's not short):
[...]
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version> <!-- 10 Sep 2010 -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>1.2.5</version> <!-- 13 Oct 2010 -->
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version> <!-- 9 Oct 2010 -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version> <!-- 9 Oct 2010 -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>1.6.2</version> <!-- 12 Oct 2010 -->
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version> <!-- 2 Nov 2010 -->
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<!-- version see below in dependencyManagement section -->
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<!-- version see below in dependencyManagement section -->
</dependency>
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly</artifactId>
<!-- version see below in dependencyManagement section -->
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<!-- version see below in dependencyManagement section -->
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-ejbd</artifactId>
<!-- version see below in dependencyManagement section -->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<!-- version see below in dependencyManagement section -->
</dependency>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<!-- version see below in dependencyManagement section -->
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version> <!-- 9 Oct 2010 -->
<scope>provided</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-ejbd</artifactId>
<version>3.1.3</version> <!-- 26 October 2010 -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.4.2</version> <!-- 29 oct 2010 -->
</dependency>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.10</version> <!-- 12 October 2010 -->
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
[...]
This is how maven-war-plugin is configured:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
<configuration>
<archive>
<manifestEntries>
<SCM-Revision>${buildNumber}</SCM-Revision>
</manifestEntries>
</archive>
</configuration>
</plugin>
This is very very weird, I don't get the same output when running mvn with --debug:
$ mvn --debug compile
...
[DEBUG] com.sun.jersey.jersey-test-framework:jersey-test-framework-grizzly:jar:1.4:test
[DEBUG] com.sun.jersey.jersey-test-framework:jersey-test-framework-core:jar:1.4:test
[DEBUG] com.sun.jersey:jersey-server:jar:1.4:test
[DEBUG] com.sun.jersey:jersey-core:jar:1.4:test
[DEBUG] asm:asm:jar:3.1:test
[DEBUG] com.sun.jersey:jersey-client:jar:1.4:test
[DEBUG] org.glassfish:javax.servlet:jar:3.0-b66:test
[DEBUG] com.sun.grizzly:grizzly-servlet-webserver:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-http:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-framework:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-rcm:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-portunif:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-http-servlet:jar:1.9.18-i:test
[DEBUG] com.sun.grizzly:grizzly-utils:jar:1.9.18-i:test
[DEBUG] javax.servlet:servlet-api:jar:2.5:test
...
Which is coherent with the dependency:tree:
$ mvn dependency:tree
[INFO] Scanning for projects...
...
[INFO] \- com.sun.jersey.jersey-test-framework:jersey-test-framework-grizzly:jar:1.4:test
[INFO] +- com.sun.jersey.jersey-test-framework:jersey-test-framework-core:jar:1.4:test
[INFO] | +- com.sun.jersey:jersey-server:jar:1.4:test
[INFO] | | +- com.sun.jersey:jersey-core:jar:1.4:test
[INFO] | | \- asm:asm:jar:3.1:test
[INFO] | +- com.sun.jersey:jersey-client:jar:1.4:test
[INFO] | \- org.glassfish:javax.servlet:jar:3.0-b66:test
[INFO] \- com.sun.grizzly:grizzly-servlet-webserver:jar:1.9.18-i:test
[INFO] +- com.sun.grizzly:grizzly-http:jar:1.9.18-i:test
[INFO] | +- com.sun.grizzly:grizzly-framework:jar:1.9.18-i:test
[INFO] | +- com.sun.grizzly:grizzly-rcm:jar:1.9.18-i:test
[INFO] | \- com.sun.grizzly:grizzly-portunif:jar:1.9.18-i:test
[INFO] +- com.sun.grizzly:grizzly-http-servlet:jar:1.9.18-i:test
[INFO] | \- com.sun.grizzly:grizzly-utils:jar:1.9.18-i:test
[INFO] \- javax.servlet:servlet-api:jar:2.5:test
...
The servlet-api artifact has a test scope as expected.
Do you have the servlet-api declared as dependency with a compile scope somewhere? That's the only way I could reproduce.
Update: I reproduced the output with mvn --debug after pasting all dependencies your provided. That said, I don't know how to interpret this output which is printed when the maven-compiler-plugin is executed. Also note that it differs from the dependency:tree:
$ mvn dependency:tree
[INFO] Scanning for projects...
...
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) # Q4098082 ---
[INFO] com.stackoverflow:Q4098082:jar:1.0-SNAPSHOT
[INFO] +- junit:junit:jar:4.7:test
[INFO] +- xom:xom:jar:1.2.5:compile
[INFO] | +- xml-apis:xml-apis:jar:1.3.03:compile
[INFO] | +- xerces:xercesImpl:jar:2.8.0:compile
[INFO] | \- xalan:xalan:jar:2.7.0:compile
[INFO] +- org.mockito:mockito-all:jar:1.8.5:test
[INFO] +- org.apache.commons:commons-io:jar:1.3.2:test
[INFO] +- joda-time:joda-time:jar:1.6.2:compile
[INFO] +- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] | +- commons-logging:commons-logging:jar:1.0.4:compile
[INFO] | \- commons-codec:commons-codec:jar:1.2:compile
[INFO] +- com.sun.jersey:jersey-server:jar:1.4:compile
[INFO] | +- com.sun.jersey:jersey-core:jar:1.4:compile
[INFO] | \- asm:asm:jar:3.1:compile
[INFO] +- com.sun.jersey:jersey-client:jar:1.4:test
[INFO] +- com.sun.jersey.jersey-test-framework:jersey-test-framework-grizzly:jar:1.4:test
[INFO] | +- com.sun.jersey.jersey-test-framework:jersey-test-framework-core:jar:1.4:test
[INFO] | | \- org.glassfish:javax.servlet:jar:3.0-b66:test
[INFO] | \- com.sun.grizzly:grizzly-servlet-webserver:jar:1.9.18-i:test
[INFO] | +- com.sun.grizzly:grizzly-http:jar:1.9.18-i:test
[INFO] | | +- com.sun.grizzly:grizzly-framework:jar:1.9.18-i:test
[INFO] | | +- com.sun.grizzly:grizzly-rcm:jar:1.9.18-i:test
[INFO] | | \- com.sun.grizzly:grizzly-portunif:jar:1.9.18-i:test
[INFO] | +- com.sun.grizzly:grizzly-http-servlet:jar:1.9.18-i:test
[INFO] | | \- com.sun.grizzly:grizzly-utils:jar:1.9.18-i:test
[INFO] | \- javax.servlet:servlet-api:jar:2.5:test
[INFO] +- org.hibernate:hibernate-entitymanager:jar:3.5.6-Final:compile
[INFO] | +- org.hibernate:hibernate-core:jar:3.5.6-Final:compile
[INFO] | | +- antlr:antlr:jar:2.7.6:compile
[INFO] | | +- commons-collections:commons-collections:jar:3.1:compile
[INFO] | | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | \- javax.transaction:jta:jar:1.1:compile
[INFO] | +- org.hibernate:hibernate-annotations:jar:3.5.6-Final:compile
[INFO] | | \- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
[INFO] | +- cglib:cglib:jar:2.2:compile
[INFO] | +- javassist:javassist:jar:3.9.0.GA:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.5.8:compile
[INFO] +- org.apache.openejb:openejb-ejbd:jar:3.1.3:test
[INFO] | +- org.apache.openejb:javaee-api:jar:5.0-3:test
[INFO] | +- org.apache.openejb:openejb-core:jar:3.1.3:test
[INFO] | | +- log4j:log4j:jar:1.2.12:test
[INFO] | | +- org.apache.openejb:ejb31-api-experimental:jar:3.1.3:test
[INFO] | | +- org.apache.openejb:openejb-api:jar:3.1.3:test
[INFO] | | +- org.apache.openejb:openejb-javaagent:jar:3.1.3:test
[INFO] | | +- org.apache.openejb:openejb-jee:jar:3.1.3:test
[INFO] | | | +- org.codehaus.woodstox:wstx-asl:jar:3.2.0:test
[INFO] | | | | \- stax:stax-api:jar:1.0.1:test
[INFO] | | | \- com.sun.xml.bind:jaxb-impl:jar:2.1.9:test
[INFO] | | +- commons-cli:commons-cli:jar:1.1:test
[INFO] | | +- org.apache.activemq:activemq-ra:jar:5.3.1:test
[INFO] | | +- org.apache.activemq:activemq-core:jar:5.3.1:test
[INFO] | | | +- commons-logging:commons-logging-api:jar:1.1:test
[INFO] | | | +- org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.1.1:test
[INFO] | | | +- org.apache.activemq:activeio-core:jar:3.1.2:test
[INFO] | | | | \- org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec:jar:1.0.1:test
[INFO] | | | +- org.apache.activemq:kahadb:jar:5.3.1:test
[INFO] | | | +- org.apache.activemq.protobuf:activemq-protobuf:jar:1.0:test
[INFO] | | | +- org.apache.geronimo.specs:geronimo-j2ee-management_1.0_spec:jar:1.0:test
[INFO] | | | \- commons-net:commons-net:jar:2.0:test
[INFO] | | +- org.apache.openjpa:openjpa:jar:1.2.1:test
[INFO] | | | +- net.sourceforge.serp:serp:jar:1.13.1:test
[INFO] | | | +- commons-lang:commons-lang:jar:2.1:test
[INFO] | | | \- commons-pool:commons-pool:jar:1.3:test
[INFO] | | +- org.apache.geronimo.components:geronimo-connector:jar:2.1:test
[INFO] | | +- org.apache.geronimo.components:geronimo-transaction:jar:2.1:test
[INFO] | | +- org.objectweb.howl:howl:jar:1.0.1-1:test
[INFO] | | +- org.apache.geronimo.javamail:geronimo-javamail_1.4_mail:jar:1.2:test
[INFO] | | +- org.apache.xbean:xbean-asm-shaded:jar:3.7:test
[INFO] | | +- org.apache.xbean:xbean-finder-shaded:jar:3.7:test
[INFO] | | +- org.apache.xbean:xbean-reflect:jar:3.7:test
[INFO] | | +- org.apache.xbean:xbean-naming:jar:3.7:test
[INFO] | | +- org.apache.openejb:commons-dbcp-all:jar:1.3-r699049:test
[INFO] | | +- org.codehaus.swizzle:swizzle-stream:jar:1.0.1:test
[INFO] | | +- wsdl4j:wsdl4j:jar:1.6.1:test
[INFO] | | \- quartz:quartz:jar:1.5.2:test
[INFO] | +- org.apache.openejb:openejb-server:jar:3.1.3:test
[INFO] | +- org.apache.openejb:openejb-loader:jar:3.1.3:test
[INFO] | \- org.apache.openejb:openejb-client:jar:3.1.3:test
[INFO] +- org.slf4j:slf4j-jdk14:jar:1.4.2:compile
[INFO] +- hsqldb:hsqldb:jar:1.8.0.10:test
[INFO] \- javax:javaee-api:jar:6.0:provided
...
The above is my reference to analyze the scope of dependencies and it looks correct. I don't know why the maven-compiler-plugin outputs a different result in debug mode, I don't know if this is expected, I never pay attention to the output.
Additional remark, the javax.servlet:servlet-api:jar:2.5 is on the (huge) test classpath during the compiler:testCompile execution.
So while I don't have a full explanation, I can't spot any side effect.
This is what I've done to solve the problem:
[...]
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
[...]
Related
Hi im trying to run a test with cucumber, but when i try to run anytest, with IntellJ, show me this error:
Exception in thread "main" java.util.NoSuchElementException
at java.base/java.util.ArrayList$Itr.next(ArrayList.java:1000)
at java.base/java.util.Collections.max(Collections.java:713)
at io.cucumber.core.feature.FeatureParser.parseResource(FeatureParser.java:46)
at java.base/java.util.function.BiFunction.lambda$andThen$0(BiFunction.java:70)
my POM:
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>messages</artifactId>
<version>21.0.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>${cucumber.version}</version>
<exclusions>
<exclusion>
<groupId>io.cucumber</groupId>
<artifactId>messages</artifactId>
</exclusion>
<exclusion>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-gherkin-messages</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<exclusions>
<exclusion>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
</exclusion>
<exclusion>
<groupId>io.cucumber</groupId>
<artifactId>messages</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<artifactId>cucumber-java</artifactId>
<groupId>io.cucumber</groupId>
<exclusions>
<exclusion>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-gherkin</artifactId>
</exclusion>
<exclusion>
<groupId>io.cucumber</groupId>
<artifactId>messages</artifactId>
</exclusion>
</exclusions>
<version>${cucumber.version}</version>
</dependency>
If anyone can help me, i really appreciate it
Your dependencies are inconsistent. You are explicitly excluding transitive dependencies of Cucumber and explicitly including others. You shouldn't do that, Cucumber needs those to function.
I would strongly urge you to invest time in learning how to use Maven (or Gradle) beyond a superficial level. Understanding these tools and the concepts involved can make your life much easier.
For example:
If you want to use Cucumber with JUnit 5 and annotation based step definitions you would declare this minimal set of dependencies in a Maven pom.xml file.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.9.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-bom</artifactId>
<version>7.10.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
By telling Maven what your dependencies are Maven can calculate your transitive dependencies i.e: the dependencies of your dependencies.
This has many advantages. One example would be using the mvn dependency:tree -Dverbose command to will list all dependencies and their transitive dependencies.
$ mvn dependency:tree -Dverbose
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< cucumber:cucumber-java-skeleton >-------------------
[INFO] Building Cucumber-Java Skeleton 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # cucumber-java-skeleton ---
[INFO] cucumber:cucumber-java-skeleton:jar:0.0.1
[INFO] +- io.cucumber:cucumber-java:jar:7.10.1:test
[INFO] | +- io.cucumber:cucumber-core:jar:7.10.1:test
[INFO] | | +- io.cucumber:cucumber-gherkin:jar:7.10.1:test
[INFO] | | | \- (io.cucumber:cucumber-plugin:jar:7.10.1:test - omitted for duplicate)
[INFO] | | +- io.cucumber:cucumber-gherkin-messages:jar:7.10.1:test
[INFO] | | | +- io.cucumber:gherkin:jar:25.0.2:test
[INFO] | | | | \- (io.cucumber:messages:jar:19.1.4:test - omitted for duplicate)
[INFO] | | | \- (io.cucumber:cucumber-gherkin:jar:7.10.1:test - omitted for duplicate)
[INFO] | | +- io.cucumber:messages:jar:19.1.4:test
[INFO] | | +- io.cucumber:tag-expressions:jar:4.1.0:test
[INFO] | | +- io.cucumber:cucumber-expressions:jar:16.1.1:test
[INFO] | | | \- (org.apiguardian:apiguardian-api:jar:1.1.2:test - omitted for duplicate)
[INFO] | | +- io.cucumber:datatable:jar:7.10.1:test
[INFO] | | | \- (org.apiguardian:apiguardian-api:jar:1.1.2:test - omitted for duplicate)
[INFO] | | +- io.cucumber:cucumber-plugin:jar:7.10.1:test
[INFO] | | | \- (org.apiguardian:apiguardian-api:jar:1.1.2:test - omitted for duplicate)
[INFO] | | +- io.cucumber:docstring:jar:7.10.1:test
[INFO] | | | \- (org.apiguardian:apiguardian-api:jar:1.1.2:test - omitted for duplicate)
[INFO] | | +- io.cucumber:html-formatter:jar:20.2.0:test
[INFO] | | | \- (io.cucumber:messages:jar:19.1.4:test - omitted for duplicate)
[INFO] | | +- io.cucumber:ci-environment:jar:9.1.0:test
[INFO] | | \- (org.apiguardian:apiguardian-api:jar:1.1.2:test - omitted for duplicate)
[INFO] | \- org.apiguardian:apiguardian-api:jar:1.1.2:test
[INFO] +- io.cucumber:cucumber-junit-platform-engine:jar:7.10.1:test
[INFO] | +- (io.cucumber:cucumber-core:jar:7.10.1:test - omitted for duplicate)
[INFO] | \- org.junit.platform:junit-platform-engine:jar:1.9.1:test
[INFO] | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | +- org.junit.platform:junit-platform-commons:jar:1.9.1:test
[INFO] | | \- (org.apiguardian:apiguardian-api:jar:1.1.2:test - omitted for duplicate)
[INFO] | \- (org.apiguardian:apiguardian-api:jar:1.1.2:test - omitted for duplicate)
[INFO] +- org.junit.platform:junit-platform-suite:jar:1.9.1:test
[INFO] | +- org.junit.platform:junit-platform-suite-api:jar:1.9.1:test
[INFO] | | +- (org.junit.platform:junit-platform-commons:jar:1.9.1:test - omitted for duplicate)
[INFO] | | \- (org.apiguardian:apiguardian-api:jar:1.1.2:test - omitted for duplicate)
[INFO] | \- org.junit.platform:junit-platform-suite-engine:jar:1.9.1:test
[INFO] | +- (org.junit.platform:junit-platform-engine:jar:1.9.1:test - omitted for duplicate)
[INFO] | +- (org.junit.platform:junit-platform-suite-api:jar:1.9.1:test - omitted for duplicate)
[INFO] | +- (org.apiguardian:apiguardian-api:jar:1.1.2:test - omitted for duplicate)
[INFO] | \- org.junit.platform:junit-platform-suite-commons:jar:1.9.1:test
[INFO] | +- org.junit.platform:junit-platform-launcher:jar:1.9.1:test
[INFO] | | +- (org.junit.platform:junit-platform-engine:jar:1.9.1:test - omitted for duplicate)
[INFO] | | \- (org.apiguardian:apiguardian-api:jar:1.1.2:test - omitted for duplicate)
[INFO] | +- (org.apiguardian:apiguardian-api:jar:1.1.2:test - omitted for duplicate)
[INFO] | +- (org.junit.platform:junit-platform-engine:jar:1.9.1:test - omitted for duplicate)
[INFO] | \- (org.junit.platform:junit-platform-suite-api:jar:1.9.1:test - omitted for duplicate)
[INFO] \- org.junit.jupiter:junit-jupiter:jar:5.9.1:test
[INFO] +- org.junit.jupiter:junit-jupiter-api:jar:5.9.1:test
[INFO] | +- (org.opentest4j:opentest4j:jar:1.2.0:test - omitted for duplicate)
[INFO] | +- (org.junit.platform:junit-platform-commons:jar:1.9.1:test - omitted for duplicate)
[INFO] | \- (org.apiguardian:apiguardian-api:jar:1.1.2:test - omitted for duplicate)
[INFO] +- org.junit.jupiter:junit-jupiter-params:jar:5.9.1:test
[INFO] | +- (org.junit.jupiter:junit-jupiter-api:jar:5.9.1:test - omitted for duplicate)
[INFO] | \- (org.apiguardian:apiguardian-api:jar:1.1.2:test - omitted for duplicate)
[INFO] \- org.junit.jupiter:junit-jupiter-engine:jar:5.9.1:test
[INFO] +- (org.junit.platform:junit-platform-engine:jar:1.9.1:test - omitted for duplicate)
[INFO] +- (org.junit.jupiter:junit-jupiter-api:jar:5.9.1:test - omitted for duplicate)
[INFO] \- (org.apiguardian:apiguardian-api:jar:1.1.2:test - omitted for duplicate)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.933 s
[INFO] Finished at: 2022-12-28T16:33:23+01:00
[INFO] ------------------------------------------------------------------------
Note: If you see a transitive dependency listed as "omitted for duplicate" and you have also included it in your pom.xml, this inclusion isn't needed. Maven will download it for you.
Also if you are looking to make a fresh start, you could also use the cucumber-java-skeleton to start with a working project.
I have an existing SpringBoot Application that was running with no issue. I then created a Java library—a standalone repository with only static Java code, no main class. My library is deployed as a GitHub Maven package.
I then proceeded with setting up my GitHub packages repository in my local Maven settings and added the dependency to my original SpringBoot application. The import process is successful, my library's Jar is in the classpath and compilation and build are successful.
What happens next is I run the application now, and I get the following stacktrace:
02:36:51.110 [main] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [<redacted list of classpath dependencies, including my new library>]
02:36:51.223 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:161)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:102)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:68)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:80)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at my.org.transfer.TransferServicesApiApplication.main(TransferServicesApiApplication.java:18)
Process finished with exit code 1
I'm not sure what else to try and a night of Googling lead me nowhere.
This is my application's 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 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.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>my.org</groupId>
<artifactId>appname</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency> <!-- my library import -->
<groupId>my.org</groupId>
<artifactId>mylibrary</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.6</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>19.0.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.2.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-booter</artifactId>
<version>2.22.2</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<goalPrefix>formatter</goalPrefix>
<executable>true</executable>
</configuration>
</plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.12.0</version>
</plugin>
</plugins>
</build>
</project>
My library's 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 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.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>my.org</groupId>
<artifactId>mylibrary</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
</properties>
<distributionManagement>
<repository>
<id>github</id>
<name>Github Packages</name>
<url>https://maven.pkg.github.com/my-org/library-repo</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-secretsmanager</artifactId>
<version>1.11.793</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>20.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-aws-secrets-manager-config</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.10</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<version>2.0.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>2.0.7</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.12.0</version>
</plugin>
</plugins>
</build>
</project>
Thanks much.
Edit: set spring-boot-starter-parent version in application pom to match the version in the library pom. No changes.
Edit 2: This is the output of mvn dependency:tree (my library-injected dependency at the bottom):
[INFO] my.org.hopscotchtrading:transfer-services-api:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter:jar:2.3.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:2.3.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-context:jar:5.2.9.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.3.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-logging:jar:2.3.4.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.13.3:compile
[INFO] | | | \- org.apache.logging.log4j:log4j-api:jar:2.13.3:compile
[INFO] | | \- org.slf4j:jul-to-slf4j:jar:1.7.30:compile
[INFO] | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] | +- org.springframework:spring-core:jar:5.2.9.RELEASE:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.2.9.RELEASE:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.26:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.3.4.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.3.4.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.3.4.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] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:test
[INFO] | | \- jakarta.activation:jakarta.activation-api:jar:1.2.2:test
[INFO] | +- org.assertj:assertj-core:jar:3.16.1:test
[INFO] | +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] | +- org.junit.jupiter:junit-jupiter:jar:5.6.2:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-api:jar:5.6.2:test
[INFO] | | | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | | | \- org.junit.platform:junit-platform-commons:jar:1.6.2:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-params:jar:5.6.2:test
[INFO] | | \- org.junit.jupiter:junit-jupiter-engine:jar:5.6.2:test
[INFO] | +- org.junit.vintage:junit-vintage-engine:jar:5.6.2:test
[INFO] | | +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] | | +- org.junit.platform:junit-platform-engine:jar:1.6.2:test
[INFO] | | \- junit:junit:jar:4.13:test
[INFO] | +- org.mockito:mockito-core:jar:3.3.3:test
[INFO] | | +- net.bytebuddy:byte-buddy:jar:1.10.14:compile
[INFO] | | +- net.bytebuddy:byte-buddy-agent:jar:1.10.14:test
[INFO] | | \- org.objenesis:objenesis:jar:2.6:test
[INFO] | +- org.mockito:mockito-junit-jupiter:jar:3.3.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-test:jar:5.2.9.RELEASE:test
[INFO] | \- org.xmlunit:xmlunit-core:jar:2.7.0:test
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.3.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.3.4.RELEASE:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.11.2:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.11.2:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.11.2:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.3.4.RELEASE:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.38:compile
[INFO] | | +- org.glassfish:jakarta.el:jar:3.0.3:compile
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.38:compile
[INFO] | \- org.springframework:spring-webmvc:jar:5.2.9.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:5.2.9.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:5.2.9.RELEASE:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.12:compile
[INFO] +- io.jsonwebtoken:jjwt:jar:0.9.1:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-databind:jar:2.11.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.2:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.11.2:compile
[INFO] +- joda-time:joda-time:jar:2.10.6:compile
[INFO] +- org.jetbrains:annotations:jar:19.0.0:compile
[INFO] +- commons-io:commons-io:jar:2.7:compile
[INFO] +- commons-codec:commons-codec:jar:1.14:compile
[INFO] +- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- commons-lang:commons-lang:jar:2.4:compile
[INFO] +- org.springframework:spring-web:jar:5.2.7.RELEASE:compile
[INFO] | \- org.springframework:spring-beans:jar:5.2.9.RELEASE:compile
[INFO] +- org.apache.maven.surefire:surefire-booter:jar:2.22.2:compile
[INFO] | \- org.apache.maven.surefire:surefire-api:jar:2.22.2:compile
[INFO] | \- org.apache.maven.surefire:surefire-logger-api:jar:2.22.2:compile
[INFO] +- commons-beanutils:commons-beanutils:jar:1.9.4:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] +- io.springfox:springfox-swagger2:jar:2.9.2:compile
[INFO] | +- io.swagger:swagger-annotations:jar:1.5.20:compile
[INFO] | +- io.swagger:swagger-models:jar:1.5.20:compile
[INFO] | +- io.springfox:springfox-spi:jar:2.9.2:compile
[INFO] | | \- io.springfox:springfox-core:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-schema:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-swagger-common:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-spring-web:jar:2.9.2:compile
[INFO] | +- com.google.guava:guava:jar:20.0:compile
[INFO] | +- com.fasterxml:classmate:jar:1.5.1:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] | +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO] | +- org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
[INFO] | \- org.mapstruct:mapstruct:jar:1.2.0.Final:compile
[INFO] +- io.springfox:springfox-swagger-ui:jar:2.9.2:compile
[INFO] +- org.influxdb:influxdb-java:jar:2.18:compile
[INFO] | +- com.squareup.retrofit2:retrofit:jar:2.8.1:compile
[INFO] | +- com.squareup.retrofit2:converter-moshi:jar:2.8.1:compile
[INFO] | | \- com.squareup.moshi:moshi:jar:1.8.0:compile
[INFO] | +- org.msgpack:msgpack-core:jar:0.8.20:compile
[INFO] | +- com.squareup.okhttp3:okhttp:jar:3.14.9:compile
[INFO] | | \- com.squareup.okio:okio:jar:1.17.2:compile
[INFO] | \- com.squareup.okhttp3:logging-interceptor:jar:3.14.9:compile
[INFO] \- my.org:mylibrary:jar:0.0.1-SNAPSHOT:compile
[INFO] +- com.amazonaws:aws-java-sdk-secretsmanager:jar:1.11.793:compile
[INFO] | +- com.amazonaws:aws-java-sdk-core:jar:1.11.793:compile
[INFO] | | +- org.apache.httpcomponents:httpclient:jar:4.5.12:compile
[INFO] | | | \- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] | | +- software.amazon.ion:ion-java:jar:1.0.2:compile
[INFO] | | \- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.11.2:compile
[INFO] | \- com.amazonaws:jmespath-java:jar:1.11.793:compile
[INFO] +- org.apache.commons:commons-collections4:jar:4.4:compile
[INFO] +- org.springframework.cloud:spring-cloud-aws-secrets-manager-config:jar:2.1.1.RELEASE:compile
[INFO] | \- org.springframework.cloud:spring-cloud-context:jar:1.3.2.RELEASE:compile
[INFO] | \- org.springframework.security:spring-security-crypto:jar:5.3.4.RELEASE:compile
[INFO] \- org.apache.commons:commons-lang3:jar:3.10:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.147 s
[INFO] Finished at: 2020-09-19T13:06:54-05:00
[INFO] ------------------------------------------------------------------------
You're using different versions of spring-boot-starter-parent (2.3.1.RELEASE and 2.3.4.RELEASE) which is probably leading to inconsistent versions where the later or earlier don't have the method. Try using 2.3.4.RELEASE in your application.
[Update]
You're still getting inconsistent versions of org.springframework:* on the classpath:
[INFO] | \- org.springframework:spring-webmvc:jar:5.2.9.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:5.2.9.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:5.2.9.RELEASE:compile
...
[INFO] +- org.springframework:spring-web:jar:5.2.7.RELEASE:compile
In your application pom.xml remove the explicit dependency from
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.2.7.RELEASE</version>
</dependency>
and any other dependency that is specified in the parent so you get all 5.2.9 versions in the dependency output.
Finally, there is discussion like here about requiring specific versions for Spring Boot and the latest version of spring-cloud-aws-secrets-manager-config is 2.2.4.RELEASE which makes me think your library's POM needs to be updated to use the latest.
I'm trying to migrate existing Spring project to Spring Boot.
In project already used Spring Data JPA/Hibernate and simple DAO with JDBC (PostgreSQL used).
In few states I found that all that I need to migrate on Spring boot, is:
Add necessary dependencies
Add entry point #SpringBootApplication
profit, that's all.
1) Dependencies:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.4</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
With dependencyManagment section I have error:
Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)Ljava/util/Optional;
at org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension.postProcess(JpaRepositoryConfigExtension.java:125)
at org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:127)
at org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport.registerBeanDefinitions(RepositoryBeanDefinitionRegistrarSupport.java:83)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:359)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:143)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:320)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:272)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:92)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at ru.testproject.BootConfiguration.main(BootConfiguration.java:26)
And without it:
Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is java.lang.NoClassDefFoundError: org/eclipse/jetty/util/DeprecationWarning
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at ru.testproject.BootConfiguration.main(BootConfiguration.java:26)
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jetty/util/DeprecationWarning
at org.eclipse.jetty.servlet.ServletContextHandler.<init>(ServletContextHandler.java:159)
at org.eclipse.jetty.webapp.WebAppContext.<init>(WebAppContext.java:289)
at org.eclipse.jetty.webapp.WebAppContext.<init>(WebAppContext.java:211)
at org.springframework.boot.context.embedded.jetty.JettyEmbeddedWebAppContext.<init>(JettyEmbeddedWebAppContext.java:28)
at org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory.getEmbeddedServletContainer(JettyEmbeddedServletContainerFactory.java:170)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134)
... 8 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.util.DeprecationWarning
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
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)
2) entry point (I'm also tried to Import configuration classes, commented):
#SpringBootApplication
//#Import({DatabaseConfig.class, WebMvcConfig.class, WebAppConfig.class, WebSecurityConfig.class, WebServiceConfig.class})
public class BootConfiguration extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(BootConfiguration.class, args);
// SpringApplication.run(new Class<?>[] {BootConfiguration.class, DatabaseConfig.class, WebMvcConfig.class, WebAppConfig.class, WebSecurityConfig.class, WebServiceConfig.class}, args);
}
#Bean
public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory() {
JettyEmbeddedServletContainerFactory jettyContainer =
new JettyEmbeddedServletContainerFactory();
jettyContainer.setPort(9000);
jettyContainer.setContextPath("");
return jettyContainer;
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(BootConfiguration.class);
}
}
And configuration:
#Configuration
#EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
#EnableJpaRepositories(basePackages = {
"ru.testproject.hibernate"
})
#EnableTransactionManagement
#PropertySource("classpath:application.properties")
public class DatabaseConfig implements TransactionManagementConfigurer {
#Bean
public DataSource dataSource() {
if (DB_TYPE_POSTGRESQL.equalsIgnoreCase(dbType)) {
return postresqlDataSource();
} else {
return h2DataSource();
}
}
#Bean
public PlatformTransactionManager annotationDrivenTransactionManager() {
return new JpaTransactionManager();
}
}
I have no idea what I'm doing wrong. What do I need to do to start spring boot application with existing Jetty server configuration?
UPDATE
I've modified the main pom:
<parent>
<groupId>ru.testproject</groupId>
<artifactId>test</artifactId>
<version>1.0.1</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
<!-- <version>${spring.boot.version}</version> -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate-version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate-version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Version 5.0.4 because ${spring.version} context fails with CandidateComponentsIndexLoader error (it introduced in 5.0.0 version) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<!-- Jetty embedded -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
also, I've commented all tags for spring boot dependencies.
mvc dependency:tree give the following output:
[INFO] --- maven-dependency-plugin:3.0.2:tree (default-cli) # test ---
[WARNING] The artifact org.hibernate:hibernate-infinispan:jar:5.3.3.Final has been relocated to org.infinispan:infinispan-hibernate-cache-v53:jar:9.3.0.Final
[INFO] ru.testproject:test:jar:2.4.41-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.5.8.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:1.5.8.RELEASE:test
[INFO] | | \- org.springframework.boot:spring-boot:jar:1.5.8.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.8.RELEASE:test
[INFO] | | \- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.8.RELEASE:compile
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.2.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.2.1:test
[INFO] | | \- net.minidev:accessors-smart:jar:1.1:test
[INFO] | +- org.assertj:assertj-core:jar:2.6.0:test
[INFO] | +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] | | \- org.objenesis:objenesis:jar:2.1: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.4.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | +- org.springframework:spring-core:jar:4.3.12.RELEASE:compile
[INFO] | \- org.springframework:spring-test:jar:4.3.12.RELEASE:test
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.5.8.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:1.5.8.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.8.RELEASE:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.1.11:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.1.11:compile
[INFO] | | | +- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] | | | \- org.slf4j:log4j-over-slf4j:jar:1.7.25:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.17:runtime
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:1.5.8.RELEASE:compile
[INFO] | | \- org.aspectj:aspectjweaver:jar:1.8.11:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.8.RELEASE:compile
[INFO] | | \- org.apache.tomcat:tomcat-jdbc:jar:8.5.23:compile
[INFO] | | \- org.apache.tomcat:tomcat-juli:jar:8.5.23:compile
[INFO] | +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:1.11.8.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-commons:jar:1.13.8.RELEASE:compile
[INFO] | | +- org.springframework:spring-orm:jar:4.3.12.RELEASE:compile
[INFO] | | \- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
[INFO] | \- org.springframework:spring-aspects:jar:4.3.12.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-jetty:jar:1.5.8.RELEASE:compile
[INFO] | +- org.eclipse.jetty:jetty-webapp:jar:9.4.7.v20170914:compile
[INFO] | | +- org.eclipse.jetty:jetty-xml:jar:9.4.7.v20170914:compile
[INFO] | | \- org.eclipse.jetty:jetty-servlet:jar:9.4.7.v20170914:compile
[INFO] | | \- org.eclipse.jetty:jetty-security:jar:9.4.7.v20170914:compile
[INFO] | | \- org.eclipse.jetty:jetty-server:jar:9.4.7.v20170914:compile
[INFO] | +- org.eclipse.jetty.websocket:websocket-server:jar:9.4.7.v20170914:compile
[INFO] | | +- org.eclipse.jetty.websocket:websocket-common:jar:9.4.7.v20170914:compile
[INFO] | | | \- org.eclipse.jetty.websocket:websocket-api:jar:9.4.7.v20170914:compile
[INFO] | | +- org.eclipse.jetty.websocket:websocket-client:jar:9.4.7.v20170914:compile
[INFO] | | | \- org.eclipse.jetty:jetty-client:jar:9.4.7.v20170914:compile
[INFO] | | \- org.eclipse.jetty.websocket:websocket-servlet:jar:9.4.7.v20170914:compile
[INFO] | +- org.eclipse.jetty.websocket:javax-websocket-server-impl:jar:9.4.7.v20170914:compile
[INFO] | | +- org.eclipse.jetty:jetty-annotations:jar:9.4.7.v20170914:compile
[INFO] | | | +- org.eclipse.jetty:jetty-plus:jar:9.4.7.v20170914:compile
[INFO] | | | +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] | | | +- org.ow2.asm:asm:jar:5.1:compile
[INFO] | | | \- org.ow2.asm:asm-commons:jar:5.1:compile
[INFO] | | | \- org.ow2.asm:asm-tree:jar:5.1:compile
[INFO] | | +- org.eclipse.jetty.websocket:javax-websocket-client-impl:jar:9.4.7.v20170914:compile
[INFO] | | \- javax.websocket:javax.websocket-api:jar:1.0:compile
[INFO] | \- org.mortbay.jasper:apache-el:jar:8.0.33:compile
[INFO] +- commons-fileupload:commons-fileupload:jar:1.3.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web-services:jar:1.5.8.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-web:jar:1.5.8.RELEASE:compile
[INFO] | +- org.springframework:spring-oxm:jar:4.3.12.RELEASE:compile
[INFO] | \- org.springframework.ws:spring-ws-core:jar:2.4.0.RELEASE:compile
[INFO] | \- org.springframework.ws:spring-xml:jar:2.4.0.RELEASE:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:5.3.3.Final:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile
[INFO] | +- dom4j:dom4j:jar:1.6.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.13:compile
[INFO] | \- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.1.1.Final:compile
[INFO] +- org.hibernate:hibernate-core:jar:5.3.3.Final:compile
[INFO] | +- org.javassist:javassist:jar:3.21.0-GA: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.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] +- org.hibernate:hibernate-osgi:jar:5.3.3.Final:compile
[INFO] | +- javax.interceptor:javax.interceptor-api:jar:1.2:compile
[INFO] | +- org.osgi:org.osgi.core:jar:6.0.0:compile
[INFO] | \- org.osgi:org.osgi.compendium:jar:5.0.0:compile
[INFO] +- org.hibernate:hibernate-envers:jar:5.3.3.Final:compile
[INFO] +- org.hibernate:hibernate-hikaricp:jar:5.3.3.Final:compile
[INFO] +- org.hibernate:hibernate-proxool:jar:5.3.3.Final:compile
[INFO] | \- proxool:proxool:jar:0.8.3:compile
[INFO] +- org.infinispan:infinispan-hibernate-cache-v53:jar:9.3.0.Final:compile
[INFO] | +- org.infinispan:infinispan-hibernate-cache-commons:jar:9.3.0.Final:compile
[INFO] | +- org.infinispan:infinispan-hibernate-cache-spi:jar:9.3.0.Final:compile
[INFO] | \- org.infinispan:infinispan-core:jar:9.3.0.Final:compile
[INFO] | +- org.infinispan:infinispan-commons:jar:9.3.0.Final:compile
[INFO] | +- org.jgroups:jgroups:jar:4.0.12.Final:compile
[INFO] | +- com.github.ben-manes.caffeine:caffeine:jar:2.3.5:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.1.Final:compile
[INFO] | +- org.jboss.marshalling:jboss-marshalling-osgi:jar:2.0.5.Final:compile
[INFO] | \- io.reactivex.rxjava2:rxjava:jar:2.1.3:compile
[INFO] | \- org.reactivestreams:reactive-streams:jar:1.0.1:compile
[INFO] +- org.hibernate:hibernate-ehcache:jar:5.3.3.Final:compile
[INFO] | \- net.sf.ehcache:ehcache:jar:2.10.4:compile
[INFO] +- wsdl4j:wsdl4j:jar:1.6.1:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.3.12.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.3.12.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.3.12.RELEASE:compile
[INFO] | +- org.springframework:spring-expression:jar:4.3.12.RELEASE:compile
[INFO] | \- org.springframework:spring-web:jar:4.3.12.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:4.2.1.RELEASE:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | \- org.springframework.security:spring-security-core:jar:4.2.3.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-web:jar:4.2.0.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-taglibs:jar:4.2.0.RELEASE:compile
[INFO] | \- org.springframework.security:spring-security-acl:jar:4.2.3.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:4.3.12.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:5.0.4.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:4.3.12.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:4.3.12.RELEASE:compile
[INFO] +- javax.xml.bind:jaxb-api:jar:2.3.0:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] +- javax.inject:javax.inject:jar:1:compile
[INFO] +- commons-configuration:commons-configuration:jar:1.10:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- junit:junit:jar:4.11:test
[INFO] +- org.jdom:jdom:jar:2.0.2:compile
[INFO] +- commons-io:commons-io:jar:2.4:compile
[INFO] +- xalan:xalan:jar:2.7.2:compile
[INFO] | \- xalan:serializer:jar:2.7.2:compile
[INFO] | \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] +- org.apache.derby:derby:jar:10.11.1.1:compile
[INFO] +- org.postgresql:postgresql:jar:42.1.1:compile
[INFO] +- com.zaxxer:HikariCP:jar:2.6.3:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- jaxen:jaxen:jar:1.1.6:compile
[INFO] +- ru.testproject:test-conf:jar:2.4.41-SNAPSHOT:compile
[INFO] | +- log4j:log4j:jar:1.2.16:compile
[INFO] | +- org.slf4j:slf4j-log4j12:jar:1.7.25:compile
[INFO] | \- ru.testproject:test-util:jar:2.4.41-SNAPSHOT:compile
[INFO] +- com.github.spullara.mustache.java:compiler:jar:0.9.0:compile
[INFO] +- org.quartz-scheduler:quartz:jar:2.2.1:compile
[INFO] | \- c3p0:c3p0:jar:0.9.1.1:compile
[INFO] +- javax.json:javax.json-api:jar:1.0:compile
[INFO] +- org.apache.santuario:xmlsec:jar:2.0.6:compile
[INFO] | +- org.codehaus.woodstox:woodstox-core-asl:jar:4.4.1:compile
[INFO] | | +- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] | | \- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
[INFO] | \- commons-codec:commons-codec:jar:1.10:compile
[INFO] +- org.eclipse.jetty:jetty-servlets:jar:9.3.5.v20151012:compile
[INFO] | +- org.eclipse.jetty:jetty-continuation:jar:9.4.7.v20170914:compile
[INFO] | +- org.eclipse.jetty:jetty-http:jar:9.4.7.v20170914:compile
[INFO] | +- org.eclipse.jetty:jetty-util:jar:9.4.7.v20170914:compile
[INFO] | \- org.eclipse.jetty:jetty-io:jar:9.4.7.v20170914:compile
[INFO] +- com.itextpdf:itextpdf:jar:5.5.12:compile
[INFO] +- org.bouncycastle:bcprov-jdk15on:jar:1.55:compile
[INFO] +- org.bouncycastle:bcmail-jdk15on:jar:1.55:compile
[INFO] +- org.bouncycastle:bcpkix-jdk15on:jar:1.55:compile
[INFO] +- com.google.guava:guava:jar:24.0-jre:compile
[INFO] | +- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] | +- org.checkerframework:checker-compat-qual:jar:2.0.0:compile
[INFO] | +- com.google.errorprone:error_prone_annotations:jar:2.1.3:compile
[INFO] | +- com.google.j2objc:j2objc-annotations:jar:1.1:compile
[INFO] | \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile
[INFO] +- org.dom4j:dom4j:jar:2.1.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.10:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.8.10:compile
[INFO] +- commons-net:commons-net:jar:3.6:compile
[INFO] +- org.samba.jcifs:jcifs:jar:1.2.19:compile
[INFO] \- org.reflections:reflections:jar:0.9.11:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.788 s
[INFO] Finished at: 2018-08-22T11:11:41+03:00
[INFO] ------------------------------------------------------------------------
Anyway, I have the same issue at application startup:
Warning: SLF4J: Class path contains multiple SLF4J bindings.
33:08.275 [main] DEBUG org.springframework.boot.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath:
[main] ERROR org.springframework.boot.SpringApplication - Application startup failed
java.lang.NoSuchMethodError: org.springframework.util.ObjectUtils.unwrapOptional(Ljava/lang/Object;)Ljava/lang/Object;
at org.springframework.validation.DataBinder.<init>(DataBinder.java:179)
at org.springframework.boot.bind.RelaxedDataBinder.<init>(RelaxedDataBinder.java:83)
org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:197)
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325)
org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at ru.testproject.BootConfiguration.main(BootConfiguration.java:26)
cess finished with exit code 1
Problem solved: I fixed the dependency issues. Should use,
#Configuration
#EnableAutoConfiguration
#ComponentScan
#Import(Config.class)
instead #SpringBootApplication annotation. Now the application is getting booted, but cannot find config file which is another story.
I'm getting this error trying to use log4j2 with spring boot.
ERROR StatusLogger Log4j2 could not find a logging implementation.
Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
I'm have followed this guide: http://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html#howto-configure-log4j-for-logging - and also added the two log4j2-dependencies from https://logging.apache.org/log4j/2.x/maven-artifacts.html
My dependency:tree looks like this:
[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) # musikkjulekalender ---
[INFO] no.saiboten:musikkjulekalender:war:1.0-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.4.0.RELEASE:compile
[INFO] | +- org.hibernate:hibernate-validator:jar:5.2.4.Final:compile
[INFO] | | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] | | \- com.fasterxml:classmate:jar:1.3.1:compile
[INFO] | +- org.springframework:spring-web:jar:4.3.2.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc:jar:4.3.2.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-jetty:jar:1.4.0.RELEASE:compile
[INFO] | +- org.eclipse.jetty:jetty-servlets:jar:9.3.11.v20160721:compile
[INFO] | | +- org.eclipse.jetty:jetty-continuation:jar:9.3.11.v20160721:compile
[INFO] | | +- org.eclipse.jetty:jetty-http:jar:9.3.11.v20160721:compile
[INFO] | | \- org.eclipse.jetty:jetty-io:jar:9.3.11.v20160721:compile
[INFO] | +- org.eclipse.jetty:jetty-webapp:jar:9.3.11.v20160721:compile
[INFO] | | +- org.eclipse.jetty:jetty-xml:jar:9.3.11.v20160721:compile
[INFO] | | \- org.eclipse.jetty:jetty-servlet:jar:9.3.11.v20160721:compile
[INFO] | | \- org.eclipse.jetty:jetty-security:jar:9.3.11.v20160721:compile
[INFO] | +- org.eclipse.jetty.websocket:websocket-server:jar:9.3.11.v20160721:compile
[INFO] | | +- org.eclipse.jetty.websocket:websocket-common:jar:9.3.11.v20160721:compile
[INFO] | | | \- org.eclipse.jetty.websocket:websocket-api:jar:9.3.11.v20160721:compile
[INFO] | | +- org.eclipse.jetty.websocket:websocket-client:jar:9.3.11.v20160721:compile
[INFO] | | \- org.eclipse.jetty.websocket:websocket-servlet:jar:9.3.11.v20160721:compile
[INFO] | \- org.eclipse.jetty.websocket:javax-websocket-server-impl:jar:9.3.11.v20160721:compile
[INFO] | +- org.eclipse.jetty:jetty-annotations:jar:9.3.11.v20160721:compile
[INFO] | | +- org.eclipse.jetty:jetty-plus:jar:9.3.11.v20160721:compile
[INFO] | | +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] | | +- org.ow2.asm:asm:jar:5.0.1:compile
[INFO] | | \- org.ow2.asm:asm-commons:jar:5.0.1:compile
[INFO] | | \- org.ow2.asm:asm-tree:jar:5.0.1:compile
[INFO] | +- org.eclipse.jetty.websocket:javax-websocket-client-impl:jar:9.3.11.v20160721:compile
[INFO] | \- javax.websocket:javax.websocket-api:jar:1.0:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.4.0.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:1.4.0.RELEASE:compile
[INFO] | | \- org.aspectj:aspectjweaver:jar:1.8.9:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.4.0.RELEASE:compile
[INFO] | | +- org.apache.tomcat:tomcat-jdbc:jar:8.5.4:compile
[INFO] | | | \- org.apache.tomcat:tomcat-juli:jar:8.5.4:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:4.3.2.RELEASE:compile
[INFO] | +- org.hibernate:hibernate-core:jar:5.0.9.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] | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | +- org.jboss:jandex:jar:2.0.0.Final:compile
[INFO] | | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | | \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] | | \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] | +- org.hibernate:hibernate-entitymanager:jar:5.0.9.Final:compile
[INFO] | +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] | \- org.springframework:spring-aspects:jar:4.3.2.RELEASE:compile
[INFO] +- com.h2database:h2:jar:1.4.192:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.4.0.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:1.4.0.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.4.0.RELEASE:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.2.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.2.1:test
[INFO] | | \- net.minidev:accessors-smart:jar:1.1:test
[INFO] | +- org.assertj:assertj-core:jar:2.5.0:test
[INFO] | +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] | | \- org.objenesis:objenesis:jar:2.1:test
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.3.0:test
[INFO] | | \- org.json:json:jar:20140107:test
[INFO] | +- org.springframework:spring-core:jar:4.3.2.RELEASE:compile
[INFO] | \- org.springframework:spring-test:jar:4.3.2.RELEASE:test
[INFO] +- org.springframework.boot:spring-boot-starter:jar:1.4.0.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:1.4.0.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.4.0.RELEASE:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.17:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-log4j2:jar:1.4.0.RELEASE:compile
[INFO] | +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.6.2:compile
[INFO] | +- org.slf4j:jcl-over-slf4j:jar:1.7.21:compile
[INFO] | \- org.slf4j:jul-to-slf4j:jar:1.7.21:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.6.2:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.6.2:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] +- org.mongodb:mongo-java-driver:jar:2.12.4:compile
[INFO] +- org.springframework.data:spring-data-mongodb:jar:1.9.2.RELEASE:compile
[INFO] | +- org.springframework:spring-tx:jar:4.3.2.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:4.3.2.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.3.2.RELEASE:compile
[INFO] | +- org.springframework:spring-expression:jar:4.3.2.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:1.12.2.RELEASE:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] +- com.google.api-client:google-api-client:jar:1.18.0-rc:compile
[INFO] +- com.google.http-client:google-http-client-jackson2:jar:1.18.0-rc:compile
[INFO] | \- com.google.http-client:google-http-client:jar:1.18.0-rc:compile
[INFO] +- com.google.oauth-client:google-oauth-client:jar:1.18.0-rc:compile
[INFO] | \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.2:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.1:compile
[INFO] +- com.google.apis:google-api-services-oauth2:jar:v2-rev81-1.19.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.8.2:compile
[INFO] +- org.mongodb.morphia:morphia:jar:0.107:compile
[INFO] +- org.springframework.security:spring-security-web:jar:4.1.1.RELEASE:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | \- org.springframework.security:spring-security-core:jar:4.1.1.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:4.1.1.RELEASE:compile
[INFO] | \- org.springframework:spring-aop:jar:4.3.2.RELEASE:compile
[INFO] +- org.springframework.social:spring-social-config:jar:1.1.4.RELEASE:compile
[INFO] | \- org.springframework.social:spring-social-web:jar:1.1.4.RELEASE:compile
[INFO] | \- javax.inject:javax.inject:jar:1:compile
[INFO] +- org.springframework.social:spring-social-core:jar:1.1.4.RELEASE:compile
[INFO] +- org.springframework.social:spring-social-facebook:jar:2.0.3.RELEASE:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.3.6:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.4.5:compile
[INFO] | \- commons-codec:commons-codec:jar:1.10:compile
[INFO] +- org.mockito:mockito-all:jar:1.10.8:compile
[INFO] +- junit:junit:jar:4.11:compile
[INFO] +- org.eclipse.jetty:apache-jsp:jar:9.3.11.v20160721:provided
[INFO] | +- org.eclipse.jetty:jetty-util:jar:9.3.11.v20160721:compile
[INFO] | +- org.eclipse.jetty:jetty-server:jar:9.3.11.v20160721:compile
[INFO] | +- org.eclipse.jetty.toolchain:jetty-schemas:jar:3.1:provided
[INFO] | +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] | +- org.mortbay.jasper:apache-jsp:jar:8.0.33:provided
[INFO] | | \- org.mortbay.jasper:apache-el:jar:8.0.33:provided
[INFO] | \- org.eclipse.jdt.core.compiler:ecj:jar:4.4.2:provided
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- org.springframework.data:spring-data-jpa:jar:1.10.2.RELEASE:compile
[INFO] | +- org.springframework:spring-orm:jar:4.3.2.RELEASE:compile
[INFO] | \- org.aspectj:aspectjrt:jar:1.8.9:compile
[INFO] +- postgresql:postgresql:jar:9.1-901-1.jdbc4:compile
[INFO] \- joda-time:joda-time:jar:2.9.4:compile
I have added the standard log4j2.xml-file to src/main/resources/config with the default config:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="org.apache.log4j.xml" level="info"/>
<Root level="debug">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>
Any guesses? I've tried running from within Spring Tool Suite and with the maven spring-boot plugin.
By popular request, here is the complete 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/maven-v4_0_0.xsd">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>no.saiboten</groupId>
<artifactId>musikkjulekalender</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Musikkjulekalender</name>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.12.4</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.18.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>1.18.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client</artifactId>
<version>1.18.0-rc</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-oauth2</artifactId>
<version>v2-rev81-1.19.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.mongodb.morphia</groupId>
<artifactId>morphia</artifactId>
<version>0.107</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-facebook</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.8</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jsp</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.4</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</repository>
<repository>
<id>org.jboss.repository.releases</id>
<name>JBoss Maven Release Repository</name>
<url>https://repository.jboss.org/nexus/content/repositories/releases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
I looked up the source code of LogManager.class and found the reason was there's no LoggerContextFactory found in log4j-provider.properties which should be found in log4j-core.jar/META-INF.
So check your log4j-core.jar/META-INF/log4j-provider.properties file , or you can delete your log4j-core.jar in your local repository.
It looks your dependencies are correct. This is the pom of working spring-boot application with log4j2 as logging framework:
<!-- Spring logging -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
Put your log4j2.xml into resource folder for running from eclipse; if you prefer to use the different directory - resource/conf - provide the path to log4j2 configuration with JVM argument like this:
-Dlog4j.configurationFile=”conf/log4j2.xml”
Do not give up and switch back from logback to log4j2...
That error message is generated by the log4j-api module when it cannot find or load an implementation of its interfaces. Usually this means that the log4j-core module is missing from the classpath, but looking at your dependency graph that doesn't seem to be the case.
There are some transitive dependencies on the log4j-slf4j-impl and log4j-jul modules but I don't think that could cause the error message.
One way to investigate further is to try starting your application again with this system property set: -Dorg.apache.logging.log4j.simplelog.StatusLogger.level=TRACE. This will print log4j internal debug logging to the console.
(Once your configuration file is loaded the StatusLogger output level can be controlled by setting <Configuration status="trace"> in the beginning of the log4j2.xml configuration file. However, the configuration file is loaded by the log4j-core module, and we're not there yet...)
There might be multiple reasons but common reason is you might have wrong JAR (corrupted).
Delete JARs from repository and try to download again. It will solve the problem.
In my case I have deleted org folder from maven repository
{home}.m2\repository\org.
I have posted similar question here.
Spring boot: ERROR StatusLogger Log4j2 could not find a logging implementation
Adding below setting solved my issue.
-Dlog4j2.loggerContextFactory=org.apache.logging.log4j.core.impl.Log4jContextFactory
I'm new to Spring and im getting the following error
java.lang.NoClassDefFoundError: org/springframework/beans/factory/NoUniqueBeanDefinitionException
java.lang.Class.getDeclaredMethods0(Native Method)
java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
java.lang.Class.getDeclaredMethods(Class.java:1855)
org.springframework.core.type.StandardAnnotationMetadata.hasAnnotatedMethods(StandardAnnotationMetadata.java:159)
org.springframework.context.annotation.ConfigurationClassUtils.isLiteConfigurationCandidate(ConfigurationClassUtils.java:104)
org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:87)
org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:253)
org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:223)
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:647)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:598)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:661)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:517)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:458)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:138)
javax.servlet.GenericServlet.init(GenericServlet.java:160)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor.run(AprEndpoint.java:2378)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:744)
From what I've searched it seems that I'm missing a library, so here is my POM
<properties>
<spring.version>3.2.0.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</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-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</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>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<!--Jersey-->
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-xml-provider</artifactId>
<version>2.3.0</version>
</dependency>
<!--Security-->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
<!--Spring Data JDBC-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.28</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.0.Final</version>
</dependency>
If you guys could help me figure out which Lib it it i would be grateful.
But can some one teach how to debug this kind of error?
I'm using Intelij Idea 13
Here is the output of mvn dependency:three
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # WebGest ---
[INFO] com.springapp:WebGest:war:1.0-SNAPSHOT
[INFO] +- org.springframework:spring-core:jar:3.2.0.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework:spring-web:jar:3.2.0.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:3.2.0.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:3.2.0.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-beans:jar:3.2.0.RELEASE:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:compile
[INFO] +- javax.servlet.jsp:jsp-api:jar:2.1:provided
[INFO] +- org.springframework:spring-webmvc:jar:3.2.0.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:3.2.0.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:3.2.0.RELEASE:test
[INFO] +- junit:junit:jar:4.8.2:test
[INFO] +- org.glassfish.jersey.ext:jersey-spring3:jar:2.5.1:compile
[INFO] | +- org.glassfish.jersey.core:jersey-server:jar:2.5.1:compile
[INFO] | | +- org.glassfish.jersey.core:jersey-common:jar:2.5.1:compile
[INFO] | | | +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] | | | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
[INFO] | | +- org.glassfish.jersey.core:jersey-client:jar:2.5.1:compile
[INFO] | | +- com.google.guava:guava:jar:14.0.1:compile
[INFO] | | +- org.glassfish.hk2:hk2-api:jar:2.2.0-b21:compile
[INFO] | | +- org.glassfish.hk2.external:javax.inject:jar:2.2.0-b21:compile
[INFO] | | +- org.glassfish.hk2:hk2-locator:jar:2.2.0-b21:compile
[INFO] | | | +- org.glassfish.hk2.external:asm-all-repackaged:jar:2.2.0-b21:compile
[INFO] | | | \- org.glassfish.hk2.external:cglib:jar:2.2.0-b21:compile
[INFO] | | \- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | +- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.5.1:compile
[INFO] | +- org.glassfish.hk2:hk2:jar:2.2.0-b21:compile
[INFO] | | +- org.glassfish.hk2:hk2-utils:jar:2.2.0-b21:compile
[INFO] | | | \- javax.inject:javax.inject:jar:1:compile
[INFO] | | +- org.glassfish.hk2:config-types:jar:2.2.0-b21:compile
[INFO] | | +- org.glassfish.hk2:core:jar:2.2.0-b21:compile
[INFO] | | +- org.glassfish.hk2:hk2-config:jar:2.2.0-b21:compile
[INFO] | | | +- org.jvnet:tiger-types:jar:1.4:compile
[INFO] | | | \- org.glassfish.hk2.external:bean-validator:jar:2.2.0-b21:compile
[INFO] | | +- org.glassfish.hk2:hk2-runlevel:jar:2.2.0-b21:compile
[INFO] | | \- org.glassfish.hk2:class-model:jar:2.2.0-b21:compile
[INFO] | +- org.glassfish.hk2:spring-bridge:jar:2.2.0-b21:compile
[INFO] | \- javax.ws.rs:javax.ws.rs-api:jar:2.0:compile
[INFO] +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.3.0:compile
[INFO] | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.3.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.3.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.3.0:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.0:compile
[INFO] | \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.3.0:compile
[INFO] +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-xml-provider:jar:2.3.0:compile
[INFO] | +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.3.0:compile
[INFO] | +- org.codehaus.woodstox:stax2-api:jar:3.1.1:compile
[INFO] | | \- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] | \- org.codehaus.woodstox:woodstox-core-asl:jar:4.1.4:compile
[INFO] +- org.springframework.security:spring-security-web:jar:3.2.0.RELEASE:compile
[INFO] | \- org.springframework.security:spring-security-core:jar:3.2.0.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:3.2.0.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:4.0.0.RELEASE:compile
[INFO] | \- org.springframework:spring-tx:jar:4.0.0.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:4.0.0.RELEASE:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.28:compile
[INFO] \- org.hibernate:hibernate-core:jar:4.3.0.Final:compile
[INFO] +- org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile
[INFO] +- org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile
[INFO] +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.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.4.Final:compile
[INFO] +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] +- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] +- antlr:antlr:jar:2.7.7:compile
[INFO] \- org.jboss:jandex:jar:1.1.0.Final:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.348s
[INFO] Finished at: Mon Feb 03 21:43:43 WET 2014
[INFO] Final Memory: 13M/217M
[INFO] ------------------------------------------------------------------------
To troubleshoot these kind of problems, search for the class in either findjar.com or
grepcode.com, in this case this is the report from grepcode for NoUniqueBeanDefinitionException.
There we can see that that class is not on version 3.2.0 of the spring-beans jar, and that the earliest version that has it 3.2.1.RELEASE.
Then check the version used in your project with mvn dependency:tree, and adapt accordingly, in this case upgrade to at least 3.2.1.RELEASE.
This class seems (from a since tag) to be introduced in Spring 3.2.1. Try to change spring.version to 3.2.1.RELEASE (to upgrade also spring-beans.jar which holds this class).