Spring Cloud Config Remote - USERAUTH fail - spring

I'm trying to do a ConfigServer with a remote repository.
The ConfigServer pom's file is:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-monitor</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Inthe the properties file, i have the url, user and password of the repository. Is necessary anything else?. The file is like:
server.port:8888
spring.cloud.config.server.git.uri:git#gitlab.com:user/repo.git
spring.cloud.config.server.git.uri.username:user
spring.cloud.config.server.git.uri.password:password
spring.profiles.active:config-monitor
rabbitmq.host:rabbitmq
rabbitmq.port:5672
rabbitmq.username:guest
rabbitmq.password:guest
spring.cloud.bus.enabled:true
spring.cloud.config.server.monitor.gitlab.enabled:true
And I created a Webhook in gitLab with url http://localhost:8888/monitor too.
But when a client try to start, the ConfigServer's console shows:
**2017-03-14 23:46:35.767 ERROR 10595 --- [nio-8888-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: Cannot clone or checkout repository] with root cause
com.jcraft.jsch.JSchException: USERAUTH fail
at com.jcraft.jsch.UserAuthPublicKey.start(UserAuthPublicKey.java:118) ~[jsch-0.1.50.jar:na]
at com.jcraft.jsch.Session.connect(Session.java:463) ~[jsch-0.1.50.jar:na]
2017-03-14 23:46:51.162 WARN 10595 --- [nio-8888-exec-2] .c.s.e.MultipleJGitEnvironmentRepository : Could not fetch remote for master remote: git#gitlab.com:user/repo.git**
Dou you know how can i resolver it?
Thanks!

Related

The following method did not exist: 'java.lang.String javax.servlet.ServletContext.getVirtualServerName()'

I am developing a simple application using Spring Boot, this is my pom
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.3.4.RELEASE</version>
</dependency>
</dependencies>
When I run the application I get
***************************
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.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1318)
The following method did not exist:
'java.lang.String javax.servlet.ServletContext.getVirtualServerName()'
The calling method's class, org.apache.catalina.authenticator.AuthenticatorBase, was loaded from the following location:
jar:file:/Users/19904760/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.58/tomcat-embed-core-9.0.58.jar!/org/apache/catalina/authenticator/AuthenticatorBase.class
The called method's class, javax.servlet.ServletContext, is available from the following locations:
jar:file:/Users/19904760/Desktop/prm-service-middleware/lib/javax.servlet.jar!/javax/servlet/ServletContext.class
jar:file:/Users/19904760/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.58/tomcat-embed-core-9.0.58.jar!/javax/servlet/ServletContext.class
The called method's class hierarchy was loaded from the following locations:
javax.servlet.ServletContext: file:/Users/19904760/Desktop/prm-service-middleware/lib/javax.servlet.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes org.apache.catalina.authenticator.AuthenticatorBase and javax.servlet.ServletContext
Process finished with exit code 1
How is this caused and how can I solve it?

Upgrading Spring Boot to 2.5.9 and getting FileNotFoundException: class path ...../boot/actuate/health/HealthAggregator.class] cannot be opened

I am getting a FileNotFoundException during Spring Boot initiation for org/springframework/boot/actuate/health/HealthAggregator.class. This seem related to https://github.com/spring-projects/spring-boot/issues/19860 but that was back in 2.2.
I have tried different versions of Spring Boot, 2.5.9 etc, different versions of Spring Cloud, etc.
Any thoughts on how I can resolved this?
Key parts of my POM
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
..
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>2021.0.0</spring-cloud.version>
</properties>
..
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
..
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-client-config</artifactId>
<version>2.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
The error:
is 2022-01-25 20:16:20 WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.xxxxx.vms.yyyyy]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/boot/actuate/health/HealthAggregator.class] cannot be opened because it does not exist 2022-01-25 20:16:20 ERROR o.s.boot.SpringApplication - Application run failed

Why can I exclude servlet-api from endpoints-framework but not from endpoints-management-control-appengine-all?

