Jersey Dependency Tree Issue - jersey

Previously we are using Jersey 1.17 and org.apache.cxf 2.6.0 version for different components of our project . Now our proj migrated to Jersey 1.19.4 and cxf 3.2.6 . I saw jersey 1.19.4 holding javax.ws.rs:jsr311-api:jar:1.1.1 where as cxf 3.2.6 holding javax.ws.rs:javax.ws.rs-api:jar:2.1 . All components are compiling successfully without any failure . But in Application We are facing this below issue :-
Oct 17, 2018 10:29:08 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [CA Service REST API] in context with path [/caservice] threw exception [Servlet execution threw an exception] with root cause
java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:120)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:669)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationF)
How We resolve this issue ?
After upgrading this is my dependency tree Structure
+- org.apache.cxf:cxf-core:jar:3.2.6:compile
[INFO] | | +- com.fasterxml.woodstox:woodstox-core:jar:5.1.0:compile
[INFO] | | | \- org.codehaus.woodstox:stax2-api:jar:4.1:compile
[INFO] | | \- org.apache.ws.xmlschema:xmlschema-core:jar:2.2.3:compile
[INFO] | +- org.apache.cxf:cxf-rt-rs-client:jar:3.2.6:compile
[INFO] | | \- org.apache.cxf:cxf-rt-frontend-jaxrs:jar:3.2.6:compile
[INFO] | | +- javax.ws.rs:javax.ws.rs-api:jar:2.1:compile
[INFO] | | \- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] | +- org.apache.cxf:cxf-rt-transports-http:jar:3.2.6:compile
+- com.sun.jersey:jersey-core:jar:1.19.4:compile
[INFO] | \- javax.ws.rs:jsr311-api:jar:1.1.1:compile

Related

Jasper exception PWC6188 - Jetty cannot resolve javax.servlet.jstl.fmt TLD to JSTL classes inside project

