Spring-Boot can't connect programmatically to AWS SSM locally - spring

I'm using:
Open JDK 11
Spring boot 2.6.6
MacBook (my local dev environment)
I can connect to AWS from the command line (java -jar app.war) if I do the following:
export AWS_PROFILE=me#example.com
export AWS_ACCESS_KEY_ID=AccessKeyHere
# both AWS_SECRET_KEY and AWS_SECRET_ACCESS_KEY work, so I'm leaving both
export AWS_SECRET_KEY=SecretKeyHere
export AWS_SECRET_ACCESS_KEY=SecretKeyHereIwasTryingAbunchOfDifferentOnesSoOneExportIsNotNeeded
export AWS_DEFAULT_REGION=us-east-1
But, it fails if I only do it via the application.properties such as (unset all the exports above):
spring.config.import=aws-parameterstore:
aws.paramstore.enabled=true
aws.paramstore.prefix=/config
aws.paramstore.defaultContext=contextNameHere
aws.paramstore.profileSeparator=_
# ################################################# #
# Locally, without this line, I get this error:
# Caused by: com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
# ################################################# #
aws.paramstore.region=us-east-1
cloud.aws.stack.auto=false
cloud.aws.region.auto=false
cloud.aws.region.static=us-east-1
#
# I'll leave these here for now as I think these might be required when running on AWS/EC2
#
cloud.aws.credentials.profile-name=me#example.com
cloud.aws.credentials.access-key=AccessKeyHere
cloud.aws.credentials.secret-key=SecretKeyHere
I believe I have the correct config names (listed here https://docs.spring.io/spring-cloud-aws/docs/2.2.3.RELEASE/reference/html/appendix.html), but initially I had old AWS values from a training class higher up in my .bashrc so things kept failing and it didn't make sense from the docs I was reading.
When I finally figured out the old values where higher up in the .bashrc, removed and then reset everything, things started working, but at that point I had been throwing things at the wall hoping something would stick. While I have done quite a bit of cleanup, I do have more to do; but, with the exports everything works well, without, it fails with this error:
Caused by: com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain: [EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)), SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), WebIdentityTokenCredentialsProvider: To use assume role profiles the aws-java-sdk-sts module must be on the class path., com.amazonaws.auth.profile.ProfileCredentialsProvider#3eeb318f: No AWS profile named 'default', com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper#52045dbe: Failed to connect to service endpoint: ]
NOTE: whether I set the export's or unset them, I never change the application.properties, so it's the export's that do the trick of connecting to AWS SSM.
Now, if this isn't needed running on an EC2 instance (our TechOps current plan), I'll just update the developer guides within confluence to include those exports (or system variables for windows developers), but being able to do everything within the application.properties would be the easiest, most preferable route.
What i believe is the relevant parts of 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
...
<properties>
<log4j.version>2.4</log4j.version>
<org.slf4j-version>1.7.10</org.slf4j-version>
<java.version>11</java.version>
<spring-cloud.version>2021.0.1</spring-cloud.version>
</properties>
<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>
<dependencies>
<!-- ********************************** -->
<!-- Needed for SSM -->
<!-- ********************************** -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-aws</artifactId>
<version>2.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-starter-aws-parameter-store-config</artifactId>
<version>2.3.0</version>
</dependency>
...
</dependencies>
...
</project>

Related

Liquibase fails with MongoDB

