My Spring cloud project has been working all the time until today. The error happened in Spring cloud.
in POM:
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Brixton.BUILD-SNAPSHOT</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
In bootstrap:
spring:
application:
name: configserver
profiles:
active: native
In main app:
#Configuration
#EnableAutoConfiguration
#EnableDiscoveryClient
#EnableConfigServer
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
When I tried to run, i got this error:
java.lang.NoSuchMethodError: org.springframework.cloud.config.environment.Environment.<init>(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
at org.springframework.cloud.config.server.PassthruEnvironmentRepository.findOne(PassthruEnvironmentRepository.java:64) ~[spring-cloud-config-server-1.1.0.BUILD-SNAPSHOT.jar:1.1.0.BUILD-SNAPSHOT]
at org.springframework.cloud.config.server.NativeEnvironmentRepository.findOne(NativeEnvironmentRepository.java:105) ~[spring-cloud-config-server-1.1.0.BUILD-SNAPSHOT.jar:1.1.0.BUILD-SNAPSHOT]
at org.springframework.cloud.config.server.EnvironmentController.labelled(EnvironmentController.java:111) ~[spring-cloud-config-server-1.1.0.BUILD-SNAPSHOT.jar:1.1.0.BUILD-SNAPSHOT]
at org.springframework.cloud.config.server.EnvironmentController.defaultLabel(EnvironmentController.java:97) ~[spring-cloud-config-server-1.1.0.BUILD-SNAPSHOT.jar:1.1.0.BUILD-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_51]
Why did this happen? Is spring cloud being updated now?
Related
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>
I had an embedded project, this was a war, I configured Spring Boot and this was deployed sucessfully on Wildfly 13.
My problem is that I moved the repositories and services of Spring Boot to another module, another jar, and from the web application, I added the dependency to this jar. I changed the package name of the classes, the EntityScan and the ComponentScan to the new packages, but I am having the same error.
The goal is to deploy sucessfully my web application on Wildfly 13 using this component separated, the business logic.
I am running this on Java 8, Wildfly 13, Maven 3.3.9 and Spring Boot 2.1.2.RELEASE.
I've tried a lot of suggestions in the Internet, but I coudn't.
This class I put in the jar separated to the web application:
#Configuration
#EnableAutoConfiguration
#ComponentScan(basePackages = {"io.quarzo.service"})
#EntityScan(basePackages = "io.quarzo.domain.model.entities")
#EnableJpaRepositories(basePackages = "io.quarzo.service", entityManagerFactoryRef = "entityManagerFactory")
#EnableTransactionManagement
public class RepositoryConfiguration {
#Bean
public DataSource jndiDataSource() throws IllegalArgumentException, NamingException {
JndiObjectFactoryBean bean = new JndiObjectFactoryBean();
bean.setJndiName("java:/QuarzoDs");
bean.setProxyInterface(DataSource.class);
bean.setLookupOnStartup(true);
bean.afterPropertiesSet();
return (DataSource) bean.getObject();
}
}
This class I put in the web application:
#SpringBootApplication
public class QuarzoApiApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(QuarzoApiApplication.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(applicationClass);
}
private static Class<QuarzoApiApplication> applicationClass = QuarzoApiApplication.class;
}
#RestController
class HelloController {
#Autowired
private IBuserServiceImp buserService;
#RequestMapping("/hello/{name}")
String hello(#PathVariable String name) {
return "Hi ------***--- " + buserService.findAll() + " !";
}
}
pom.xml in the jar file:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>io.quarzo.web</groupId>
<artifactId>quarzo-domain</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.10.Final</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
<scope>runtime</scope>
</dependency>
</dependencies>
pom.xml of the web application:
<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>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarzo.web</groupId>
<artifactId>quarzo-service</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>io.quarzo.web</groupId>
<artifactId>quarzo-domain</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
The stacktrace is too large, but I cut the messages:
14:57:54,857 ERROR [org.jboss.as.server] (management-handler-thread - 3) WFLYSRV0014: Replacement of deployment "quarzo-api.war" by deployment "quarzo-api.war" was rolled back with the following failure message:
{
"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"quarzo-api.war\".WeldStartService" => "Failed to start service
Caused by: org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:
Exception 0 :
javax.enterprise.inject.UnsatisfiedResolutionException: Unable to resolve a bean for 'javax.persistence.EntityManager' with qualifiers [#javax.enterprise.inject.Default(), #javax.enterprise.inject.Any()].
at org.springframework.data.jpa.repository.cdi.JpaRepositoryExtension.createRepositoryBean(JpaRepositoryExtension.java:120)
at org.springframework.data.jpa.repository.cdi.JpaRepositoryExtension.afterBeanDiscovery(JpaRepositoryExtension.java:96)
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.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95)
at org.jboss.weld.injection.MethodInvocationStrategy$SpecialParamPlusBeanManagerStrategy.invoke(MethodInvocationStrategy.java:144)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:330)
at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:123)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:308)
at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:286)
at org.jboss.weld.util.Observers.notify(Observers.java:172)
at org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:285)
at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:273)
at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:177)
at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:171)
at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:53)
at org.jboss.weld.bootstrap.events.AbstractDefinitionContainerEvent.fire(AbstractDefinitionContainerEvent.java:44)
at org.jboss.weld.bootstrap.events.AfterBeanDiscoveryImpl.fire(AfterBeanDiscoveryImpl.java:75)
at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:456)
at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:86)
at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:96)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1736)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1698)
at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1556)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
at java.lang.Thread.run(Thread.java:748)
"},
"WFLYCTL0288: One or more services were unable to start due to one or more indirect dependencies not being available." => {
"Services that were unable to start:" => [
"jboss.deployment.unit.\"quarzo-api.war\".CdiValidatorFactoryService",
"jboss.deployment.unit.\"quarzo-api.war\".component.\"com.sun.faces.config.ConfigureListener\".WeldInstantiator",
"jboss.deployment.unit.\"quarzo-api.war\".component.\"javax.faces.webapp.FacetTag\".WeldInstantiator",
"jboss.deployment.unit.\"quarzo-api.war\".component.\"javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV\".WeldInstantiator",
"jboss.deployment.unit.\"quarzo-api.war\".component.\"javax.servlet.jsp.jstl.tlv.ScriptFreeTLV\".WeldInstantiator",
"jboss.deployment.unit.\"quarzo-api.war\".component.\"org.jboss.weld.module.web.servlet.WeldInitialListener\".WeldInstantiator",
.
.
.
],
"Services that may be the cause:" => [
"jboss.clustering.web.route.default-server",
"jboss.deployment.unit.\"quarzo-api.war\".component.\"com.sun.faces.config.ConfigureListener\".START",
"jboss.deployment.unit.\"quarzo-api.war\".component.\"com.sun.faces.config.ConfigureListener\".WeldInstantiator",
"jboss.deployment.unit.\"quarzo-api.war\".component.\"javax.faces.webapp.FacetTag\".START",
"jboss.deployment.unit.\"quarzo-api.war\".component.\"javax.faces.webapp.FacetTag\".WeldInstantiator",
"jboss.deployment.unit.\"quarzo-api.war\".component.\"javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV\".START",
.
.
.
"org.wildfly.clustering.infinispan.cache-container.web",
"org.wildfly.clustering.infinispan.cache-container-configuration.hibernate",
"org.wildfly.clustering.infinispan.cache-container-configuration.hibernate.transport",
"org.wildfly.clustering.infinispan.cache-container-configuration.server",
"org.wildfly.clustering.infinispan.cache-container-configuration.server.transport",
"org.wildfly.clustering.infinispan.cache-container-configuration.web",
"org.wildfly.clustering.infinispan.cache-container-configuration.web.transport",
"org.wildfly.clustering.infinispan.default-cache.ejb",
"org.wildfly.clustering.infinispan.default-cache.web",
"org.wildfly.clustering.infinispan.default-cache-configuration.server",
"org.wildfly.clustering.infinispan.default-cache-configuration.web"
]
}
}
I solved this, the problem was I had a beans.xml in my jar project. I deleted the beans.xml and it works
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.
It seems that current release of spring-cloud-consul(which is 1.2.2-snapshot at this moment) is not compatible with spring-boot-2.0.0.M1.
As a new comer of microservice, i'm trying to integrate consul into my project to support service registry, but the project failed to start after I insert the consul starter into the pom.xml.
All right, here comes the sample code:
//DemoApplication.java
#SpringBootApplication
#EnableDiscoveryClient
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
//pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version> <!-- evertything works fine -->
<!--<version>2.0.0.M1</version>--> <!-- project fail to start -->
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<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.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
</dependency>
</dependencies>
....some other irrelevant configs
//application.properties
spring.cloud.consul.port = 8500
spring.cloud.consul.host = localhost
As above code shows, everything works fine if using spring-boot-1.5.4.RELEASE, while it failed to start project when using spring-boot-2.0.0.M1, with complain of following:
13:52:15.444 [main] ERROR org.springframework.boot.SpringApplication - Application startup failed
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:157)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:98)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:64)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:72)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:328)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1278)
at com.cmcc.syw.demo.DemoApplication.main(DemoApplication.java:11)
Any suggestions about the reason?
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"
},