Related: Jetty - upgrading 9.3.0.M1 to 9.3.0.M2 breaks JSP functionality using Maven
Related: Jetty 9 migrate from JDK1.8 to JDK11 - http://java.sun.com/jsp/jstl/fmt cannot be resolved in JDK11 - fat exec jar
I have a legacy maven project running on JDK 1.8 (yup, old) that I need to upgrade to JDK 17.
It runs on an embedded Jetty instance version 9.2.23.v20171218.
I've spent all day trolling through SO trying at least 9 different fixes advised by others, none work. I have no web.xml file or web-INF folder, virtually all posts refer to these folders in the project?
Also it is an embedded instance of Jetty (which seems quite unique and a strange use case?)
The exception on trying to access the project's index.jsp in a browser is
org.apache.jasper.JasperException: /index.jsp(1,64) PWC6188: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:92)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:378)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:172)
at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:431)
at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:240)
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:502)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:582)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1657)
at org.apache.jasper.compiler.Parser.parse(Parser.java:185)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:244)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:145)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:212)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:625)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
at org.eclipse.jetty.jsp.JettyJspServlet.service(JettyJspServlet.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:553)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:499)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.base/java.lang.Thread.run(Thread.java:833)
------------------------------------------------------------
I'm aware there are at least 30 posts about this same issue - I've spent today working through them one by one, no joy...
The error seems related to the fact that the TLD in the JSP tag at the top of my index.jsp is not mapped to the correct class in the referenced JAR, and this only matters if running in any JDK higher then 1.8 (dropped JDK17 and tried JDK11, it also doesn't work). Any JDK above 1.8 seems to give the above exception, and Jetty fails to parse any .JSP files anymore.
I have the following Maven artifacts as suggested by various SO posts:
.
.
.
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
.
.
.
and can confirm in NetBeans 14 that in "Dependencies" I have
jstl-1.2.jar
jstl-api-1.2.jar
If I open jstl-1.2.jar in the Netbeans 14 project view, I can see the exact class complained about, e. g.
jstl-1.2.jar
>.
.
.
javax.servlet.jsp.jstl.core
javax.servlet.jsp.jstl.fmt
.
.
.
are present in the project JAR.
My .jsp page's first lines are
<%# taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
.
.
.
How can I get Jetty / Jasper to find jstl-1.2.jar's "fmt" and "core" classes inside the JAR above in my project, and map the TLDs above to those classes so I can get JSP functionality back in any JDK higher than 1.8?
(As stated, JDK 1.8 works with the above codebase as-is, any JDK of a higher version fails with above exception.)
ANY help or suggestions appreciated!
Thanks
My mvn dependency:tree:
--- maven-dependency-plugin:2.8:tree (default-cli) # verdi ---
[INFO] verishare:verdi:jar:1.0-SNAPSHOT
[INFO] +- org.slf4j:slf4j-simple:jar:1.7.21:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.17.1:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.17.1:compile
[INFO] +- junit:junit:jar:4.11:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.eclipse.jetty.websocket:websocket-client:jar:9.2.23.v20171218:compile
[INFO] | +- org.eclipse.jetty:jetty-util:jar:9.2.23.v20171218:compile
[INFO] | +- org.eclipse.jetty:jetty-io:jar:9.2.23.v20171218:compile
[INFO] | \- org.eclipse.jetty.websocket:websocket-common:jar:9.2.23.v20171218:compile
[INFO] | \- org.eclipse.jetty.websocket:websocket-api:jar:9.2.23.v20171218:compile
[INFO] +- org.eclipse.jetty:jetty-server:jar:9.2.23.v20171218:compile
[INFO] | +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] | \- org.eclipse.jetty:jetty-http:jar:9.2.23.v20171218:compile
[INFO] +- org.eclipse.jetty:jetty-servlet:jar:9.2.23.v20171218:compile
[INFO] | \- org.eclipse.jetty:jetty-security:jar:9.2.23.v20171218:compile
[INFO] +- com.google.code.gson:gson:jar:2.2.4:compile
[INFO] +- org.glassfish:javax.json:jar:1.0.4:compile
[INFO] +- org.apache.commons:commons-dbcp2:jar:2.5.0:compile
[INFO] | +- org.apache.commons:commons-pool2:jar:2.6.0:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- postgresql:postgresql:jar:9.1-901-1.jdbc4:compile
[INFO] +- org.eclipse.jetty:jetty-webapp:jar:9.2.23.v20171218:compile
[INFO] | \- org.eclipse.jetty:jetty-xml:jar:9.2.23.v20171218:compile
[INFO] +- org.eclipse.jetty:jetty-jsp:jar:9.2.23.v20171218:compile
[INFO] | +- org.eclipse.jetty.toolchain:jetty-schemas:jar:3.1.M0:compile
[INFO] | +- javax.servlet.jsp:javax.servlet.jsp-api:jar:2.3.1:compile
[INFO] | +- org.glassfish.web:javax.servlet.jsp:jar:2.3.2:compile
[INFO] | +- org.eclipse.jetty.orbit:javax.servlet.jsp.jstl:jar:1.2.0.v201105211821:compile
[INFO] | +- org.glassfish.web:javax.servlet.jsp.jstl:jar:1.2.2:compile
[INFO] | +- org.glassfish:javax.el:jar:3.0.0:compile
[INFO] | \- org.eclipse.jetty.orbit:org.eclipse.jdt.core:jar:3.8.2.v20130121:compile
[INFO] +- com.microsoft.sqlserver:mssql-jdbc:jar:6.4.0.jre8:compile
[INFO] +- org.mariadb.jdbc:mariadb-java-client:jar:2.7.4:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.1:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.4.3:compile
[INFO] | \- commons-codec:commons-codec:jar:1.9:compile
[INFO] +- org.glassfish.jersey.core:jersey-server:jar:2.22.1:compile
[INFO] | +- org.glassfish.jersey.core:jersey-common:jar:2.22.1:compile
[INFO] | | +- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.22.1:compile
[INFO] | | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
[INFO] | +- org.glassfish.jersey.core:jersey-client:jar:2.22.1:compile
[INFO] | +- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
[INFO] | +- org.glassfish.jersey.media:jersey-media-jaxb:jar:2.22.1:compile
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] | +- org.glassfish.hk2:hk2-api:jar:2.4.0-b31:compile
[INFO] | | +- org.glassfish.hk2:hk2-utils:jar:2.4.0-b31:compile
[INFO] | | \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.4.0-b31:compile
[INFO] | +- org.glassfish.hk2.external:javax.inject:jar:2.4.0-b31:compile
[INFO] | +- org.glassfish.hk2:hk2-locator:jar:2.4.0-b31:compile
[INFO] | \- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] +- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.22.1:compile
[INFO] +- org.glassfish.jersey.media:jersey-media-multipart:jar:2.22.1:compile
[INFO] | \- org.jvnet.mimepull:mimepull:jar:1.9.6:compile
[INFO] +- org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.22.1:compile
[INFO] | +- org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.22.1:compile
[INFO] | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.5.4:compile
[INFO] | \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.5.4:compile
[INFO] | \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.5.4:compile
[INFO] +- org.glassfish.jersey.containers:jersey-container-jetty-http:jar:2.22.1:compile
[INFO] | \- org.eclipse.jetty:jetty-continuation:jar:9.1.1.v20140108:compile
[INFO] +- org.reflections:reflections:jar:0.9.10:compile
[INFO] | +- com.google.guava:guava:jar:15.0:compile
[INFO] | +- org.javassist:javassist:jar:3.19.0-GA:compile
[INFO] | \- com.google.code.findbugs:annotations:jar:2.0.1:compile
[INFO] +- com.jcraft:jsch:jar:0.1.53:compile
[INFO] +- ie.corballis:sox-java:jar:1.0.1:compile
[INFO] +- com.sun.mail:javax.mail:jar:1.5.0:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] +- org.springframework:spring-web:jar:5.3.0:compile
[INFO] | +- org.springframework:spring-beans:jar:5.3.0:compile
[INFO] | \- org.springframework:spring-core:jar:5.3.0:compile
[INFO] | \- org.springframework:spring-jcl:jar:5.3.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.11.3:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.11.3:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.3:compile
[INFO] +- javax.servlet.jsp.jstl:jstl-api:jar:1.2:compile
[INFO] | +- javax.servlet:servlet-api:jar:2.5:compile
[INFO] | \- javax.servlet.jsp:jsp-api:jar:2.1:compile
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] \- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.017 s
[INFO] Finished at: 2022-08-24T16:49:34+02:00
[INFO] ------------------------------------------------------------------------
EDIT: after reading many, many SO posts about exactly this exception I changed to the Apache artifacts, but this changes nothing, the exact same exception except for the string "PWC6188" which disappears if I use the Apache artifacts
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jsp</artifactId>
<version>9.2.23.v20171218</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jstl</artifactId>
<version>9.2.23.v20171218</version>
</dependency>
iso
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<version>9.2.23.v20171218</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
The rest of the exception text remains the same for the Apache-JSP artifacts, the line numbers just change in the stack trace.
This was solved - see in relation to
Jetty - upgrading 9.3.0.M1 to 9.3.0.M2 breaks JSP functionality using Maven
In summary (see above link) The breakthrough was to add the Apache-JSP and Apache-JSTL artifacts in the pom.xml (details at above link), and also add jetty-webapp, jaxb-api and jetty-annotations artifacts, and then remove the Jetty-JSP artifact.
And then also upgrading to JDK 17 (from JDK 1.8) and taking the Jetty version in the pom.xml up to at least version 9.4.48.v20220622
Once this was done PWC6188 with
org.apache.jasper.JasperException: /index.jsp(1,64) PWC6188: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:92)
disappeared from the browser when accessing the Jetty server and JSP rendering is working again as it did previously with the legacy Jetty I was using (9.2.2.v20140723) and old, old JDK 1.8.
I also upgraded my Netbeans from NetBeans 11 to NetBeans 14, not sure if that also had a positive effect to get this working. Only tested so far inside NetBeans itself, haven't tried deploying the .jar yet to the operational server involved.
It now works in JDK 17 which was my goal all along, with a slightly more current Jetty version (at least - still working on getting to a current Jetty version) with JSP support working.
Hope this helps someone.
EDIT: I forgot I also had to do this to my WebappContext whens starting jetty to make PWC6188 exception above go away when starting Jetty:
.
.
.
WebAppContext waContext = new WebAppContext(webDir, "/");
waContext.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
waContext.setSecurityHandler(basicSecurity);
waContext.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$");
server.setHandler(waContext);
.
.
.
e.g. I had to add
waContext.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$");
or else in Jetty 9.3.0.M2 I again had the same exception.

