spring boot with spring-data-jpa and full tomcat-jdbc config throws java.lang.ClassNotFoundException for ResetAbandonedTimer - spring-boot

I'm using spring boot 1.3.0.RELEASE with the following pom dependencies
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
I am trying to get JPA working and it all works fine with the following in my application.properties
# Connection url for the database
spring.datasource.url = jdbc:oracle:thin:#**********
# Username and password
spring.datasource.username = **********
spring.datasource.password = *********
when I switch to full blown dbcp config for tomcat-jdbc as below:
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.datasource.url=jdbc:oracle:thin:#**********
spring.datasource.username=*****
spring.datasource.password=*****
spring.datasource.initial-size=0
spring.datasource.max-active=10
spring.datasource.default-auto-commit=true
spring.datasource.default-transaction-isolation=2
spring.datasource.fair-queue=false
spring.datasource.jdbc-interceptors=ConnectionState;StatementFinalizer;ResetAbandonedTimer"
spring.datasource.jmx-enabled=true
spring.datasource.log-abandoned=true
spring.datasource.max-idle=1
spring.datasource.max-wait=30000
spring.datasource.min-evictable-idle-time-millis=60000
spring.datasource.min-idle=1
spring.datasource.remove-abandoned=true
spring.datasource.remove-abandoned-timeout=300
spring.datasource.test-on-borrow=true
spring.datasource.test-on-return=false
spring.datasource.test-while-idle=false
spring.datasource.time-between-eviction-runs-millis=10000
spring.datasource.use-equals=false
spring.datasource.validation-interval=60000
spring.datasource.validation-query=SELECT 2+2 FROM DUAL
I get the following stack trace
2015-11-20 16:58:18.788 ERROR 48307 --- [nio-8080-exec-1] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to inform interceptor of pool start.
java.lang.ClassNotFoundException: Unable to load class: org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer" from ClassLoader:java.net.URLClassLoader#5bbcaf22;ClassLoader:TomcatEmbeddedWebappClassLoader
context: ROOT
delegate: true
----------> Parent Classloader:
java.net.URLClassLoader#5bbcaf22
at org.apache.tomcat.jdbc.pool.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:56) ~[tomcat-jdbc-8.0.28.jar:na]
at org.apache.tomcat.jdbc.pool.PoolProperties$InterceptorDefinition.getInterceptorClass(PoolProperties.java:964) ~[tomcat-jdbc-8.0.28.jar:na]\
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:447) [tomcat-jdbc-8.0.28.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:141) [tomcat-jdbc-8.0.28.jar:na]
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:115) [tomcat-jdbc-8.0.28.jar:na]
......
......
......
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer"
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedWebappClassLoader.loadClass(TomcatEmbeddedWebappClassLoader.java:74) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
at java.lang.Class.forName0(Native Method) ~[na:1.8.0_20]
at java.lang.Class.forName(Class.java:340) ~[na:1.8.0_20]
at org.apache.tomcat.jdbc.pool.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:38) ~[tomcat-jdbc-8.0.28.jar:na]
... 147 common frames omitted
This seems to be the case even with different spring boot versions....
Is my config (taken from a spring datasource bean we already use fine) not what boot expects?
cheers

Typo.
Remove " from spring.datasource.jdbc-interceptors=ConnectionState;StatementFinalizer;ResetAbandonedTimer" at the end there.

Related

Spring Boot: Unable to look up data source