endpoints-management-control-appengine-all
endpoints-framework
Both of these packages come with some version of servlet-api-2.5.jar/servlet-api dependency
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
Without any exclusions
2020-07-16 01:22:48.113 WARN 1 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextExcepti
on: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2020-07-16 01:22:48.127 INFO 1 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-16 01:22:48.130 ERROR 1 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
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.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1321)
The following method did not exist:
'java.lang.String javax.servlet.ServletContext.getVirtualServerName()'
The method's class, javax.servlet.ServletContext, is available from the following locations:
jar:file:/app/libs/servlet-api-2.5.jar!/javax/servlet/ServletContext.class
jar:file:/app/libs/endpoints-management-control-appengine-all-1.0.12.jar!/javax/servlet/ServletContext.class
jar:file:/app/libs/tomcat-embed-core-9.0.36.jar!/javax/servlet/ServletContext.class
The class hierarchy was loaded from the following locations:
javax.servlet.ServletContext: file:/app/libs/servlet-api-2.5.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of javax.servlet.ServletContext
With one exclusion
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework</artifactId>
<version>${endpoints.framework.version}</version>
</dependency>
<!-- [START api_management] -->
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-management-control-appengine-all</artifactId>
<version>1.0.12</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- [END api_management] -->
(Exact same as above)
With other exclusion
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework</artifactId>
<version>${endpoints.framework.version}</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- [START api_management] -->
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-management-control-appengine-all</artifactId>
<version>1.0.12</version>
</dependency>
<!-- [END api_management] -->
2020-07-16 01:25:49.509 WARN 1 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextExcepti
on: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2020-07-16 01:25:49.524 INFO 1 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-07-16 01:25:49.529 ERROR 1 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
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.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1321)
The following method did not exist:
'java.lang.String javax.servlet.ServletContext.getVirtualServerName()'
The method's class, javax.servlet.ServletContext, is available from the following locations:
jar:file:/app/libs/endpoints-management-control-appengine-all-1.0.12.jar!/javax/servlet/ServletContext.class
jar:file:/app/libs/tomcat-embed-core-9.0.36.jar!/javax/servlet/ServletContext.class
The class hierarchy was loaded from the following locations:
javax.servlet.ServletContext: file:/app/libs/endpoints-management-control-appengine-all-1.0.12.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of javax.servlet.ServletContext
With both exclusions
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework</artifactId>
<version>${endpoints.framework.version}</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- [START api_management] -->
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-management-control-appengine-all</artifactId>
<version>1.0.12</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- [END api_management] -->
(same as above)
So we can conclude that exclusions simply aren't working for endpoints-management-control-appengine-all.
I have no idea how to fix this? There has got to be some weird quirk going on.
Obviously the goal is to remove all outdated transitive servlet dependencies so that jar:file:/app/libs/tomcat-embed-core-9.0.36.jar!/javax/servlet/ServletContext.class can be auto-selected, which probably has the new virtualization method, as recommended by answers like An attempt was made to call a method that does not exist. STS.
To test these exclusions I am creating a docker container with google jib plugin and docker run
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<to>
<image>gcr.io/${endpoints.project.id}/endpoints-container</image>
</to>
</configuration>
</plugin>
PORT=8080 && docker run --rm -p 9090:${PORT} -e PORT=${PORT} gcr.io/project-id/endpoints-container
I'm not sure whether this detail is relevant, but something I did notice was that endpoints-management-control-appengine-all has a different package structure, with respect to the way javax servlet 2.5 is included compared to endpoints-framework.
included alongside com which doesnt happen in endpoints-framework

#EnableEurekaServer, #EnableConfigServer, #EnableAdminServer and #EnableZuulProxy walk into a bar

I am having trouble building a Spring Boot + Spring Cloud application that is combining Zuul, Eureka server, Config server and Admin server in one unique application.
If you are already thinking: "Why on earth, this is breaking micro services concepts, etc.." I totally agree. This question is about the feasibility to make it happen, not to ask if it is a good idea to do it, thank you for your understanding.
Does anyone know how to make it happen? Some solution with Spring 2.1.0 + Spring Cloud Finchley or above will be great.
The code is obviously very straightforward:
`
#EnableZuulProxy
#EnableAdminServer
#EnableConfigServer
#EnableEurekaServer
#SpringBootApplication
public class Main {
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
}
`
The pom is also simple:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.M3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
</dependencies>
With an also straightforward config file:
spring.application.name=question
server.port=8090
eureka.client.service-url.defaultZone=http://localhost:8090/eureka
spring.boot.admin.context-path=/admin
spring.cloud.config.server.prefix=/config
spring.cloud.config.server.git.uri=...
spring.cloud.config.server.git.searchPaths=...
[...]
The closest I got was to use 2.0.6 + Finchley:
2018-12-08 13:20:10.515 INFO 13078 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-12-08 13:20:10.519 WARN 13078 --- [ost-startStop-1] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [RxIoScheduler-1 (Evictor)] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
2018-12-08 13:20:10.534 INFO 13078 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-12-08 13:20:10.536 ERROR 13078 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call the method reactor.retry.Retry.retryMax(J)Lreactor/retry/Retry; but it does not exist. Its class, reactor.retry.Retry, is available from the following locations:
jar:file:/Users/aaa/.m2/repository/io/projectreactor/addons/reactor-extra/3.1.7.RELEASE/reactor-extra-3.1.7.RELEASE.jar!/reactor/retry/Retry.class
It was loaded from the following location:
file:/Users/aaa/.m2/repository/io/projectreactor/addons/reactor-extra/3.1.7.RELEASE/reactor-extra-3.1.7.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of reactor.retry.Retry
Process finished with exit code 1
You need version 2.0.4 of spring boot admin. You're using the latest (2.1.1) which is not compatible with the rest of Spring libraries you're using.

Maven solrj issue

I can run my app and there's no problem at all but when i'm adding
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-solr</artifactId>
<version>1.1.0.RELEASE</version>
</dependency>
to my pom file it throws:
15:59:18,172 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-3) Context initialization failed: java.lang.IllegalStateException: Cannot load configuration class: eu.combc.webuzu.configuration.SecurityConfig
any idea what's going on?
check with this :
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>4.10.1</version>
</dependency>

Resources