I cannot use Debug on IntelliJ : java.lang.NoSuchMethodError: 'org.slf4j.impl.StaticMDCBinder org.slf4j.impl.StaticMDCBinder.getSingleton()'

I am working on Spring Boot and getting NoSuchMethodError when I click on Debug.
Apparently it is caused by multiple slf4j bindings in the classpath.
It all happened all of a sudden and I am not able to fix this for over a week now.
Please see the attached stacktrace.
My maven dependency tree is pasted below showing the different loggers on the list.
[INFO] +- org.thymeleaf.extras:thymeleaf-extras-springsecurity5:jar:3.0.4.RELEASE:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.4.2:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.4.2:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.4.2:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.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
There could be many breakpoints

Spring Boot migration from 2.3.6.RELEASE to 2.4.0 and json ClassCastException

I have a Java project which has a dependency of SpringBoot version 2.3.6.RELEASE. However, I'm in trouble trying to upgrade to 2.4.0 version. In the project nothing else was changed, only version of SpringBoot. Since then the application throws the following error message:
Caused by: java.lang.ClassCastException: com.nimbusds.jose.shaded.json.JSONObject cannot be cast to net.minidev.json.JSONObject
I did some comparison of maven dependency tree (mvn dependency:tree) and found out that probably some significant changes have been done for nimbus-jose-jwt and json-smart libs.
2.3.6.RELEASE
[INFO] +- org.springframework.security:spring-security-oauth2-jose:jar:5.3.5.RELEASE:compile
[INFO] | +- com.nimbusds:nimbus-jose-jwt:jar:8.19:compile (version managed from 8.20.1)
[INFO] | | +- com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile
[INFO] | | \- net.minidev:json-smart:jar:1.3.1:provided (scope managed from compile)
[INFO] | +- org.springframework.security:spring-security-core:jar:5.3.5.RELEASE:compile
2.4.0
[INFO] +- org.springframework.security:spring-security-oauth2-jose:jar:5.4.1:compile
[INFO] | +- com.nimbusds:nimbus-jose-jwt:jar:9.1.2:compile (version managed from 9.0.1)
[INFO] | | \- com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile
[INFO] | +- org.springframework.security:spring-security-core:jar:5.4.1:compile
As can be seen above nimbus-jose-jwt has been updated from 8.19 to 9.1.2. Moreover, json-smart is not anymore part of nimbus-jose-jwt in 2.4.0.
The root cause is probably this change https://connect2id.com/blog/nimbus-jose-jwt-9
However, what should be done in order to prevent this exception?
You could override the default versions of jars nimbus-jose-jwt and json-smart, by adding the older version explicitly in your pom.
Please refer here : https://github.com/Azure/azure-sdk-for-java/issues/14898
In my case - I had to upgrade to 2.5.7 Springboot version and the nimbus-jose-jwt:jar version came with SB-2.5.7 is 9.10.1.
org.springframework.security:spring-security-oauth2-jose:jar:5.5.3:compile
[INFO] | +- (org.springframework.security:spring-security-core:jar:5.5.3:compile - version managed from 4.2.15.RELEASE; omitted for duplicate)
[INFO] | +- (org.springframework.security:spring-security-oauth2-core:jar:5.5.3:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-core:jar:5.3.13:compile - version managed from 5.3.11; omitted for duplicate)
[INFO] | \- com.nimbusds:nimbus-jose-jwt:jar:9.10.1:compile
After downgrading the nimbus-jose-jwt to 8.20 the app started working.