I'm running an application framework (jbpm) on Spring Boot which requires looking up a Datasource.
I'm facing the following error:
java.lang.RuntimeException: Unable to look up data source: java:jboss/datasources/ExampleDS - Need to specify class name in environment or system property, or in an application resource file: java.naming.factory.initial
at org.jbpm.process.workitem.executesql.ExecuteSqlWorkItemHandler.<init>(ExecuteSqlWorkItemHandler.java:83) ~[execute-sql-workitem-7.52.0.Final.jar:7.52.0.Final]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
I have got the following properties in application.properties:
spring.datasource.username=sa
spring.datasource.password=sa
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driver-class-name=org.h2.Driver
#hibernate configuration
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
I have also added in my configuration class the following:
#Bean
public DataSource jndiDataSource() throws IllegalArgumentException, NamingException {
JndiObjectFactoryBean bean = new JndiObjectFactoryBean();
bean.setJndiName("java:jboss/datasources/ExampleDS");
bean.setProxyInterface(DataSource.class);
bean.setLookupOnStartup(false);
bean.afterPropertiesSet();
return (DataSource) bean.getObject();
}
I have checked the code of the jbpm handler:
https://github.com/kiegroup/jbpm-work-items/blob/main/execute-sql-workitem/src/main/java/org/jbpm/process/workitem/executesql/ExecuteSqlWorkItemHandler.java#L79
I see this is the code which does the lookup:
this.ds = InitialContext.doLookup(dataSourceName);
What am I missing in my code/configuration?
Thanks
Edit: here's the core section of pom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.10.RELEASE</version>
</parent>
<properties>
<version.org.kie>7.52.0.Final</version.org.kie>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<narayana.version>5.9.0.Final</narayana.version>
<fabric8.version>3.5.40</fabric8.version>
</properties>
<dependencies>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-server-spring-boot-starter</artifactId>
<version>${version.org.kie}</version>
</dependency>
<dependency>
<groupId>org.jbpm.contrib</groupId>
<artifactId>execute-sql-workitem</artifactId>
<version>${version.org.kie}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

How to configure Spring Cloud Turbine Stream and Spring Boot Actuator using 2.0.0.M4 version?

I have the following configuration:
#EnableTurbineStream
#EnableDiscoveryClient
#SpringBootApplication
public class SquintTurbineServerApplication {
public static void main(final String... args) {
SpringApplication.run(SquintTurbineServerApplication.class, args);
}
}
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-reactor-netty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-turbine-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
When I try to start up my application this error is thrown:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicator]: Factory method 'binderHealthIndicator' threw exception; nested exception is java.lang.NoClassDefFoundError: org/spr
ingframework/boot/actuate/health/RabbitHealthIndicator
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:186)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:597)
... 40 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/actuate/health/RabbitHealthIndicator
at org.springframework.cloud.stream.binder.rabbit.config.RabbitServiceAutoConfiguration$RabbitHealthIndicatorConfiguration.binderHealthIndicator(RabbitServiceAutoConfiguration.java:141)
at org.springframework.cloud.stream.binder.rabbit.config.RabbitServiceAutoConfiguration$RabbitHealthIndicatorConfiguration$$EnhancerBySpringCGLIB$$f894963c.CGLIB$binderHealthIndicator$0()
at org.springframework.cloud.stream.binder.rabbit.config.RabbitServiceAutoConfiguration$RabbitHealthIndicatorConfiguration$$EnhancerBySpringCGLIB$$f894963c$$FastClassBySpringCGLIB$$2435cd8c.invoke()
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
at org.springframework.cloud.stream.binder.rabbit.config.RabbitServiceAutoConfiguration$RabbitHealthIndicatorConfiguration$$EnhancerBySpringCGLIB$$f894963c.binderHealthIndicator()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:155)
... 41 more
I'v tried to disable the property:
management.health.rabbit.enabled = false
But the error is still being thrown. I'v noticed that turbine-stream is looking for the class "org.springframework.boot.actuate.health.RabbitHealthIndicator", but when searched it, these class is now within "org.springframework.boot.actuate.amqp.RabbitHealthIndicator". Could someone help me?
The latest boot update to M4 changed the actuator classes, packages and removed some classes from Metrics.
That is still not compatible with Spring Cloud Stream.
The snapshot of 2.0 on SCSt pulls M2 for that reason, it won't be compatible until we get it fixed on master.

Keycloak admin-client: Unable to find a MessageBodyReader of content-type application/json

