I have spring boot application contains embedded activeMQ, i want to connect to web console using hawtio but not able to connect .
i do the following steps :
1-in cmd "java -jar hawtio-app-1.5.7.jar".
2- trying connect to Host : localhost port : 1099 Path : /api/jolokia
but not working return the following :
Failed to load resource: the server responded with a status of 500 (localhost:1099 failed to respond)
Pom.xml
<!-- Starter for building web, including RESTful, applications using Spring
MVC. Uses Tomcat as the default embedded container -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- the embedded container dependencies as “provided” -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- Logging libraries -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<!-- WebSocket libraries -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<!-- reactor project libraries -->
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-bus</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-net</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.33.Final</version>
</dependency>
<!-- Email -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>sockjs-client</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>stomp-websocket</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.7</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-stomp</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-kahadb-store</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.7.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
the below log startup :
`2018-02-13;00:31:26.976 [localhost-startStop-1] INFO
o.s.b.w.s.ServletRegistrationBean.onStartup(190) - Mapping servlet: 'dispatcherServlet' to [/]
2018-02-13;00:31:27.016 [localhost-startStop-1] INFO
o.s.b.w.s.FilterRegistrationBean.configure(258) - Mapping filter: 'characterEncodingFilter' to: [/*]
2018-02-13;00:31:27.019 [localhost-startStop-1] INFO
o.s.b.w.s.FilterRegistrationBean.configure(258) - Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-02-13;00:31:27.021 [localhost-startStop-1] INFO
o.s.b.w.s.FilterRegistrationBean.configure(258) - Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-02-13;00:31:27.022 [localhost-startStop-1] INFO
o.s.b.w.s.FilterRegistrationBean.configure(258) - Mapping filter: 'requestContextFilter' to: [/*]
2018-02-13;00:31:28.938 [main] INFO
o.s.s.c.ThreadPoolTaskExecutor.initialize(165) - Initializing ExecutorService 'clientInboundChannelExecutor'
2018-02-13;00:31:28.976 [main] INFO
o.s.s.c.ThreadPoolTaskExecutor.initialize(165) - Initializing ExecutorService 'clientOutboundChannelExecutor'
2018-02-13;00:31:29.434 [main] INFO
o.s.s.c.ThreadPoolTaskScheduler.initialize(165) - Initializing ExecutorService 'messageBrokerTaskScheduler'
2018-02-13;00:31:29.567 [main] INFO
o.s.w.s.s.s.WebSocketHandlerMapping.registerHandler(362) - Mapped URL path [/websocket/**] onto handler of type [class org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler]
2018-02-13;00:31:29.627 [main] INFO
o.s.s.c.ThreadPoolTaskExecutor.initialize(165) - Initializing ExecutorService 'brokerChannelExecutor'
2018-02-13;00:31:30.895 [main] WARN
o.a.activemq.broker.BrokerService.checkMemorySystemUsageLimits(2146) - Memory Usage for the Broker (1024mb) is more than the maximum available for the JVM: 512 mb - resetting to 70% of maximum available: 358 mb
2018-02-13;00:31:31.096 [main] INFO
o.a.activemq.broker.BrokerService.doStartPersistenceAdapter(671) - Using Persistence Adapter: KahaDBPersistenceAdapter[C:\Users\anash\git\Notfication\activemq-data\localhost\KahaDB]
2018-02-13;00:31:31.111 [JMX connector] INFO
o.a.a.broker.jmx.ManagementContext.run(155) - JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
2018-02-13;00:31:31.721 [main] INFO
o.a.a.store.kahadb.MessageDatabase.read(191) - KahaDB is version 6
2018-02-13;00:31:31.747 [main] INFO
o.a.a.store.kahadb.MessageDatabase.recover(678) - Recovering from the journal #1:1026194
2018-02-13;00:31:31.768 [main] INFO
o.a.a.store.kahadb.MessageDatabase.recover(706) - Recovery replayed 253 operations from the journal in 0.037 seconds.
2018-02-13;00:31:31.965 [main] INFO
o.a.a.s.kahadb.plist.PListStoreImpl.doStart(371) - PListStore:[C:\Users\anash\git\Notfication\activemq-data\localhost\tmp_storage] started
2018-02-13;00:31:32.136 [main] INFO
o.a.activemq.broker.BrokerService.doStartBroker(734) - Apache ActiveMQ 5.14.5 (localhost, ID:SPS-Anash-49217-1518474691990-0:1) is starting
2018-02-13;00:31:32.159 [main] INFO
o.a.a.t.TransportServerThreadSupport.doStart(69) - Listening for connections at: stomp://127.0.0.1:61613
2018-02-13;00:31:32.160 [main] INFO
o.a.a.broker.TransportConnector.start(263) - Connector stomp://127.0.0.1:61613 started
2018-02-13;00:31:32.164 [main] INFO
o.a.activemq.broker.BrokerService.doStartBroker(761) - Apache ActiveMQ 5.14.5 (localhost, ID:SPS-Anash-49217-1518474691990-0:1) started
2018-02-13;00:31:32.165 [main] INFO
o.a.activemq.broker.BrokerService.doStartBroker(762) - For help or more information please see: http://activemq.apache.org
2018-02-13;00:31:32.169 [main] WARN `
You need to enable Jolokia endpoint on your Spring Boot app and make it accessible outside of the app.
To do so, firstly you need to add spring-boot-actuator in pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
Then in your application.properties, disable sensitivity of the Jolokia endpoint:
endpoints.jolokia.sensitive = false
Now you should be able to connect to Jolokia at: http://localhost:8080/jolokia Try connecting to it from your hawtio console.
FYI, here you can find a working example of hawtio integration with a Spring Boot app:
https://github.com/hawtio/hawtio/blob/hawtio-1.5.7/hawtio-sample-springboot/
Related
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
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.
I'm developing a Spring boot application.
I'm building a war file for JBoss
My war is building correctly , I'm using *-war.original as deployment for JBoss
the deployment seems fine
But when I make call to controller, it's throwing a 404
With embedded sever it's working fine
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.my.service</groupId>
<artifactId>my-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.0.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Swagger UI Depedency -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<!-- Oracle JDBC driver -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<java.version>1.8</java.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<dependencies>
<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>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- <version>2.0.1.RELEASE</version> -->
<!-- https://stackoverflow.com/questions/43641664/why-spring-boot-generate-jar-or-war-file-with-original-extention -->
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<phase>package</phase>
<!-- https://stackoverflow.com/questions/30325549/only-generate-one-war-during-package -->
</execution>
</executions>
</plugin>
<!-- This configuration helps to generate war file without web.xml, spring
boot projects -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
SpringBootServletInitializer
#SpringBootApplication
public class ServletInitializer extends SpringBootServletInitializer{
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(MyApiApplication.class);
}
#Override
public void onStartup(ServletContext servletContext) throws ServletException{
super.onStartup(servletContext);
}
}
Deployment log
12:01:09,605 INFO [stdout] (ServerService Thread Pool -- 162) ::
Spring Boot :: (v2.0.1.RELEASE)
2018-04-24 12:01:09,605 [ServerService Thread Pool -- 162] INFO (AbstractLoggingWriter.java:71) - :: Spring Boot ::
(v2.0.1.RELEASE)
12:01:09,605 INFO [stdout] (ServerService Thread Pool -- 162)
2018-04-24 12:01:09,605 [ServerService Thread Pool -- 162] INFO (AbstractLoggingWriter.java:71) -
12:01:09,669 INFO [com.aerlingus.dei.subscriber.api.ServletInitializer] (ServerService
Thread Pool -- 162) Starting ServletInitializer on USER with PID 10692
(started by ADMIN in C:\pathto\jboss-eap-7.1\bin)
2018-04-24 12:01:09,669 [ServerService Thread Pool -- 162] INFO (JBossLog.java:134) - Starting ServletInitializer on CND7064JRN with
PID 10692 (started by ADMIN in C:\pathto\jboss-eap-7.1\bin)
2018-04-24 12:01:09,669 [ServerService Thread Pool -- 162] DEBUG (JBossLog.java:134) - Running with Spring Boot v2.0.1.RELEASE, Spring
v5.0.5.RELEASE
12:01:09,670 INFO [com.aerlingus.dei.subscriber.api.ServletInitializer] (ServerService
Thread Pool -- 162) The following profiles are active: uat
2018-04-24 12:01:09,670 [ServerService Thread Pool -- 162] INFO (JBossLog.java:134) - The following profiles are active: uat
12:01:09,686 INFO [org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext]
(ServerService Thread Pool -- 162) Refreshing
org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#5023cb50:
startup date [Tue Apr 24 12:01:09 BST 2018]; root of context hierarchy
2018-04-24 12:01:09,686 [ServerService Thread Pool -- 162] INFO (JBossLog.java:134) - Refreshing
org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#5023cb50:
startup date [Tue Apr 24 12:01:09 BST 2018]; root of context hierarchy
12:01:09,805 INFO [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor]
(ServerService Thread Pool -- 162) JSR-330 'javax.inject.Inject'
annotation found and supported for autowiring
2018-04-24 12:01:09,805 [ServerService Thread Pool -- 162] INFO (JBossLog.java:134) - JSR-330 'javax.inject.Inject' annotation found
and supported for autowiring
12:01:09,816 INFO [io.undertow.servlet] (ServerService Thread Pool -- 162) Initializing Spring embedded WebApplicationContext
2018-04-24 12:01:09,816 [ServerService Thread Pool -- 162] INFO (ServletContextImpl.java:360) - Initializing Spring embedded
WebApplicationContext
12:01:09,816 INFO [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 162) Root WebApplicationContext:
initialization completed in 130 ms
2018-04-24 12:01:09,816 [ServerService Thread Pool -- 162] INFO (JBossLog.java:134) - Root WebApplicationContext: initialization
completed in 130 ms
12:01:09,987 INFO [org.springframework.boot.web.servlet.FilterRegistrationBean]
(ServerService Thread Pool -- 162) Mapping filter: 'errorPageFilter'
to: [/*]
2018-04-24 12:01:09,987 [ServerService Thread Pool -- 162] INFO (JBossLog.java:134) - Mapping filter: 'errorPageFilter' to: [/*]
12:01:10,015 INFO [com.aerlingus.dei.subscriber.api.ServletInitializer] (ServerService
Thread Pool -- 162) Started ServletInitializer in 0.683 seconds (JVM
running for 4712.635)
2018-04-24 12:01:10,015 [ServerService Thread Pool -- 162] INFO (JBossLog.java:134) - Started ServletInitializer in 0.683 seconds (JVM
running for 4712.635)
12:01:10,021 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService
Thread Pool -- 162) Initializing Mojarra 2.2.13.SP3 for context
'/my-api'
2018-04-24 12:01:10,021 [ServerService Thread Pool -- 162] INFO (ConfigureListener.java:213) - Initializing Mojarra 2.2.13.SP3 for
context '/my-api'
12:01:11,566 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 162) WFLYUT0021: Registered web context: '/my-api' for
server 'default-server'
2018-04-24 12:01:11,566 [ServerService Thread Pool -- 162] INFO (Host.java:220) - WFLYUT0021: Registered web context: '/my-api' for
server 'default-server'
12:01:11,583 INFO [org.jboss.as.server] (External Management Request Threads -- 3) WFLYSRV0010: Deployed "my-api.war" (runtime-name
: "my-api.war")
2018-04-24 12:01:11,583 [External Management Request Threads -- 3] INFO (DeploymentHandlerUtil.java:171) - WFLYSRV0010: Deployed
"my-api.war" (runtime-name : "my-api.war")
WEB-INF/jboss-web.xml
<jboss-web>
<context-root>my-api</context-root>
</jboss-web>
similar to this
Getting "404 - Not found" error with Wildfly and springboot
Finally figured out what was wrong in I did, I have an Application class with main method without #SpringBootApplication along with SpringBootServletInitializer , So Jboss was not picking up the mapping correctly
The resolution was to make SpringBootServletInitializer class with main method. So I change ServletInitializermentioned in question
#SpringBootApplication
public class ServletInitializer extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(ServletInitializer.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ServletInitializer.class);
}
#Override
public void onStartup(ServletContext servletContext) throws ServletException{
super.onStartup(servletContext);
}
}
After that I was able to hit endpoint,
Why I didn't do this earlier ??
I generated the project using
SPRING INITIALIZR with war packaging, When SPRING INITIALIZR generate project Application and SpringBootServletInitializer classes was there.
Among both classes Appliaction class has the main method and #SpringBootApplication annotation
While writing Integration test initially it was not working , Then I change #SpringBootApplication annotation to SpringBootServletInitializer and write a main method in SpringBootServletInitializer test start working. But I kept the main method back in Appliaction class that was the root cause of this issue.
Since Spring Initializer, generate the classes I was in assumption , all classes generated are required to build war .So I kept the Application class the way it's generated without #SpringBootApplication annotation while generating war file. I think Jboss got confused which main method it should run. And eventually throwing a 404 exception while hitting end point
I am working currently on a project which includes the Spring Framework. Everything is working as aspect but there is one problem. When I try to start my application onto my laptop it immediately shuts down after startup. It is working on every other machine, so this problem occurs only on my laptop.
Maybe you got an idea what could force this problem ? I am working with IntelliJ and I haven´t found any solutions for this problem.
PC Specs
Laptop is a AsusN550JK( modified RAM and SSD)
Intel Core i7-4700HQ CPU#2.4 GHz
16 GB Ram
500 GB SSD Samsung EVO 840
1 TB HDD
64 Bit OS - Windows 10
ConsoleOutput
Exclusions:
-----------
None
Unconditional classes:
----------------------
org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration
org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration
org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration
2017-04-22 21:24:15.756 INFO 6300 --- [ main] com.objectbay.test.me.Application : Started Application in 8.012 seconds (JVM running for 9.251)
2017-04-22 21:24:15.758 INFO 6300 --- [ Thread-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#6fb0d3ed: startup date [Sat Apr 22 21:24:08 CEST 2017]; root of context hierarchy
2017-04-22 21:24:15.763 INFO 6300 --- [ Thread-3] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2017-04-22 21:24:15.764 INFO 6300 --- [ Thread-3] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2017-04-22 21:24:15.765 INFO 6300 --- [ Thread-3] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2017-04-22 21:24:15.771 DEBUG 6300 --- [ Thread-3] org.hibernate.SQL : drop table person if exists
2017-04-22 21:24:15.782 INFO 6300 --- [ Thread-3] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
Process finished with exit code 0
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>org.springframework</groupId>
<artifactId>gs-accessing-data-rest</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
Full example which is not working on my machine
Spring Guide Rest example
Console - LOG after Updating Dependencies
LOG after Updating Dependencies
Add this dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
For me what caused this was that I had this property below, in the application properties (carried over by mistake from a test application.properties file). See if any of your property files that are included have this like below, and remove it:
# disables the servlet-container initialization (for unit testing only)
spring.main.web-application-type=none
Problem is solved - thanks for your help crazycoder.
The issue was caused by an older version of tomcat. After upating the embedded tomcat of Spring to 1.5.3_RELEASE and updating mysql-jdbc-driver as well , it finally worked for me.
I adjusted the pom.xml like this:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>
I met the same problem, I fix by these steps as below:
update file application.yml
1- remove:
main:
web-application-type: none
2- if your change server port already, it's still error:
Identify and stop the process that's listening on port 8080 or
configure this application to listen on another port.
solution: move server port config on the top of yml file
Done! it's for my case.
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!