Vaadin spring boot Frontend compiling failed - java

I'm new in Vaading, and I'm trying to create an example project. During compiling Vaadin spring boot project,with this 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>
<groupId>com.example</groupId>
<artifactId>crud</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>crud</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<vaadin.version>23.0.6</vaadin.version>
</properties>
<repositories>
<repository>
<id>vaadin-addons</id>
<url>https://maven.vaadin.com/vaadin-addons</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</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>
<dependency>
<groupId>org.vaadin.crudui</groupId>
<artifactId>crudui</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>collaboration-engine</artifactId>
<version>3.2.2</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>23.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>production</id>
<build>
<plugins>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>23.0.6</version>
<executions>
<execution>
<id>frontend</id>
<phase>compile</phase>
<goals>
<goal>prepare-frontend</goal>
<goal>build-frontend</goal>
</goals>
<configuration>
<productionMode>true</productionMode>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
After runngin this commands:
mvnw clean install
mvnw spring-boot:run
I receive many errors for modules not found in the folder projectname\target\flow-frontend\field-highlighter\src. The stanger think is that i do not see this target folder into root project. Same story if I run npm install, and execute again the above commands. Below are the specific error:
2022-04-17 22:56:41.659 INFO 12028 --- [onPool-worker-5] c.v.f.s.frontend.TaskUpdatePackages : Frontend dependencies resolved successfully.
2022-04-17 22:56:44.249 INFO 12028 --- [onPool-worker-5] c.v.f.s.frontend.TaskCopyFrontendFiles : Copying frontend resources from jar files ...
2022-04-17 22:56:44.308 INFO 12028 --- [onPool-worker-5] c.v.f.s.frontend.TaskCopyFrontendFiles : Visited 17 resources. Took 58 ms.
2022-04-17 22:56:44.374 INFO 12028 --- [onPool-worker-5] c.v.b.devserver.AbstractDevServerRunner : Starting Webpack
2022-04-17 22:56:44.568 INFO 12028 --- [onPool-worker-5] c.v.flow.server.frontend.FrontendTools : Globally node version 10.15.3 is older than 16.14.0. Using node from C:\Users\davide\.vaadin.
------------------ Starting Frontend compilation. ------------------
2022-04-17 22:56:45.671 INFO 12028 --- [onPool-worker-5] c.v.b.devserver.AbstractDevServerRunner : Running Webpack to compile frontend resources. This may take a moment, please stand by...
2022-04-17 22:56:50.311 INFO 12028 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker : [webpack-dev-server] Project is running at:
2022-04-17 22:56:50.311 INFO 12028 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker : [webpack-dev-server] Loopback: http://localhost:64731/
2022-04-17 22:56:50.312 INFO 12028 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker : [webpack-dev-server] On Your Network (IPv4): http://192.168.1.189:64731/
2022-04-17 22:56:50.312 INFO 12028 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker : [webpack-dev-server] Content not from webpack is served from 'C:\shared_folder\crud\target\classes\META-INF\VAADIN\webapp, C:\share
d_folder\crud\src\main\webapp' directory
2022-04-17 22:56:53.591 INFO 12028 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker :
2022-04-17 22:56:53.591 INFO 12028 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker : ERROR in ../target/flow-frontend/field-highlighter/src/vaadin-field-highlighter.js
2022-04-17 22:56:53.592 INFO 12028 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker : Module not found: Error: Can't resolve '#polymer/iron-a11y-announcer/iron-a11y-announcer.js' in 'C:\shared_folder\crud\target\flow-
frontend\field-highlighter\src'
2022-04-17 22:56:53.592 INFO 12028 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker :
2022-04-17 22:56:53.592 INFO 12028 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker : ERROR in ../target/flow-frontend/field-highlighter/src/vaadin-field-highlighter.js
2022-04-17 22:56:53.593 INFO 12028 --- [v-server-output] c.v.b.devserver.DevServerOutputTracker : Module not found: Error: Can't resolve '#vaadin/vaadin-element-mixin/vaadin-dir-mixin.js' in 'C:\shared_folder\crud\target\flow-fro
How can I solve it?