I'm new to keycloak and spring. I'm trying to use the keycloak admin-client to create a user in my spring-boot project like this:
Keycloak kc = Keycloak.getInstance(
"http://localhost:8080/auth",
"master", // the realm to log in to
"admin", "password", // the user
"admin-cli");
CredentialRepresentation credential = new CredentialRepresentation();
credential.setType(CredentialRepresentation.PASSWORD);
credential.setValue("test123");
UserRepresentation user = new UserRepresentation();
user.setUsername("testuser");
user.setFirstName("Test");
user.setLastName("User");
user.setCredentials(Arrays.asList(credential));
kc.realm("master").users().create(user);
but I keep getting this error:
Exception in thread "main" javax.ws.rs.client.ResponseProcessingException: javax.ws.rs.ProcessingException: RESTEASY003145: Unable to find a MessageBodyReader of content-type application/json and type class org.keycloak.representations.AccessTokenResponse
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.extractResult(ClientInvocation.java:158)
at org.jboss.resteasy.client.jaxrs.internal.proxy.extractors.BodyEntityExtractor.extractEntity(BodyEntityExtractor.java:60)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:107)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:76)
at com.sun.proxy.$Proxy18.grantToken(Unknown Source)
at org.keycloak.admin.client.token.TokenManager.grantToken(TokenManager.java:89)
at org.keycloak.admin.client.token.TokenManager.getAccessToken(TokenManager.java:69)
at org.keycloak.admin.client.token.TokenManager.getAccessTokenString(TokenManager.java:64)
at org.keycloak.admin.client.resource.BearerAuthFilter.filter(BearerAuthFilter.java:52)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:443)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:105)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:76)
at com.sun.proxy.$Proxy26.create(Unknown Source)
at me.phuongtm.KeycloakAdminClientDemoApplication.main(KeycloakAdminClientDemoApplication.java:68)
Caused by: javax.ws.rs.ProcessingException: RESTEASY003145: Unable to find a MessageBodyReader of content-type application/json and type class org.keycloak.representations.AccessTokenResponse
at org.jboss.resteasy.core.interception.jaxrs.ClientReaderInterceptorContext.throwReaderNotFound(ClientReaderInterceptorContext.java:42)
at org.jboss.resteasy.core.interception.jaxrs.AbstractReaderInterceptorContext.getReader(AbstractReaderInterceptorContext.java:80)
at org.jboss.resteasy.core.interception.jaxrs.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53)
at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readFrom(ClientResponse.java:266)
at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readEntity(ClientResponse.java:196)
at org.jboss.resteasy.specimpl.BuiltResponse.readEntity(BuiltResponse.java:212)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.extractResult(ClientInvocation.java:122)
... 13 more
It seems to be a problem with RESTEASY, so I added resteasy-jackson2-provider as suggested by keycloak docs, but no luck.
Here are my pom.xml dependecies:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>3.2.0.Final</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.1.4.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
<version>3.1.4.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>3.1.4.Final</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
I spent hours and hours trying to find an answer, I even tried this MatteoM's solution:
https://stackoverflow.com/a/40462534/7441720
But no luck.
I appreciate all the help I can get
UPDATE:
It appears to be an issue of providers:
10:06:45.027 [main] WARN org.jboss.resteasy.resteasy_jaxrs.i18n -
RESTEASY002145: NoClassDefFoundError: Unable to load builtin provider
org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider from
jar:file:/C:/Users/hp/.m2/repository/org/jboss/resteasy/resteasy-jackson2-
provider/3.1.4.Final/resteasy-jackson2-provider-3.1.4.Final.jar!/META-
INF/services/javax.ws.rs.ext.Providers
I can't seem to find a solution, I checked the jar and the class
ResteasyJackson2Provider
exists!
UPDATE:
From what I can tell, it was an issue with dependecies, I switched to gradle (but it should work for maven as well), my new dependencies are:
compile('org.keycloak:keycloak-admin-client:3.2.1.Final')
compile('org.jboss.resteasy:resteasy-client:3.0.14.Final')
compile('org.jboss.resteasy:resteasy-multipart-provider:3.0.14.Final')
compile('org.jboss.resteasy:resteasy-jackson2-provider:3.0.14.Final')
compile('org.jboss.resteasy:resteasy-jaxb-provider:3.0.14.Final')
compile('org.jboss.resteasy:resteasy-jettison-provider:3.0.14.Final')
compile('org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.0_spec:1.0.0.Final')
As for keycloak, I created a Configuration class with a bean:
#Bean
public Keycloak keycloakBeanConfig(){
return KeycloakBuilder.builder().serverUrl(keycloakUrl).realm(realm) //
.grantType(OAuth2Constants.CLIENT_CREDENTIALS).clientId(clientId) //
.clientSecret(clientSecret)
.build();
}
try to use resteasy-jackson-provider and removeresteasy-jackson2-provider. you can find dependency below:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>3.1.3.Final</version>
</dependency>