Incompatible Spring dependencies (NoSuchMethodError when AnnotationRepositoryConfigurationSource constructor is called)

I can't start my Spring Boot application anymore after adding persistence. The error is:
java.lang.NoSuchMethodError: org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.<init>(Lorg/springframework/core/type/AnnotationMetadata;Ljava/lang/Class;Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/Environment;Lorg/springframework/beans/factory/support/BeanDefinitionRegistry;)V
at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport$1.<init>(AbstractRepositoryConfigurationSourceSupport.java:68) ~[spring-boot-autoconfigure-1.5.7.RELEASE.jar:1.5.7.RELEASE]
I tracked this down to the changes in spring-data-commons where AnnotationRepositoryConfigurationSource resides and an additional constructor argument was added in version 1.13.5, and version 1.13.7 with the same constructor signature should be used by spring-boot-starter-data-jpa in version 1.5.7. And we only use Spring Boot dependencies with version number 1.5.7.
So then I built the dependency tree and strangely found spring-data-commons in version 1.13.4, not 1.13.7 (third to last line):
...(snippet)
[INFO] +- com.name.project:project-subproject8:jar:1.0.0-SNAPSHOT:compile
[INFO] | \- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.5.7.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.4.RELEASE:compile
[INFO] | | +- org.apache.tomcat:tomcat-jdbc:jar:8.5.15:compile
[INFO] | | | \- org.apache.tomcat:tomcat-juli:jar:8.5.15:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:4.3.9.RELEASE:compile
[INFO] | +- org.hibernate:hibernate-core:jar:5.0.12.Final:compile
[INFO] | | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final: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] | | \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] | +- org.hibernate:hibernate-entitymanager:jar:5.0.12.Final:compile
[INFO] | +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:1.11.4.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-commons:jar:1.13.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-orm:jar:4.3.9.RELEASE:compile
[INFO] | \- org.springframework:spring-aspects:jar:4.3.9.RELEASE:compile
...
Going up the tree you can see that spring-data-jpa is included in version 1.11.4, whereas, according to Spring Boot Dependency Appendix, it should be version 1.11.7. This seems to cause the error. But we don't depend on spring-data-jpa directly via our pom files.
So I don't know how this older version got into the dependency tree.
The pom of spring-boot-starter-data-jpa doesn't indicate any version numbers.
I had the same issue, and yeah it is SOLVED now!!!
You can always exclude particular inner dependency from the outer dependency. You have already given hint to solve this issue.
The root cause is that you most likely have compiled a class against a different version of the class that is missing a method, than the one you are using when running it.
I switched to 1.5.7 version of spring boot, so i just needed to add jpa dependency compatible with spring boot 1.5.7 version. Why jpa dependency because - org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource is in the spring data package. And it worked