Related

OncePerRequestFilter in Jar is not invoking

I made a simple Jar with spring boot in which I simply placed a single class called IngressFilter whose job is to monitor network calls. Let's call this Jar Network-Tracer for now.
The IngressFilter and Pom.xml code can be found below.
IngressFilter.Java
#Component
#Slf4j
public class IngressFilter extends OncePerRequestFilter {
IngressFilter() {
log.info("Started Ingress Filter");
}
#Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
log.info("Started network call");
filterChain.doFilter(request, response);
log.info("call finished");
}
}
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>
<groupId>com.demo.networktracer</groupId>
<artifactId>network-tracer</artifactId>
<version>0.0.2</version>
<name>network-tracer</name>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Nothing special in the code, just a simple jar.
However, when I include this jar as a dependency in one of the spring boot applications, an issue arises.
Assume the application is
Weather Application
.
Below 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 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>
<groupId>com.poc</groupId>
<artifactId>weather</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>weather</name>
<description>Weather Calling Service</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>com.demo.networktracer</groupId>
<artifactId>network-tracer</artifactId>
<version>0.0.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
This code initializes when I try to run it. However, when I call one of the weather application's APIs, the Filter isn't called.
I'm also printing logs from the Weather Application for further information.
2022-04-21 07:42:49,128 INFO [main] org.springframework.boot.SpringApplication: No active profile set, falling back to 1 default profile: "default"
2022-04-21 07:42:49,761 INFO [main] org.springframework.boot.web.embedded.tomcat.TomcatWebServer: Tomcat initialized with port(s): 8080 (http)
2022-04-21 07:42:49,765 INFO [main] org.apache.juli.logging.DirectJDKLog: Initializing ProtocolHandler ["http-nio-8080"]
2022-04-21 07:42:49,765 INFO [main] org.apache.juli.logging.DirectJDKLog: Starting service [Tomcat]
2022-04-21 07:42:49,765 INFO [main] org.apache.juli.logging.DirectJDKLog: Starting Servlet engine: [Apache Tomcat/9.0.60]
2022-04-21 07:42:49,814 INFO [main] org.apache.juli.logging.DirectJDKLog: Initializing Spring embedded WebApplicationContext
2022-04-21 07:42:49,814 INFO [main] org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext: Root WebApplicationContext: initialization completed in 633 ms
2022-04-21 07:42:49,976 INFO [main] org.apache.juli.logging.DirectJDKLog: Starting ProtocolHandler ["http-nio-8080"]
2022-04-21 07:42:49,997 INFO [main] org.springframework.boot.web.embedded.tomcat.TomcatWebServer: Tomcat started on port(s): 8080 (http) with context path ''
2022-04-21 07:42:50,009 INFO [main] org.springframework.boot.StartupInfoLogger: Started WeatherApplication in 1.149 seconds (JVM running for 1.605)
I looked everywhere on the internet for information on this, but nothing came up.
Please assist me in determining why the network-tracer Ingressfilter is not being invoked.

There is an error loading static content in multi module project with Spring Boot

