Issue while using Spring IO Platform - spring

I have created a Spring MVC Project with Maven. I am new to Spring framework. With reference to the following tutorial, I am trying to analyze the Spring Data JPA repositories. I have enabled the Spring IO platform in my pom.xml with the following configuration:
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>1.1.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
After that I have added the other required dependencies without mentioning the version as follows:
<!-- Database (H2) -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<!-- DataSource (HikariCP) -->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</dependency>
<!-- JPA Provider (Hibernate) -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<!-- Spring Data JPA -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
The tutorial says that Spring IO platform will take care of the versions. But When I try to do this I'm getting an error in my pom.xml saying that
Project build error: 'dependencies.dependency.version' for com.h2database:h2:jar is missing.
Any suggestions that how can I use and enable Spring IO?

The following POM will work:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<groupId>test</groupId>
<artifactId>test</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Database (H2) -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<!-- DataSource (HikariCP) -->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</dependency>
<!-- JPA Provider (Hibernate) -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<!-- Spring Data JPA -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>1.1.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
The important part is to put Spring IO dependency inside the dependencyManagement section of the POM. This is because it has the scope import.

Related

Upgraded spring boot from 2.1.9 to 2.2.0 , now getting exception while starting

I upgraded spring boot from 2.1.9 to 2.2.0 now I am facing some exception while starting the application
java : openjdk11
spring-boot: v2.2.0.RELEASE
I tried by deleting the jar from this below location and did mvn clean install, still no luck.
.m2/repository/org/springframework/boot/spring-boot-actuator/2.2.0.RELEASE/spring-boot-actuator-2.2.0.RELEASE.jar
error :
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.cloud.client.discovery.health.DiscoveryCompositeHealthIndicator.<init>(DiscoveryCompositeHealthIndicator.java:41)
The following method did not exist:
org.springframework.boot.actuate.health.CompositeHealthIndicator.<init>(Lorg/springframework/boot/actuate/health/HealthAggregator;)V
The method's class, org.springframework.boot.actuate.health.CompositeHealthIndicator, is available from the following locations:
jar:file:/C:/Users/regosa/.m2/repository/org/springframework/boot/spring-boot-actuator/2.2.0.RELEASE/spring-boot-actuator-2.2.0.RELEASE.jar!/org/springframework/boot/actuate/health/CompositeHealthIndicator.class
It was loaded from the following location:
file:/C:/Users/regosa/.m2/repository/org/springframework/boot/spring-boot-actuator/2.2.0.RELEASE/spring-boot-actuator-2.2.0.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.boot.actuate.health.CompositeHealthIndicator
Pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxxxx.business.workflow</groupId>
<artifactId>xxxxx-component-workflow-starter</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>xxxxx-component-workflow-starter</name>
<description>xxxxx-component-workflow-starter</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
<jaxb-runtime.version>2.4.0-b180830.0438</jaxb-runtime.version>
<spring-cloud.version>Greenwich.M1</spring-cloud.version>
<zeebe-version>0.20.1</zeebe-version>
<google-guava.version>27.0.1-jre</google-guava.version>
<xxxxx.version>1.0</xxxxx.version>
<swagger.version>2.9.2</swagger.version>
<jjwt.version>0.9.1</jjwt.version>
<json.version>20180813</json.version>
<slf4j-api.version>1.7.25</slf4j-api.version>
<mysql.version>8.0.11</mysql.version>
<mongo-java-driver.version>3.10.1</mongo-java-driver.version>
<commons-io.version>2.6</commons-io.version>
<commons-lang.version>2.6</commons-lang.version>
<commons-pool2.version>2.5.0</commons-pool2.version>
<redis.version>3.1.0</redis.version>
<velocity.version>1.7</velocity.version>
<velocity-tools.version>2.0</velocity-tools.version>
<logstash-logback-encoder.version>5.3</logstash-logback-encoder.version>
<httpclient.version>4.5.6</httpclient.version>
<jaxb-runtime.version>2.4.0-b180830.0438</jaxb-runtime.version>
<env>local</env>
</properties>
<dependencies>
<!-- Start: Spring Libraries -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<!-- End: Spring Libraries -->
<!-- Adding JAXB Runtime since it is not shipped with JDK 9+ -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb-runtime.version}</version>
</dependency>
<!-- Start: xxxxx Libraries -->
<dependency>
<groupId>com.xxxxx</groupId>
<artifactId>xxxxx-entity</artifactId>
<version>${xxxxx.version}</version>
</dependency>
<dependency>
<groupId>com.xxxxx</groupId>
<artifactId>xxxxx-redis</artifactId>
<version>${xxxxx.version}</version>
</dependency>
<dependency>
<groupId>com.xxxxx</groupId>
<artifactId>xxxxx-mongo</artifactId>
<version>${xxxxx.version}</version>
</dependency>
<dependency>
<groupId>com.xxxxx</groupId>
<artifactId>xxxxx-util</artifactId>
<version>${xxxxx.version}</version>
</dependency>
<dependency>
<groupId>com.xxxxx.model</groupId>
<artifactId>xxxxx-model</artifactId>
<version>${xxxxx.version}</version>
</dependency>
<dependency>
<groupId>com.xxxxx.service</groupId>
<artifactId>xxxxx-common-service</artifactId>
<version>${xxxxx.version}</version>
</dependency>
<dependency>
<groupId>com.xxxxx.service</groupId>
<artifactId>xxxxx-common-messaging</artifactId>
<version>${xxxxx.version}</version>
</dependency>
<dependency>
<groupId>com.xxxxx.service</groupId>
<artifactId>xxxxx-common-security</artifactId>
<version>${xxxxx.version}</version>
</dependency>
<!-- End: xxxxx Libraries -->
<!-- Adding Zeebe client as part of the Spring Startup -->
<dependency>
<groupId>io.zeebe</groupId>
<artifactId>zeebe-client-java</artifactId>
<version>${zeebe-version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${google-guava.version}</version>
</dependency>
<!-- Logstash Log Encoder -->
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>${logstash-logback-encoder.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>${mongo-java-driver.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons-lang.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>${commons-pool2.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>${redis.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>
<!-- Start: Swagger Libraries -->
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
<!-- End: Swagger Libraries -->
<!-- Start: Spring Boot and Security Test Libraries -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- End: Spring Boot and Security Test Libraries -->
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>xxxxx-component-workflow-starter</finalName>
<filters>
<filter>${env}-build.properties</filter>
</filters>
<resources>
<resource>
<filtering>true</filtering>
<directory>${project.basedir}/src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<release>${java.version}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>com.xxxxx.business.workflow.component.starter</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
New exception :
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.data.rest.core.support.UnwrappingRepositoryInvokerFactory.<init>(UnwrappingRepositoryInvokerFactory.java:57)
The following method did not exist:
org.springframework.plugin.core.PluginRegistry.of(Ljava/util/List;)Lorg/springframework/plugin/core/PluginRegistry;
The method's class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:
jar:file:/C:/Users/regosa/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class
It was loaded from the following location:
file:/C:/Users/regosa/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
springfox.documentation.spring.web.plugins.DocumentationPluginsManager.createContextBuilder(DocumentationPluginsManager.java:152)
The following method did not exist:
org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang/Object;Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/Plugin;
The method's class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:
jar:file:/C:/Users/regosa/.m2/repository/org/springframework/plugin/spring-plugin-core/2.0.0.RELEASE/spring-plugin-core-2.0.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class
It was loaded from the following location:
file:/C:/Users/regosa/.m2/repository/org/springframework/plugin/spring-plugin-core/2.0.0.RELEASE/spring-plugin-core-2.0.0.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry
How to resolve this issue?
In short, issue is due to spring cloud and spring boot version incompatibility, spring boot 2.2.X requires Hoxton release train instead of Greenwich. See below for more info.
This issue is due to spring-cloud.version incompatibility. As per spring cloud documentation link(https://spring.io/projects/spring-cloud), below is the spring boot compatibility:
Release train Spring Boot compatibility
Release Train Boot Version
Hoxton 2.2.x
Greenwich 2.1.x
So if you are updating spring boot to 2.2.x then update to Hoxton release train for spring cloud as well i.e Hoxton.RC1(https://spring.io/blog/2019/10/25/spring-cloud-hoxton-rc1-released)
P.S: As per spring cloud Milestone page Hoxton.RELEASE in due on Nov 18, 2019 (https://github.com/spring-cloud/spring-cloud-release/milestones)
Actually springfox ist not compatible with Spring-Boot 2.2.0. It seems that springfox is dead at all.
Instead you can use: SpringDoc OpenApi
This seems to be a known issue: https://github.com/spring-cloud/spring-cloud-netflix/issues/3410
If you use Spring Cloud dependencies in your Spring Boot application make sure you have the correct Spring Cloud version on classpath! Only Spring Cloud's "Hoxton" (https://spring.io/blog/2019/08/19/spring-cloud-hoxton-m2-released) release train currently support Spring Boot 2.2.
Update your springfox-swagger version. I have upgraded springfox 2.9.2 running with boot 2.2.2
SpringFox needs version 1.2.0 version but Spring Boot 2.2.2 itself does not pull this in.So you somehow got spring-plugin-core-1.2.0.RELEASE in your classpath.Then it will work fine
As user10871691 and P3arl have already noted, the spring-plugin-core dependency is resolved with the wrong version 1.2.0.RELEASE. In order to force usage of the correct 2.0.0.RELEASE, you have to
EITHER exclude the wrong transitive dependency and specify the correct one,
OR pin (!) that dependency version in your pom.xml. This is done in the <dependenciesManagement> block, not in the <dependencies> block.
Example for Springfox 3.0.0 using version pinning in the <dependenciesManagement> block:
<spring-plugin-core.version>2.0.0.RELEASE</spring-plugin-core.version>
<springfox.version>3.0.0</springfox.version>
...
<dependencyManagement>
<dependencies>
<!-- Fix wrong resolved `spring-plugin-core` dependency version for springfox -->
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>${spring-plugin-core.version}</version>
</dependency>
<!-- API Documentation -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>${springfox.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- API Documentation -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
</dependency>
</dependencies>
<springBootVersion>2.2.4.RELEASE</springBootVersion>
Supported Cloud version. Hoxton.M2
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.M2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
...
</dependencies>
It's strange. The spring-plugin-core version should be 2.0.0, not 1.2.0. Let's upgrade it:
<!-- https://mvnrepository.com/artifact/org.springframework.plugin/spring-plugin-core -->
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
I was also facing the same issue and after adding the updated plugin-core dependency. It is resolved now.
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
If spring-plugin-core-1.2.0.RELEASE is not working in your project then another approach is that to use springfox-swagger with 3.0.0-SNAPSHOT version. For this version it has different repository.
Repository url : http://oss.jfrog.org/artifactory/oss-snapshot-local/
It will use #EnableSwagger2WebMvc annotation instead of #EnableSwagger2.
I upgraded to Springfox Swagger2 to 3.0.0 version and spring plugin code to 2.0.0.RELEASE version. It worked for me.
Spring Boot Version - 2.3.9.RELEASE
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>

Whitelabel Error page, Type:Not Found Status:404

We recently upgraded our spring boot version from 1.5.10 to 2.1.2 and I'm facing an issue. When the service is deployed on j boss server, it says service Not found and throws an error of White label error page when I call the service in the swagger by https://host:port/serviceName/swagger-ui.html but if i call https://host:port/swagger-ui.html I could access the service and everything works fine. Can some one let me know what will be the issue. Appreciated for the help.
There is nothing change in the pom.xml or bootstrap.yml, I have just upgraded the spring boot versions. Everything else is same as previous.
Below is the POM.Xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.goo.foo</groupId>
<artifactId>security-service</artifactId>
<version>1.2.3</version>
<properties>
<dep.scope>compile</dep.scope>
<java.version>1.8</java.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<ojdbc.version>12.1.0.2</ojdbc.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<springfox-version>2.6.1</springfox-version>
<config.version>2.1.0.RELEASE</config.version>
<admin.version>2.1.0</admin.version>
<consul-starter.version>2.1.0.RELEASE</consul-starter.version>
<cloud-consul.version>2.1.0.RELEASE</cloud-consul.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath />
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-consul-dependencies</artifactId>
<version>${cloud-consul.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!--SpringFox dependencies -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-version}</version>
<scope>${dep.scope}</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-version}</version>
<scope>${dep.scope}</scope>
</dependency>
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.7.0</version>
</dependency>
<!-- Oracle JDBC driver -->
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc7</artifactId>
<version>${ojdbc.version}</version>
<scope>${dep.scope}</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<!-- Consul properties -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
<version>${consul-starter.version}</version>
</dependency>
<!-- Spring config server - external properties -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
<version>${config.version}</version>
</dependency>
<!-- Spring boot admin client - monitoring the purpose -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>${admin.version}</version>
</dependency>
<!-- jedis cache -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Seems like you "lost" your context-path. I guess you previously specified it using the now deprecated server.contextPath=/serviceName in some form. There are several ways to set it, but the way I do it is configuring it in the application.yaml
server:
servlet:
context-path: serviceName
or application.properties
server.servlet.context-path=/serviceName
or you could set the context-path by specifying it as a command line argument
java -jar app.jar --server.servlet.context-path=/serviceName
This is just some of the options available. Figure out how you set it before and replace that with server.servlet.context-path

#Configuration annotation is not recognized with springframework 5.0.4.RELEASE

I had been using springframework version 5.0.2.RELEASE so far. But recently, i switched to newer version 5.0.4.RELEASE. However, after this switch of JARs, #Configuration annotation is not recognized as predefined annotation in my project. Eclipse is asking me if i would like to create it.
Is there any change in 5.0.4.REL version of springframework, which would stop recognizing the #Configuration annotation?
My POM :
<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>
<groupId>com.drk.demo</groupId>
<artifactId>springsecurity</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>springsecurity Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<springframework.version>5.0.4.RELEASE</springframework.version>
<springsecurity.version>5.0.2.RELEASE</springsecurity.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- Servlet, JSP and JSTL support -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springframework.version}</version>
</dependency>
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${springsecurity.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${springsecurity.version}</version>
</dependency>
</dependencies>
<build>
<finalName>springsecurity</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Error while using the #Configuration annotation :
With mere change of modifying the springframework version in my POM file from 5.0.4.REL to 5.0.2.REL, my eclipse project starts to recognize the #Configuration annotation.
delete /clean your .m2 directory , and load maven file again for new spring version

microservices spring cloud, security, oauth2, Netflix OSS #EnableOAuth2Resource not exist in spring security 1.1

I use this tutorial http://callistaenterprise.se/blogg/teknik/2015/04/27/building-microservices-part-3-secure-APIs-with-OAuth/ to create organized webservices project based on Netflix OSS by using the following technologies spring cloud, boot, security, oauth2.
I'm using spring security 1.1 and I see annotation #EnableOAuth2Resource not exist in the spring security 1.1 what I should do?
Maven Dependencies
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>auctionblox</groupId>
<artifactId>auth-microservice</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Brixton.RELEASE</version>
</parent>
<properties>
<!-- Stand-alone RESTFul application for testing only -->
<start-class>io.pivotal.microservices.services.Main</start-class>
</properties>
<dependencies>
<dependency>
<!-- Setup Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!--<dependency>-->
<!--<!– Setup Spring MVC & REST, use Embedded Tomcat –>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-web</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<!-- Setup Spring Data common components -->
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<dependency>
<!-- Testing starter -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<!-- Setup Spring Data JPA Repository support -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.0.10.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<!-- Eureka service registration -->
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<dependency>
<!-- Spring Cloud starter -->
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<!-- In-memory database for testing/demos -->
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
use #EnableResourceServer instead of #EnableOAuth2Resource
With Spring Boot 1.2 we had to use Spring Cloud Security for the #EnableOAuth2Resource annotation. While, with Spring Boot 1.3 the Spring Cloud dependency can be removed and the annotation replaced with #EnableResourceServer annotation from Spring Security OAuth2.
For more details: https://spring.io/blog/2015/11/30/migrating-oauth2-apps-from-spring-boot-1-2-to-1-3#resource-server

Calling KieScanner throws ClassNotFoundException

I have several Drools projects and would like to be able to dynamically load rules changes. The projects all work fine until I tried to add KieScanner to them. I followed the directions here: http://docs.jboss.org/drools/release/6.0.1.Final/drools-docs/html/DroolsReleaseNotesChapter.html#d0e515
I am using drools 6.1.0.Final with Wildfly 8.0.0.Final
The documentation indicates that having the dependency for the kie-ci in my class path was enough. Clearly either I am doing something wrong or the documentation is wrong.
The project builds but when it is called, I get this trace:
10:21:17,946 ERROR [io.undertow.request] (default task-2) UT005023: Exception handling request to /catalog/vetec/search/facets/term: org.jboss.resteasy.spi.UnhandledException: javax.enterprise.inject.CreationException
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) [resteasy-jaxrs-3.0.6.Final.jar:]
Caused by: java.lang.NoClassDefFoundError: org/apache/maven/repository/internal/MavenRepositorySystemSession
at org.kie.scanner.MavenRepository.getMavenRepository(MavenRepository.java:73) [kie-ci-6.1.0.Final.jar:6.1.0.Final]
at org.kie.scanner.ArtifactResolver.(ArtifactResolver.java:36) [kie-ci-6.1.0.Final.jar:6.1.0.Final]
at org.kie.scanner.KieRepositoryScannerImpl.getArtifactResolver(KieRepositoryScannerImpl.java:87) [kie-ci-6.1.0.Final.jar:6.1.0.Final]
at org.kie.scanner.KieRepositoryScannerImpl.getArtifactVersion(KieRepositoryScannerImpl.java:108) [kie-ci-6.1.0.Final.jar:6.1.0.Final]
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl$KieModuleRepo.load(KieRepositoryImpl.java:281) [drools-compiler-6.1.0.Final.jar:6.1.0.Final]
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl$KieModuleRepo.load(KieRepositoryImpl.java:267) [drools-compiler-6.1.0.Final.jar:6.1.0.Final]
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:90) [drools-compiler-6.1.0.Final.jar:6.1.0.Final]
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:77) [drools-compiler-6.1.0.Final.jar:6.1.0.Final]
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:97) [drools-compiler-6.1.0.Final.jar:6.1.0.Final]
at com.sial.rules.cdi.KSessionContextProvider.(KSessionContextProvider.java:49) [sial-rules-0.0.1-SNAPSHOT.jar:]
Here is the pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sial.rules</groupId>
<artifactId>sial-rules</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>JBoss Repository</id>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<!-- Added to ensure that we have the correct DROOLS/JBOSS versions -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-bom</artifactId>
<version>6.1.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-with-tools</artifactId>
<version>8.0.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-with-resteasy</artifactId>
<version>8.0.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-decisiontables</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-persistence-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>knowledge-api</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-internal</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<exclusions>
<exclusion>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0-rc1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.drools</groupId>
<artifactId>drools-maven-plugin</artifactId>
<version>6.0.0.CR5</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
This business rules project is itself incorporated into the actual WARs that are deployed to Wildfly.This is the dependency used in the application poms:
<dependency>
<groupId>com.sial.rules</groupId>
<artifactId>sial-rules</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
I recently discovered that the extra dependency breaks our Arquillian Unit tests. Since Arquillian has a completely different maven integration, my best guess is that this is a bug in KIE. It is very similar to BZ1098018
Adding this extra dependency "fixes" the issue when the code actually calls kie-ci, however with this dependency our Arquillian tests fail to deploy.
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-aether-provider</artifactId>
<version>3.0.5</version>
</dependency>
You should not need to declare the additional maven, aether and other dependencies manually. The kie-ci should transitively depend on everything it needs. If you look at the pom.xml of the kie-ci https://github.com/droolsjbpm/drools/blob/6.1.0.Final/kie-ci/pom.xml the dependencies you added are also listed there, so Maven resolves them automatically.
This seems to be either some weird bug or misconfiguration. I presume you have the following in your pom:
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<version>6.1.0.Final</version>
</dependency>
Could you post your whole pom?
The problem is that kie-ci includes an older version of maven (3.0.5) than does Arquillian (3.1.1) Specifically the maven-aether-provider. Arquillian (really ShrinkWrap) really wants to use the newer version.
I tried forcing the 3.0.5 version in the pom.xml but get the issue of the resolver.
This is the error:
java.lang.UnsupportedOperationException: Unable to boostrap Aether repository system. Make sure you're running Maven 3.1.0 or newer.
So basically kie 6.1.0.Final is incompatible with Arquillian 1.1.5.Final
I will have to see if the Kie 6.2.0CR3 release will work

Resources