ssh access to spring boot application

On Spring Boot 1.2.3.RELEASE trying to setup SSH on JDK 1.8, Windows 7.
I got the application.properties configured as:
shell.ssh.port=2212
shell.ssh.enabled=true
shell.auth=simple
shell.auth.simple.user.name=user
shell.auth.simple.user.password=password
When the application starts and trying to access it via putty, the following exception appears:
java.lang.IllegalStateException: No session available
at org.apache.sshd.common.AbstractSessionIoHandler.exceptionCaught(AbstractSessionIoHandler.java:52) ~[sshd-core-0.6.0.jar:0.6.0]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.exceptionCaught(DefaultIoFilterChain.java:697) ~[mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextExceptionCaught(DefaultIoFilterChain.java:483) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1100(DefaultIoFilterChain.java:46) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.exceptionCaught(DefaultIoFilterChain.java:791) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.IoFilterAdapter.exceptionCaught(IoFilterAdapter.java:111) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextExceptionCaught(DefaultIoFilterChain.java:483) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireExceptionCaught(DefaultIoFilterChain.java:471) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionCreated(DefaultIoFilterChain.java:359) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$700(DefaultIoFilterChain.java:46) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.sessionCreated(DefaultIoFilterChain.java:771) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.IoFilterAdapter.sessionCreated(IoFilterAdapter.java:79) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionCreated(DefaultIoFilterChain.java:357) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireSessionCreated(DefaultIoFilterChain.java:350) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.service.IoServiceListenerSupport.fireSessionCreated(IoServiceListenerSupport.java:211) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.addNow(AbstractPollingIoProcessor.java:514) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.handleNewSessions(AbstractPollingIoProcessor.java:481) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$200(AbstractPollingIoProcessor.java:67) [mina-core-2.0.2.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1071) [mina-core-2.0.2.jar:na]
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64) [mina-core-2.0.2.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_31]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_31]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_31]
Caused by: java.lang.AbstractMethodError: org.apache.sshd.common.keyprovider.AbstractKeyPairProvider.loadKeys()[Ljava/security/KeyPair;
at org.apache.sshd.common.keyprovider.AbstractKeyPairProvider.getKeyTypes(AbstractKeyPairProvider.java:49) ~[sshd-core-0.6.0.jar:0.6.0]
at org.apache.sshd.server.session.ServerSession.sendKexInit(ServerSession.java:331) ~[sshd-core-0.6.0.jar:0.6.0]
at org.apache.sshd.server.session.ServerSession.<init>(ServerSession.java:92) ~[sshd-core-0.6.0.jar:0.6.0]
at org.apache.sshd.server.session.SessionFactory.doCreateSession(SessionFactory.java:43) ~[sshd-core-0.6.0.jar:0.6.0]
at org.apache.sshd.common.session.AbstractSessionFactory.createSession(AbstractSessionFactory.java:38) ~[sshd-core-0.6.0.jar:0.6.0]
at org.apache.sshd.common.AbstractSessionIoHandler.sessionCreated(AbstractSessionIoHandler.java:37) ~[sshd-core-0.6.0.jar:0.6.0]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.sessionCreated(DefaultIoFilterChain.java:643) ~[mina-core-2.0.2.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionCreated(DefaultIoFilterChain.java:357) [mina-core-2.0.2.jar:na]
Is there something I am missing here?
Thanks.
Update:
Thanks for the pointers. Here is my dependency tree:
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:1.2.3.RELEASE:compile
[INFO] | \- org.springframework.boot:spring-boot-actuator:jar:1.2.3.RELEASE:compile
[INFO] \- org.springframework.boot:spring-boot-starter-remote-shell:jar:1.2.3.RELEASE:compile
[INFO] +- org.crashub:crash.cli:jar:1.3.1:compile
[INFO] +- org.crashub:crash.connectors.ssh:jar:1.3.1:compile
[INFO] | +- org.apache.sshd:sshd-core:jar:0.6.0:compile
[INFO] | +- org.apache.sshd:sshd-pam:jar:0.11.0:compile
[INFO] | | \- net.sf.jpam:jpam:jar:1.1:compile
[INFO] | +- org.bouncycastle:bcpkix-jdk15on:jar:1.51:compile
[INFO] | \- org.apache.mina:mina-core:jar:2.0.2:compile
[INFO] +- org.crashub:crash.embed.spring:jar:1.3.1:compile
[INFO] +- org.crashub:crash.plugins.cron:jar:1.3.1:compile
[INFO] | \- it.sauronsoftware.cron4j:cron4j:jar:2.2.5:compile
[INFO] +- org.crashub:crash.plugins.mail:jar:1.3.1:compile
[INFO] | \- javax.mail:mail:jar:1.4.7:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] +- org.crashub:crash.shell:jar:1.3.1:compile
[INFO] \- org.codehaus.groovy:groovy:jar:2.3.11:compile
All dependencies appear transitive from spring-boot-starter-remote-shell. I will try to fix up with manual override.
I started a spring boot project with jdk1.8, added the spring-boot-starter-remote-shell maven dependency & your configuration, gave it a go, and everything went smooth.
However java.lang.AbstractMethodError made me suspect a classpath issue, so I quickly ran a mvn dependency:tree on my project and, among others, spring-boot-starter-remote-shell:jar:1.2.3.RELEASE has org.apache.sshd:sshd-core:jar:0.11.0 as a transitive dependency as you can see below.
[INFO] +- org.springframework.boot:spring-boot-starter-remote-shell:jar:1.2.3.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-actuator:jar:1.2.3.RELEASE:compile
[INFO] | | \- org.springframework.boot:spring-boot-actuator:jar:1.2.3.RELEASE:compile
[INFO] | +- org.crashub:crash.cli:jar:1.3.1:compile
[INFO] | +- org.crashub:crash.connectors.ssh:jar:1.3.1:compile
[INFO] | | +- org.apache.sshd:sshd-core:jar:0.11.0:compile <===THIS ONE===
[INFO] | | +- org.apache.sshd:sshd-pam:jar:0.11.0:compile
[INFO] | | | \- net.sf.jpam:jpam:jar:1.1:compile
[INFO] | | +- org.bouncycastle:bcprov-jdk15on:jar:1.51:compile
[INFO] | | +- org.bouncycastle:bcpkix-jdk15on:jar:1.51:compile
[INFO] | | \- org.apache.mina:mina-core:jar:2.0.7:compile
[INFO] | +- org.crashub:crash.embed.spring:jar:1.3.1:compile
[INFO] | +- org.crashub:crash.plugins.cron:jar:1.3.1:compile
[INFO] | | \- it.sauronsoftware.cron4j:cron4j:jar:2.2.5:compile
[INFO] | +- org.crashub:crash.plugins.mail:jar:1.3.1:compile
[INFO] | | \- javax.mail:mail:jar:1.4:compile
[INFO] | | \- javax.activation:activation:jar:1.1:compile
[INFO] | +- org.crashub:crash.shell:jar:1.3.1:compile
[INFO] | \- org.codehaus.groovy:groovy:jar:2.3.11:compile
Another quick look at your stacktrace revealed that you seemed to have a different version on the classpath at org.apache.sshd.common.keyprovider.AbstractKeyPairProvider.getKeyTypes(AbstractKeyPairProvider.java:49) ~[sshd-core-0.6.0.jar:0.6.0] so what I did next was to manually specify this version as a dependency in the pom. When I rerun the app and attempted to connect via SSH I got the same exception as you did.
Also looking at the classes, the AbstractKeyPairProvider.loadKeys() method has a different signature which most likely messes up the implementations depending on the 0.11.0 contract, such as URLKeyPairProvider:
0.6.0 protected abstract KeyPair[] loadKeys();
0.11.0 public abstract Iterable<KeyPair> loadKeys();
So, either you also have added this version unintentionally, or some of your other dependencies are referring it, effectively shadowing 0.11.0 on the classpath. In my case I enabled the spring boot actuator HTTP endpoints confirming the above:
In conclusion, check your dependency tree and figure out where does the sshd-core 0.6.0 and perhaps mina-core 2.0.2 come from and exclude them.

Resources