I have multi module project with Spring boot and an external server Weblogic.
These are modules:
dao
service
web
pom.xml (dao) .
It is the work with database (repository, entities)
<?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">
<parent>
<artifactId>gov-multiple-modules</artifactId>
<groupId>gov</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.dao</groupId>
<artifactId>dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<output.directory.jdbc.oracle>${project.basedir}/src/main/resources</output.directory.jdbc.oracle>
</properties>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc</artifactId>
<version>6</version>
<scope>system</scope>
<systemPath>${output.directory.jdbc.oracle}/lib/ojdbc6.jar</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dfile.encoding=UTF8</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>
pom.xml (service )
<?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">
<parent>
<artifactId>gov-multiple-modules</artifactId>
<groupId>gov</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.service</groupId>
<artifactId>service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.dao</groupId>
<artifactId>dao</artifactId>
<version>${version.dao.module}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${version.mapstruct}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dfile.encoding=UTF8</argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.apache.maven.plugins}</version>
<groupId>org.apache.maven.plugins</groupId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${version.mapstruct}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
pom.xml (web )
It is the work with requests from clients (Contoroller and RestControllers).
There is an entry point in app.
<?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">
<parent>
<artifactId>gov-multiple-modules</artifactId>
<groupId>gov</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.web</groupId>
<artifactId>web</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.service</groupId>
<artifactId>service</artifactId>
<version>${version.service.module}</version>
</dependency>
</dependencies>
<build>
<finalName>weblogic-war-gov</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dfile.encoding=UTF8</argLine>
</configuration>
</plugin>
<plugin> <!--It is for convert beans-->
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.apache.maven.plugins}</version>
<groupId>org.apache.maven.plugins</groupId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${version.mapstruct}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
pom.xml (parrent)
<?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>
<modules>
<module>dao</module>
<module>service</module>
<module>web</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>gov</groupId>
<artifactId>gov-multiple-modules</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>gov-multiple-modules</name>
<description>project with Spring Boot for multiple module applications</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<version.apache.maven.plugins>3.8.1</version.apache.maven.plugins>
<version.mapstruct>1.3.0.Final</version.mapstruct>
<version.apache.common.lang3>3.9</version.apache.common.lang3>
<version.apache.commons.text>1.8</version.apache.commons.text>
<version.apache.commons.beanutils>1.9.4</version.apache.commons.beanutils>
<version.hibernate.validator>6.0.17.Final</version.hibernate.validator>
<version.reflection>0.9.11</version.reflection>
<version.dao.module>0.0.1-SNAPSHOT</version.dao.module>
<version.service.module>0.0.1-SNAPSHOT</version.service.module>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</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-test</artifactId>
<scope>test</scope>
</dependency>
<!--This artifact need for testing that to find classes into classpath-->
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>${version.reflection}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${version.apache.common.lang3}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>${version.apache.commons.text}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>${version.apache.commons.beanutils}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
</dependencies>
</project>
An entry point
#SpringBootConfiguration
#SpringBootApplication
#EnableJpaRepositories(basePackages = {"com.dao", "com.service"})
#EntityScan(basePackages = {"com.dao"})
#ComponentScan(basePackages = {"com.service", "com.dao", "com.web"})
public class WebSpringBootJarApplication
extends SpringBootServletInitializer
implements WebApplicationInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger( WebSpringBootJarApplication.class );
public static void main(String[] args) {
SpringApplication.run(WebSpringBootJarApplication.class, args);
LOGGER.info("Start an application...");
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
LOGGER.info("There is building the web application!");
return builder.sources(WebSpringBootJarApplication.class);
}
}
src/main/webapp/WEB-INF/weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
https://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd
http://xmlns.oracle.com/weblogic/weblogic-web-app
https://xmlns.oracle.com/weblogic/weblogic-web-app/1.9/weblogic-web-app.xsd">
<wls:context-root>sun</wls:context-root>
</wls:weblogic-web-app>
After running I must see the page the greeting.
com.web.controller.index.IndexController
#Controller
public class IndexController {
#RequestMapping(value="/", method= RequestMethod.GET)
public String index() {
return "index";
}
}
src/main/resources/templates/index.html
But I get an error.
http://localhost:7001/sun/
in an browser
Error 500--Internal Server Error java.lang.NullPointerException at
weblogic.servlet.internal.ServletResponseImpl.sendContentError(ServletResponseImpl.java:738)
at
weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:796)
at
weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:713)
at
org.springframework.boot.web.servlet.support.ErrorPageFilter$ErrorWrapperResponse.sendErrorIfNecessary(ErrorPageFilter.java:349)
at
org.springframework.boot.web.servlet.support.ErrorPageFilter$ErrorWrapperResponse.getWriter(ErrorPageFilter.java:363)
at
org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration$StaticView.render(ErrorMvcAutoConfiguration.java:227)
at
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1373)
at
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1118)
in console IDE
-"[2020-03-11 08:53:30,118] Artifact web:war exploded: Artifact is deployed successfully [2020-03-11 08:53:30,119] Artifact web:war
exploded: Deploy took 14,724 milliseconds
--11-03-2020 08:53:30.612 - INFO 17568 o.s.web.servlet.DispatcherServlet : Initializing Servlet
'dispatcherServlet' -"--11-03-2020 08:53:30.613 -DEBUG 17568
o.s.web.servlet.DispatcherServlet : Detected
StandardServletMultipartResolver -"--11-03-2020
08:53:30.621 -DEBUG 17568 o.s.web.servlet.DispatcherServlet :
enableLoggingRequestDetails='false': request parameters and headers
will be masked to prevent unsafe logging of potentially sensitive data
-"--11-03-2020 08:53:30.621 - INFO 17568 o.s.web.servlet.DispatcherServlet : Completed initialization
in 8 ms -"--11-03-2020 08:53:30.624 -DEBUG 17568
o.s.web.servlet.DispatcherServlet : GET "/sun/", parameters={}
-"--11-03-2020 08:53:30.628 -DEBUG 17568 s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to
com.web.controller.index.IndexController#index() -"--11-03-2020
08:53:30.647 -DEBUG 17568 o.s.w.s.v.ContentNegotiatingViewResolver :
Selected 'text/html' given [text/html, image/gif, image/jpeg,
/;q=.2] -"--11-03-2020 08:53:30.647 -DEBUG 17568 o.s.web.servlet.view.JstlView : View name 'index', model
{} -"--11-03-2020 08:53:30.652 -DEBUG 17568
o.s.web.servlet.view.JstlView : Forwarding to [index]
-"--11-03-2020 08:53:30.653 -DEBUG 17568 o.s.web.servlet.DispatcherServlet : "FORWARD" dispatch for GET
"/sun/index", parameters={} -"--11-03-2020 08:53:30.656 -DEBUG 17568
o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to
ResourceHttpRequestHandler ["classpath:/META-INF/resources/",
"classpath:/resources/", "classpath:/static/", "classpath:/public/",
"/"] -"--11-03-2020 08:53:30.657 -DEBUG 17568
o.s.w.s.r.ResourceHttpRequestHandler : Resource not found
-"--11-03-2020 08:53:30.657 -DEBUG 17568 o.s.web.servlet.DispatcherServlet : Exiting from "FORWARD"
dispatch, status 404 -"--11-03-2020 08:53:30.664 -DEBUG 17568
o.s.web.servlet.DispatcherServlet : Error rendering view
[org.springframework.web.servlet.view.JstlView: name 'index'; URL
[index]]
- java.lang.NullPointerException: null at weblogic.servlet.internal.ServletResponseImpl.sendContentError(ServletResponseImpl.java:738)
~[com.oracle.weblogic.servlet.jar:12.2.1.4] at
weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:796)
~[com.oracle.weblogic.servlet.jar:12.2.1.4] at
weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:713)
~[com.oracle.weblogic.servlet.jar:12.2.1.4] at
org.springframework.boot.web.servlet.support.ErrorPageFilter$ErrorWrapperResponse.sendErrorIfNecessary(ErrorPageFilter.java:349)
~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE] at
org.springframework.boot.web.servlet.support.ErrorPageFilter$ErrorWrapperResponse.flushBuffer(ErrorPageFilter.java:343)
~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE] at
weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:336)
~[com.oracle.weblogic.servlet.jar:12.2.1.4] at
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:171)
~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE] at
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:316)
~[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE] at
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1373)
[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE] at
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1118)
[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE] at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1057)
[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE] at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE] at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE] at
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE] at
javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
[javax.servlet.javax.servlet-api.jar:3.1.0] at
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
[spring-webmvc-5.2.4.RELEASE.jar:5.2.4.RELEASE] ...
"java.lang.NullPointerException: null at
weblogic.servlet.internal.ServletResponseImpl.sendContentError(ServletResponseImpl.java:738)
at
weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:796)
at
weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:713)
at
org.springframework.boot.web.servlet.support.ErrorPageFilter$ErrorWrapperResponse.sendErrorIfNecessary(ErrorPageFilter.java:349)
at
org.springframework.boot.web.servlet.support.ErrorPageFilter$ErrorWrapperResponse.flushBuffer(ErrorPageFilter.java:343)
at
weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:336)
at
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:171)
...
--11-03-2020 08:53:30.666 -DEBUG 17568 o.s.web.servlet.DispatcherServlet : Failed to complete
request: java.lang.NullPointerException -"--11-03-2020
08:53:30.667 -ERROR 17568 o.s.b.w.servlet.support.ErrorPageFilter :
Forwarding to error page from request [/] due to exception [null]
It worked then the application was not multi module project.
Any ideas what the errors are? Please.
Solution
I needed to add an dependency - the thymeleaf. The static conten don't run without.
It need to add into pom's web-module.
<groupId>com.web</groupId>
<artifactId>web</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>