Spring Boot: Failed to introspect annotated methods on class org.springframework.cloud.netflix.zuul.ZuulConfiguration

I am trying to route the requests in my spring boot to another server.
pom
<?xml version="1.0"?>
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.company.etc.settings</groupId>
<artifactId>projects</artifactId>
<version>1.8</version>
</parent>
<groupId>com.company.gateway</groupId>
<artifactId>gateway</artifactId>
<name>gateway</name>
<version>0.0.1</version>
<packaging>jar</packaging>
<inceptionYear>2017</inceptionYear>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.source.version>1.8</java.source.version>
<pmd.version>3.6</pmd.version>
<findbugs.version>3.0.3</findbugs.version>
<spring.boot>1.5.3.RELEASE</spring.boot>
<swagger.version>1.5.13</swagger.version>
<jacoco.version>0.7.5.201505241946</jacoco.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>${spring.boot}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc</artifactId>
<version>7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
<version>${spring.boot}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
<version>${spring.boot}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.boot}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>${spring.boot}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>${spring.boot}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>${spring.boot}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<artifactId>junit</artifactId>
<groupId>junit</groupId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Brixton.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Application.properties
zuul.routes.foos.path=/r/users/**
zuul.routes.foos.url=http://com.company.sws/c/users/
Main Class
#EnableZuulProxy
#SpringBootApplication
#ComponentScan
#EnableAutoConfiguration
public class GatewayApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class, args);
}
}
I am getting this error when starting application
2017-06-20 09:13:42.720 ERROR 15296 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [se.telenor.bapigateway.GatewayApplication]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.cloud.netflix.zuul.ZuulConfiguration
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:616)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:299)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:198)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:308)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:270)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
at se.telenor.bapigateway.GatewayApplication.main(GatewayApplication.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.cloud.netflix.zuul.ZuulConfiguration
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:163)
at org.springframework.context.annotation.ConfigurationClassParser.retrieveBeanMethodMetadata(ConfigurationClassParser.java:380)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:314)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:606)
... 25 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/ServletRegistrationBean
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:152)
... 29 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.ServletRegistrationBean
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
org.springframework.boot.context.embedded.ServletRegistrationBean was deprecated in spring-boot version 1.4 and its replacement, org.springframework.boot.web.servlet.ServletRegistrationBean, was introduced. The deprecated class was removed in spring-boot version 1.5. Something in your app or in one of its dependencies needs to be updated to use the replacement.
for spring-boot version 1.5.x use Dalston.RELEASE in place of Brixton.SR5 in your dependency config:
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.RELEASE</version>
It is due to depricated dependency in spring-boot. Use following dependency
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.RELEASE</version>
</dependency>
Please find initial working code
Using the Spring Start site, it looks like the correct Spring Cloud Version for Spring Boot 1.5 is:
Edgware.SR5 for Spring Boot >=1.5.0.RELEASE and <=1.5.19.RELEASE and
Edgware.BUILD-SNAPSHOT for Spring Boot >=1.5.999.BUILD-SNAPSHOT and <2.0.0.M1
The full output from the Spring Starter Actuator Info page,
"spring-cloud": {
"Edgware.SR5": "Spring Boot >=1.5.0.RELEASE and <=1.5.19.RELEASE",
"Edgware.BUILD-SNAPSHOT": "Spring Boot >=1.5.999.BUILD-SNAPSHOT and <2.0.0.M1",
"Finchley.M2": "Spring Boot >=2.0.0.M3 and <2.0.0.M5",
"Finchley.M3": "Spring Boot >=2.0.0.M5 and <=2.0.0.M5",
"Finchley.M4": "Spring Boot >=2.0.0.M6 and <=2.0.0.M6",
"Finchley.M5": "Spring Boot >=2.0.0.M7 and <=2.0.0.M7",
"Finchley.M6": "Spring Boot >=2.0.0.RC1 and <=2.0.0.RC1",
"Finchley.M7": "Spring Boot >=2.0.0.RC2 and <=2.0.0.RC2",
"Finchley.M9": "Spring Boot >=2.0.0.RELEASE and <=2.0.0.RELEASE",
"Finchley.RC1": "Spring Boot >=2.0.1.RELEASE and <2.0.2.RELEASE",
"Finchley.RC2": "Spring Boot >=2.0.2.RELEASE and <2.0.3.RELEASE",
"Finchley.SR3": "Spring Boot >=2.0.3.RELEASE and <2.0.999.BUILD-SNAPSHOT",
"Finchley.BUILD-SNAPSHOT": "Spring Boot >=2.0.999.BUILD-SNAPSHOT and <2.1.0.M3",
"Greenwich.M1": "Spring Boot >=2.1.0.M3 and <2.1.0.RELEASE",
"Greenwich.RELEASE": "Spring Boot >=2.1.0.RELEASE and <2.1.4.BUILD-SNAPSHOT",
"Greenwich.BUILD-SNAPSHOT": "Spring Boot >=2.1.4.BUILD-SNAPSHOT"
},

Spring integration with Spring boot 1.4.0. Getting error

I upgraded from Spring boot 1.2.3 to 1.4.0 alongwith dependencies for Spring integration i.e. 4.3.1
I'm sending JSON content but getting an error on request submit. Previously it was working fine with Spring boot 1.2.3 and spring integration 4.1.2
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-ws</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-xml</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-file</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-http</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<int-http:inbound-gateway id="controller" request-channel="requestChannel" reply-channel="responseChannel" path="/services/test"
supported-methods="POST" request-payload-type="com.example.SampleRequest" >
<int-http:request-mapping consumes="application/json"
produces="application/json" />
</int-http:inbound-gateway>
public class SampleRequest {
private String requestType;
private String reference;
private String nicNumber;
}
Error :
2016-12-20 15:06:14 [http-nio-8080-exec-1] DEBUG o.s.w.t.h.WebServiceMessageReceiverHandlerAdapter : Accepting incoming [org.springframework.ws.transport.http.HttpServletConnection#74518c78] at [http://localhost:8080/services/test]
2016-12-20 15:06:14 [http-nio-8080-exec-1] ERROR c.s.xml.internal.messaging.saaj.soap : SAAJ0537: Invalid Content-Type. Could be an error message instead of a SOAP message
2016-12-20 15:06:14 [http-nio-8080-exec-1] DEBUG o.s.w.t.h.MessageDispatcherServlet : Could not complete request
org.springframework.ws.soap.SoapMessageCreationException: Could not create message from InputStream: Invalid Content-Type:application/json. Is this an error message instead of a SOAP response?; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Invalid Content-Type:application/json. Is this an error message instead of a SOAP response?
at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:216)
at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:60)
at org.springframework.ws.transport.AbstractWebServiceConnection.receive(AbstractWebServiceConnection.java:92)
at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:87)
at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:61)
at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:293)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Invalid Content-Type:application/json. Is this an error message instead of a SOAP response?
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.identifyContentType(MessageImpl.java:655)
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:301)
at com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl.<init>(Message1_1Impl.java:65)
at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl.createMessage(SOAPMessageFactory1_1Impl.java:63)
Spring boot 1.2.3 didn't have WebService (SOAP) support. Right now we have WebServicesAutoConfiguration since 1.4.0. There you can find this code:
String path = this.properties.getPath();
String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*");
ServletRegistrationBean registration = new ServletRegistrationBean(servlet,
urlMapping);
Where you bump unexpected default in the WebServicesProperties:
#NotNull
#Pattern(regexp = "/[^?#]*", message = "Path must start with /")
private String path = "/services";
So, that newly created MessageDispatcherServlet intercepts all your requests because you expect them on the path="/services/test".
If you are not interested in the SOAP server side in your application you can just exclude WebServicesAutoConfiguration from auto-configuration.
Otherwise consider to change your service URL or specify something another for the spring.webservices.path application property.

Resources