I want to get an example of liquibase, Spring and MongoDB all together. In order to do so, I created a Spring project using Spring Initializr with Spring Data MongoDB as dependency. The project already connects to the database and now I would like to use liquibase. I followed the instructions from liquibase using the maven approach but if I run the maven command mvn liquibase:status I will get the following error:
Unexpected error running Liquibase: Cannot find database driver: com.mongodb.client.MongoClients.<init>()
It looks like this problem has been already reported to liquibase but if there is a solution it hasn't been posted in the issue.
I tried as well to use the CLI option by adding the jars to the lib folder of the liquibase installation. I got the same error if I run liquibase status
I have created a repo in GitHub to show the problem. Here there is some relevant configuration of the code:
pom.xml
<project>
...
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.3</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
...
<properties>
<liquibase-mongo-ext.version>4.14.0</liquibase-mongo-ext.version>
<liquibase-maven-plugin.version>4.2.0</liquibase-maven-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-mongodb</artifactId>
<version>${liquibase-mongo-ext.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase-maven-plugin.version}</version>
<configuration>
<propertyFile>liquibase.properties</propertyFile>
</configuration>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-mongodb</artifactId>
<version>${liquibase-mongo-ext.version}</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.6.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
liquibase.properties
changeLogFile=./mongo/changelog/changelog.sql
url=jdbc:mongodb://127.0.0.1:27017/local
driver=com.mongodb.client.MongoClients
How can I get liquibase running with maven? Any suggestions?
EDIT 1:
As Andrey suggested:
Driver was updated to: driver=liquibase.ext.mongodb.database.MongoClientDriver
Url was updated to:
url=mongodb://127.0.0.1:27017/local
plugin from liquibase was updated with new dependency
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.9.1</version>
</dependency>
mvn liquibase:update now trhows the following error. Since the other error seems to be unrelated to this one. I'll solve this answer and create a new thread.
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:4.2.0:update (default-cli) on project mongo: Execution default-cli of goal org.liquibase:liquibase-maven-plugin:4.2.0:update failed: A required class was missing while executing org.liquibase:liquibase-maven-plugin:4.2.0:update: liquibase/configuration/HubConfiguration
EDIT 2:
As mentioned in the answer, there was a mismatch between the version from Spring and the version of the plugin, which failed to find the class because HubConfiguration class is now under liquibase.hub.HubConfiguration This set up could have led to a CastException as well. So I updated the version liquibase-maven-plugin to 4.9.1
Also the use of the local database is not compatible with validators. The URI was updated to url=mongodb://127.0.0.1:27017/test in the liquibase.properties file.
Now it works like a charm! :D
I have found following mistakes in your configuration:
1.
changeLogFile=./mongo/changelog/changelog.sql
url=jdbc:mongodb://127.0.0.1:27017/local
driver=com.mongodb.client.MongoClients
while liquibase-mongodb expects something like (no jdbc prefix, another driver class):
changeLogFile=./mongo/changelog/changelog.sql
url=mongodb://127.0.0.1:27017/local
driver=liquibase.ext.mongodb.database.MongoClientDriver
liquibase version:
<liquibase-maven-plugin.version>4.2.0</liquibase-maven-plugin.version>
4.2.0 liquibase version seems to be incompatible with NoSQL DB extensions
spring boot 2.7.3 uses liquibase 4.9.1 - you need somehow choose the correct liquibase version
Finally I get the following on liquibase:update:
[ERROR] Failed to execute goal
org.liquibase:liquibase-maven-plugin:4.14.0:update (default-cli) on
project mongo: [ERROR] Error setting up or running Liquibase: [ERROR]
liquibase.exception.DatabaseException: Could not execute: Command
failed with error 72 (InvalidOptions): 'Document validators are not
allowed on collection local.DATABASECHANGELOGLOCK with UUID
31bd40b8-3e1c-45c8-9d03-77b91c67a1a9 in the local internal database'
on server 127.0.0.1:27017. The full response is {"ok": 0.0, "errmsg":
"Document validators are not allowed on collection
local.DATABASECHANGELOGLOCK with UUID
31bd40b8-3e1c-45c8-9d03-77b91c67a1a9 in the local internal database",
"code": 72, "codeName": "InvalidOptions"}
no idea what does it mean - something related to mongodb and extension I believe
UPD.
The root cause of last error is described in documentation:
Restrictions
You cannot specify a validator for collections in the admin, local, and config databases.
You cannot specify a validator for system.* collections.
So, url (jdbc:mongodb://127.0.0.1:27017/local) should point to another db.

Duplicate key Endpoint exception while starting - in Spring Boot Admin Client

I'm trying to configure Spring Boot Admin Client but i'm start the client application not able to register with Server. While starting of the application I'm getting the below exception.
java.lang.IllegalStateException: Duplicate key Endpoint(id=threaddump, url=http://localhost:9082/client-web/management/actuator/dump)
i'm using dependency version of client same version which I have used it for Spring Boot Admin Server
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.0.1</version>
</dependency>
what's causing the issue?
It was the known bug in 'Spring boot admin 1.x'. But has been fixed in the later version (2.0.2).
Endpoints list is obtained from the AdminServerProperties class and defaults to
{
"health", "env", "metrics", "httptrace:trace",
"httptrace","threaddump:dump","threaddump", "jolokia", "info",
"logfile", "refresh", "flyway",
"liquibase", "heapdump", "loggers","auditevents"
};
The problem with the duplicate key seems to be caused by the presence of both "httptrace:trace" and "httptrace" (and similarly for threaddump)
Overriding this in config by adding the line seems to solve the problem.
spring.boot.admin.probed-endpoints: [ "health", "env", "metrics", "httptrace:trace", "threaddump:dump", "jolokia", "info", "logfile", "refresh", "flyway", "liquibase", "heapdump", "loggers", "auditevents" ]
Pls see this for more: https://github.com/codecentric/spring-boot-admin/issues/828
Alternatively, you can update pom.xml as below
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.0.2 or above</version>
</dependency>

Do Spring LDAP and Spring Cloud Consul work together?

I had a project with Spring LDAP in place. I am trying to put in Spring Consul into this project and have been facing issues with respect to it.
Here is the pom.xml :
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
Here is application properties :
#consul properties
spring.cloud.consul.config.format=PROPERTIES
spring.cloud.consul.discovery.healthCheckPath=/<root>/health
spring.cloud.consul.discovery.healthCheckInterval=15s
spring.application.name=<App_Name>
spring.profiles.active=dev
And I enabled discovery client using #EnableDiscoveryClient on SpringBootApplication class.
But, I am ending up with this error and the app never starts :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field ldapTemplate in com.<package>.config.LdapClient required a bean of type 'org.springframework.ldap.core.LdapTemplate' that could not be found.
- Bean method 'ldapTemplate' not loaded because #ConditionalOnClass did not find required class 'org.springframework.data.ldap.repository.LdapRepository'
Action:
Consider revisiting the conditions above or defining a bean of type 'org.springframework.ldap.core.LdapTemplate' in your configuration.
Disconnected from the target VM, address: '127.0.0.1:62703', transport: 'socket'
I figure it has something to do with autodiscovery of Ldap and introducing Consul is causing this issue, but, I am not able to pin-point the problem.
Can someone please help me resolve this issue?

Spring boot 2.0.0.M1 NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>

I used the starter page on https://start.spring.io/ to generate a project with a number of included modules
When I try to run the tests I get a lot of log info but these lines seem key
10:29:33.198 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [Inlined Test Properties] PropertySource with highest search precedence
10:29:33.364 [main] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [file:/C:/privilege/target/surefire/surefirebooter1615922581175854972.jar]
10:29:33.369 [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)
The modules that I selected are:
Security
AOP
Web Jersey (JAX-RS)
Rest Repositories
DevTools
Cache
Session
Mobile
REST
Docs
Thymeleaf
MongoDB
Zuul
Zookeeper Discovery
Solr
Cloud
OAuth2
Lombok
Retry
I had to make a few mods to the generated pom but I think that I have a reasonable set of versions.
From the "effective pom" generated by STS, get the following properties:
<spring-batch.version>4.0.0.M2</spring-batch.version>
<undertow.version>1.4.14.Final</undertow.version>
<httpclient.version>4.5.3</httpclient.version>
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
<webjars-locator.version>0.32-1</webjars-locator.version>
<spring-ldap.version>2.3.1.RELEASE</spring-ldap.version>
<spring-security-oauth.version>2.1.0.RELEASE</spring-security-oauth.version>
<hibernate.version>5.2.10.Final</hibernate.version>
<groovy.version>2.4.11</groovy.version>
<rxjava2.version>2.1.0</rxjava2.version>
<byte-buddy.version>1.6.14</byte-buddy.version>
<spring-social-linkedin.version>2.0.0.M2</spring-social-linkedin.version>
<jmustache.version>1.13</jmustache.version>
<spring-cloud-connectors.version>2.0.0.M1</spring-cloud-connectors.version>
<mockito.version>2.7.22</mockito.version>
<reactor-bom.version>Bismuth-M1</reactor-bom.version>
<maven-antrun-plugin.version>1.8</maven-antrun-plugin.version>
<java.version>1.8</java.version>
<bitronix.version>2.1.4</bitronix.version>
<commons-beanutils.version>1.9.3</commons-beanutils.version>
<exec-maven-plugin.version>1.5.0</exec-maven-plugin.version>
<atomikos.version>3.9.3</atomikos.version>
<maven-javadoc-plugin.version>2.10.4</maven-javadoc-plugin.version>
<jersey.version>2.25.1</jersey.version>
<jaxen.version>1.1.6</jaxen.version>
<caffeine.version>2.5.0</caffeine.version>
<couchbase-cache-client.version>2.1.0</couchbase-cache-client.version>
<sun-mail.version>1.6.0-rc1</sun-mail.version>
<lettuce.version>5.0.0.M2</lettuce.version>
<wsdl4j.version>1.6.3</wsdl4j.version>
<jedis.version>2.9.0</jedis.version>
<javax-mail.version>1.6.0-rc1</javax-mail.version>
<lombok.version>1.16.16</lombok.version>
<maven-failsafe-plugin.version>2.18.1</maven-failsafe-plugin.version>
<activemq.version>5.14.5</activemq.version>
<spring-security-jwt.version>1.0.7.RELEASE</spring-security-jwt.version>
<spring-mobile.version>2.0.0.M1</spring-mobile.version>
<log4j2.version>2.8.2</log4j2.version>
<hazelcast-hibernate5.version>1.2.1</hazelcast-hibernate5.version>
<janino.version>3.0.7</janino.version>
<aspectj.version>1.8.10</aspectj.version>
<versions-maven-plugin.version>2.3</versions-maven-plugin.version>
<spring-kafka.version>2.0.0.M2</spring-kafka.version>
<tomcat.version>8.5.15</tomcat.version>
<postgresql.version>42.1.1</postgresql.version>
<statsd-client.version>3.1.0</statsd-client.version>
<spring-social-twitter.version>2.0.0.M2</spring-social-twitter.version>
<flyway.version>4.2.0</flyway.version>
<snakeyaml.version>1.18</snakeyaml.version>
<maven-enforcer-plugin.version>1.4</maven-enforcer-plugin.version>
<spring-cloud-starter-zuul.version>1.3.0.RELEASE</spring-cloud-starter-zuul.version>
<resource.delimiter>#</resource.delimiter>
<maven-dependency-plugin.version>2.10</maven-dependency-plugin.version>
<spring-cloud-starter-zookeeper-discovery.version>1.1.0.RELEASE</spring-cloud-starter-zookeeper-discovery.version>
<assertj.version>3.7.0</assertj.version>
<hikaricp.version>2.6.1</hikaricp.version>
<nekohtml.version>1.9.22</nekohtml.version>
<jest.version>2.4.0</jest.version>
<javax-transaction.version>1.2</javax-transaction.version>
<hazelcast.version>3.8.1</hazelcast.version>
<glassfish-el.version>3.0.0</glassfish-el.version>
<mariadb.version>2.0.1</mariadb.version>
<javax-validation.version>1.1.0.Final</javax-validation.version>
<thymeleaf-extras-java8time.version>3.0.0.RELEASE</thymeleaf-extras-java8time.version>
<spring-social.version>2.0.0.M3</spring-social.version>
<spring-security.version>5.0.0.M1</spring-security.version>
<solr.version>6.5.1</solr.version>
<maven-eclipse-plugin.version>2.10</maven-eclipse-plugin.version>
<neo4j-ogm.version>3.0.0-M01</neo4j-ogm.version>
<servlet-api.version>3.1.0</servlet-api.version>
<joda-time.version>2.9.9</joda-time.version>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<hibernate-validator.version>5.4.1.Final</hibernate-validator.version>
<jaybird.version>3.0.0</jaybird.version>
<commons-collections.version>3.2.2</commons-collections.version>
<liquibase.version>3.5.3</liquibase.version>
<maven-resources-plugin.version>3.0.1</maven-resources-plugin.version>
<embedded-mongo.version>2.0.0</embedded-mongo.version>
<spring-integration.version>5.0.0.M4</spring-integration.version>
<querydsl.version>4.1.4</querydsl.version>
<mongodb.version>3.4.2</mongodb.version>
<commons-codec.version>1.10</commons-codec.version>
<antlr2.version>2.7.7</antlr2.version>
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
<xml-apis.version>1.4.01</xml-apis.version>
<selenium.version>3.4.0</selenium.version>
<jetty-el.version>8.5.9.1</jetty-el.version>
<maven-help-plugin.version>2.2</maven-help-plugin.version>
<jetty.version>9.4.5.v20170502</jetty.version>
<ehcache.version>2.10.4</ehcache.version>
<mssql-jdbc.version>6.1.0.jre8</mssql-jdbc.version>
<spring-retry.version>1.2.0.RELEASE</spring-retry.version>
<mongo-driver-reactivestreams.version>1.3.0</mongo-driver-reactivestreams.version>
<ehcache3.version>3.3.1</ehcache3.version>
<simple-json.version>1.1.1</simple-json.version>
<couchbase-client.version>2.4.5</couchbase-client.version>
<narayana.version>5.5.24.Final</narayana.version>
<freemarker.version>2.3.26-incubating</freemarker.version>
<infinispan.version>8.2.6.Final</infinispan.version>
<unboundid-ldapsdk.version>3.2.1</unboundid-ldapsdk.version>
<httpasyncclient.version>4.1.3</httpasyncclient.version>
<thymeleaf-extras-springsecurity4.version>3.0.2.RELEASE</thymeleaf-extras-springsecurity4.version>
<spring-social-facebook.version>3.0.0.M2</spring-social-facebook.version>
<classmate.version>1.3.3</classmate.version>
<artemis.version>1.5.4</artemis.version>
<spring-plugin.version>1.2.0.RELEASE</spring-plugin.version>
<spring.version>5.0.0.RC1</spring.version>
<selenium-htmlunit.version>2.26</selenium-htmlunit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<appengine-sdk.version>1.9.53</appengine-sdk.version>
<rxjava.version>1.3.0</rxjava.version>
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
<netty.version>4.1.11.Final</netty.version>
<commons-dbcp2.version>2.1.1</commons-dbcp2.version>
<htmlunit.version>2.26</htmlunit.version>
<jboss-transaction-spi.version>7.6.0.Final</jboss-transaction-spi.version>
<hamcrest.version>1.3</hamcrest.version>
<spring-cloud-starter-oauth2.version>1.2.0.RELEASE</spring-cloud-starter-oauth2.version>
<junit.version>4.12</junit.version>
<maven-install-plugin.version>2.5.2</maven-install-plugin.version>
<javax-cache.version>1.0.0</javax-cache.version>
<build-helper-maven-plugin.version>1.10</build-helper-maven-plugin.version>
<javax-jms.version>2.0.1</javax-jms.version>
<jtds.version>1.3.1</jtds.version>
<mysql.version>5.1.42</mysql.version>
<slf4j.version>1.7.25</slf4j.version>
<git-commit-id-plugin.version>2.2.2</git-commit-id-plugin.version>
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
<derby.version>10.13.1.1</derby.version>
<thymeleaf-layout-dialect.version>2.2.1</thymeleaf-layout-dialect.version>
<jooq.version>3.9.2</jooq.version>
<logback.version>1.2.3</logback.version>
<maven-clean-plugin.version>3.0.0</maven-clean-plugin.version>
<thymeleaf-spring5.version>3.0.6.M4</thymeleaf-spring5.version>
<rxjava-adapter.version>1.2.1</rxjava-adapter.version>
<spring-restdocs.version>1.2.1.RELEASE</spring-restdocs.version>
<jsonassert.version>1.5.0</jsonassert.version>
<spring-session.version>2.0.0.M1</spring-session.version>
<elasticsearch.version>2.4.5</elasticsearch.version>
<spring-cloud.version>Finchley.BUILD-SNAPSHOT</spring-cloud.version>
<httpcore.version>4.4.6</httpcore.version>
<sqlite-jdbc.version>3.16.1</sqlite-jdbc.version>
<dom4j.version>1.6.1</dom4j.version>
<thymeleaf-extras-data-attribute.version>2.0.1</thymeleaf-extras-data-attribute.version>
<jdom2.version>2.0.6</jdom2.version>
<javassist.version>3.21.0-GA</javassist.version>
<jetty-jsp.version>2.2.0.v201112011158</jetty-jsp.version>
<json-path.version>2.2.0</json-path.version>
<spring-hateoas.version>0.23.0.RELEASE</spring-hateoas.version>
<spring.boot.version>2.0.0.M1</spring.boot.version>
<sendgrid.version>3.2.0</sendgrid.version>
<spring-data-releasetrain.version>Kay-M3</spring-data-releasetrain.version>
<spring-ws.version>2.4.0.RELEASE</spring-ws.version>
<dropwizard-metrics.version>3.2.2</dropwizard-metrics.version>
<commons-pool.version>1.6</commons-pool.version>
<jboss-logging.version>3.3.1.Final</jboss-logging.version>
<jstl.version>1.2</jstl.version>
<webjars-hal-browser.version>3325375</webjars-hal-browser.version>
<maven-war-plugin.version>2.6</maven-war-plugin.version>
<gson.version>2.8.0</gson.version>
<h2.version>1.4.195</h2.version>
<cassandra-driver.version>3.2.0</cassandra-driver.version>
<jolokia.version>1.3.6</jolokia.version>
<maven-assembly-plugin.version>2.6</maven-assembly-plugin.version>
<commons-digester.version>2.1</commons-digester.version>
<jackson.version>2.9.0.pr3</jackson.version>
<jna.version>4.4.0</jna.version>
<maven-source-plugin.version>3.0.1</maven-source-plugin.version>
<maven.compiler.target>1.8</maven.compiler.target>
<commons-lang3.version>3.5</commons-lang3.version>
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
<thymeleaf.version>3.0.6.RELEASE</thymeleaf.version>
<commons-pool2.version>2.4.2</commons-pool2.version>
<maven-site-plugin.version>3.5.1</maven-site-plugin.version>
<maven-invoker-plugin.version>1.10</maven-invoker-plugin.version>
<spring-amqp.version>2.0.0.M4</spring-amqp.version>
<maven.compiler.source>1.8</maven.compiler.source>
<hsqldb.version>2.4.0</hsqldb.version>
The constructor of SpringApplicationBuilder has recently been changed in spring-boot 2.0.0.M1.
I had the same problem, but after updating to spring-cloud Finchley.BUILD-SNAPSHOT it disappeared. However, that's the version I see in your properties above.
In the end, I'm not exactly sure what causes your problem (and maybe shouldn't post this as an answer, but it's too long for a comment) but maybe that's a start for further investigation.
Since 2.0.0.M1 is not stable, you may want to wait for spring-boot 2.0.0 to be released. Otherwise, try deleting your local SNAPSHOT versions of spring.
I'll update this answer if I figure out more.
Just check spring-cloud-starter server version compatibility with spring-boot-starter-parent. This will help and it will resolve
15:49:31.609 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:125)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:89)
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:62)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:364)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:323)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265)
In my case I've resolved this using spring-boot-starter-parent version 2.0.5.RELEASE and spring-cloud-starter-netflix-eureka-server with version Finchley.SR1.
Also added spring-cloud-starter-config dependencies with it.
Thanks and Hope It will help you.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
adding above tag for
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
resolved my problem, it's issue with spring - cloud and spring 2.1.x versions
Just complementing #Michel Jung's answer, I just needed to keep the spring-boot version as the same:
2.0.4.RELEASE
And add the Finchley.RELEASE's mavenBom as recommended here:
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Finchley.RELEASE"
}
}
repositories {
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
You need to check the consistency between Spring boot version and Release train version. Full documentation is HERE
You need to check Table 1. Release train Spring Boot compatibility
For example, if you use Spring Boot 2.4.x version, consistent Release train is 2020.0.x
For 2.2.0.RELEASE Spring Boot version compatible Release Train is Hoxton.RELEASE
In the dependencies it looks like:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.11</java.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Usually these factors are very simple, just find all dependencies with prefix "spring",
find out them have difference with the train version.
see
I think it is mainly happening because of the spring-cloud version. I am using 2.1.8.RELEASE of spring-boot-starter-parent and here are my findings
Tried by spring-cloud Camden.SR6 - Didn't work.
Tried by spring-cloud Finchley.SR1 - It worked this time.
I had this same problem in Java 8 while doing a project with the feign dependency, but I fixed it by changing it to the following:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>2.0.1.RELEASE</version>`
</dependency>

fail to run maven on jenkins on a closed environment

I am trying to run a simple build using maven on jenkins (1.651.2) for windows. I am working on a closed environment which has no internet connection. Trying the same on my internet PC works fine. Also from command line everything works fine on jenkins I get this error:
Building on master in workspace C:\source\maven
ERROR: Failed to parse POMs
java.net.MalformedURLException: no protocol:
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at hudson.tools.ZipExtractionInstaller.performInstallation(ZipExtractionInstaller.java:79)
at hudson.tools.InstallerTranslator.getToolHome(InstallerTranslator.java:68)
at hudson.tools.ToolLocationNodeProperty.getToolHome(ToolLocationNodeProperty.java:108)
at hudson.tools.ToolInstallation.translateFor(ToolInstallation.java:206)
at hudson.model.JDK.forNode(JDK.java:143)
at hudson.model.AbstractProject.getEnvironment(AbstractProject.java:357)
at hudson.model.Run.getEnvironment(Run.java:2229)
at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:938)
at hudson.maven.AbstractMavenBuild.getEnvironment(AbstractMavenBuild.java:56)
at hudson.maven.MavenModuleSetBuild.getEnvironment(MavenModuleSetBuild.java:166)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:622)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1738)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Finished: FAILURE
adding my simple program pom file:
<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.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Looks like Jenkins is trying to automatically install maven, please check your configuration page if you have something similar to this (Install automatically checked):
If so, please uncheck that box and provide the path to the maven installation, or leave it blank if you have maven in PATH of jenkins user.
thank for krzyk
The problem was not the maven section which was set as krzyk suggested the problem was in the jdk section which had "Install automatically" checked. The Error message was unclear

Resources