How to add a spring-boot jar as a dependency in a new spring-boot project without changing the original pom

In order to add azure app insights in an old spring-boot jar(which already has micrometer), I've created a new spring-boot project and added it as a dependency. However, after a successful Maven build, while executing it as spring-boot app, I'm getting Caused by: java.io.FileNotFoundException: class path resource [org/springframework/web/servlet/config/annotation/WebMvcConfigurerAdapter.class] exception. Here are my two POM files,
POM of the old spring-boot jar:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>microservice</artifactId>
<groupId>my-app-service</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>microservice-my-app</artifactId>
<dependencies>
<!-- few dependencies -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifestEntries>
<Implementation-Version>${project.version}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>app</classifier>
<mainClass>com.my.package.MyApplication</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
POM of the new spring-boot project:
<?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>
<groupId>com.my.app.appinsights</groupId>
<artifactId>microservice-my-app-appinsights</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>microservice-my-app-appinsights</name>
<description>Demo project for Spring Boot</description>
<properties>
<applicationinsights.version>1.1.1</applicationinsights.version>
<java.version>1.8</java.version>
<applicationinsights.version>2.5.1</applicationinsights.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.6.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>my-app-service</groupId>
<artifactId>microservice-my-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-spring-boot-starter</artifactId>
<version>${applicationinsights.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-webflux</artifactId>
<version>3.0.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifestEntries>
<Implementation-Version>1.0.0</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>app</classifier>
<mainClass>com.my.app.appinsights.MicroserviceMyAppinsightsApplication</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Exception stack:
2020-02-03 13:48:39.726 WARN 2420 --- [ main] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.microsoft.applicationinsights.autoconfigure.ApplicationInsightsWebMvcAutoConfiguration]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/web/servlet/config/annotation/WebMvcConfigurerAdapter.class] cannot be opened because it does not exist
2020-02-03 13:48:39.734 INFO 2420 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-02-03 13:48:39.742 ERROR 2420 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.microsoft.applicationinsights.autoconfigure.ApplicationInsightsWebMvcAutoConfiguration]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/web/servlet/config/annotation/WebMvcConfigurerAdapter.class] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:596)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:302)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:586)
at org.springframework.context.annotation.ConfigurationClassParser.access$900(ConfigurationClassParser.java:108)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.lambda$processGroupImports$1(ConfigurationClassParser.java:805)
at java.util.ArrayList.forEach(ArrayList.java:1257)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:801)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:771)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:185)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202)
at com.my.app.appinsights.MicroserviceMyAppinsightsApplication.main(MicroserviceMyAppinsightsApplication.java:14)
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/web/servlet/config/annotation/WebMvcConfigurerAdapter.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:51)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.createMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:86)
at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.getMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:73)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81)
at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:682)
at org.springframework.context.annotation.ConfigurationClassParser$SourceClass.getSuperClass(ConfigurationClassParser.java:995)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:332)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:586)
... 22 common frames omitted
It turns out that the azure app-insights needs spring-boot-starter-web to work properly. But since that jar is already present in the parent of the existing jar, I can not add it to my current POM file. This might mean I might not be importing the old jar in my new POM correctly.
How do I add the existing spring-boot jar as a dependency in my new spring-boot's POM file, without making any modifications in the existing jar or its POM?
Can you please check the packing of both the projects, if the child project has different packing then parent project, then you need to add component scan at your child main class from where you are running your project.
For example,
Parent project has package name
com.my.app
And
child project had package name
com.my.app.appinsights
then you need to add component scan in main class
#ComponentScan("com.my.app")
Spring boot by default scan beans from sub-packages of the main class. To override the component scan you need to add this annotation so that it will scan beans from given package also.

Getting error while running springboot application

Not able to run spring boot application
Tried removing contents of /C:/Users/SaurKumar/.m2/repository/org/springframework/data/spring-data-commons/2.1.10.RELEASE/spring-data-commons-2.1.10.RELEASE.jar
:: Spring Boot :: (v2.1.8.RELEASE)
2019-09-08 05:22:05.217 INFO 2420 --- [ main] i.j.c.CourseApiDataApplication : Starting CourseApiDataApplication on BLRLW8166 with PID 2420 (C:\Users\SaurKumar\Downloads\course-api-data\course-api-data\target\classes started by saurkumar in C:\Users\SaurKumar\Downloads\course-api-data\course-api-data)
2019-09-08 05:22:05.222 INFO 2420 --- [ main] i.j.c.CourseApiDataApplication : No active profile set, falling back to default profiles: default
2019-09-08 05:22:06.110 INFO 2420 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-09-08 05:22:06.215 ERROR 2420 --- [ 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.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension.postProcess(JpaRepositoryConfigExtension.java:121)
The following method did not exist:
org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)Ljava/lang/String;
The method's class, org.springframework.data.repository.config.RepositoryConfigurationSource, is available from the following locations:
jar:file:/C:/Users/SaurKumar/.m2/repository/org/springframework/data/spring-data-commons/2.1.10.RELEASE/spring-data-commons-2.1.10.RELEASE.jar!/org/springframework/data/repository/config/RepositoryConfigurationSource.class
It was loaded from the following location:
file:/C:/Users/SaurKumar/.m2/repository/org/springframework/data/spring-data-commons/2.1.10.RELEASE/spring-data-commons-2.1.10.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.data.repository.config.RepositoryConfigurationSource
Process finished with exit code 1
-----------------------------------------
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.1.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.javabrains</groupId>
<artifactId>course-api-data</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>course-api-data</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.11.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
From the logs, it seems Spring is picking a different version for groupId org.springframework.data than the one provided with spring-data-jpa. If you could match the versions of spring-boot-starter-web and spring-data-jpa, it should work.
Quick fix being: Remove the version number for spring-data-jpa and it will by default take the latest version, which in your case is 2.1.10.RELEASE.

Spring-boot inbuilt tomcat server not starting

I am building a very basic spring-boot service using the inbuild tomcat server.
Pom looks like this :
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!--<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>-->
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-jdbc</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<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.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
I am setting the port in the application.properties file as server.port=8089. There is one Ping URI added in the controller class as :
#RequestMapping("/ping")
#RestController
public class helloController {
#RequestMapping(method= RequestMethod.GET,produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<String> ping(){
return new ResponseEntity<>("Hello World Spring-boot app", HttpStatus.OK);
}
When I do a mvn clean package everything works fine and the build is a success. But when I run the application from the Main() this is what the log looks like :
2017-09-19 10:37:32.219 INFO 6436 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default
2017-09-19 10:37:32.290 INFO 6436 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#77f99a05: startup date [Tue Sep 19 10:37:32 PDT 2017]; root of context hierarchy
2017-09-19 10:37:33.782 INFO 6436 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-09-19 10:37:33.802 INFO 6436 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 2.043 seconds (JVM running for 2.802)
2017-09-19 10:37:33.802 INFO 6436 --- [ Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#77f99a05: startup date [Tue Sep 19 10:37:32 PDT 2017]; root of context hierarchy
2017-09-19 10:37:33.802 INFO 6436 --- [ Thread-2] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
The log is not showing what port the service is starting .
What else is to be done to start the service on the designated port and to keep the server up an running?
Solved this problem. Started the in built tomcat server using spring-boot:run option

Categories