Spring-boot inbuilt tomcat server not starting - java

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

Related

Vaadin spring boot Frontend compiling failed

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?

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.

Springboot : Not able to hit the url

After running the Main class, i am not able to get the output.
New to Spring Boot
Controller
#Controller
public class WelcomeController {
private static final String welcomemsg = "Welcome Mr. %s!";
#GetMapping("/welcome/user")
#ResponseBody
public Welcome welcomeUser(#RequestParam(name = "name", required = false, defaultValue = "Java Fan") String name)
{
return new Welcome(String.format(welcomemsg, name));
}
}
Main class
package com.beans.mainsrc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication(scanBasePackages = { "com.beans" })
public class DemoApplication {
public static void main(String[] args)
{
SpringApplication.run(DemoApplication.class, args);
}
}
console detail on running the main class
2018-09-28 00:40:01.268 INFO 2304 --- [ main] com.beans.mainsrc.DemoApplication : Starting DemoApplication on DESKTOP-551C51M with PID 2304 (F:\springbootdemo\demo\target\classes started by sparsh in F:\springbootdemo\demo)
2018-09-28 00:40:01.273 INFO 2304 --- [ main] com.beans.mainsrc.DemoApplication : No active profile set, falling back to default profiles: default
2018-09-28 00:40:01.346 INFO 2304 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#3e08ff24: startup date [Fri Sep 28 00:40:01 IST 2018]; root of context hierarchy WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/C:/Users/sparsh/.m2/repository/org/springframework/spring-core/5.0.9.RELEASE/spring-core-5.0.9.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release
2018-09-28 00:40:02.370 INFO 2304 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-09-28 00:40:02.392 INFO 2304 --- [ main] com.beans.mainsrc.DemoApplication : Started DemoApplication in 1.67 seconds (JVM running for 2.23)
2018-09-28 00:40:02.396 INFO 2304 --- [ Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#3e08ff24: startup date [Fri Sep 28 00:40:01 IST 2018]; root of context hierarchy
2018-09-28 00:40:02.398 INFO 2304 --- [ Thread-1] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
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>springboot</groupId>
<artifactId>springbootdemo</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>2.0.5.RELEASE</version>
<relativePath />
<!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</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>
Looks like your servlet container is not starting. Please try to add this maven dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
You can remove these dependencies :
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
They are provided by the suggested starter.

Spring Boot REST Controller returns 404 when deployed on external tomcat 9 server

I have a spring boot rest web application which works perfectly on the embedded server. However after following the steps mentioned in the is blog https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file, I got a 404 error message whan I send a resquest to a resource on the server.I have used java 1.8.0_212 locally and used java 1.8.0_131 and deployed my app on tomcat 9 on the server. One thing that's puzzling me is that the repositories which extends CrudRepository can be accessed. Below is my application's entry point.
#SpringBootApplication
#ComponentScan(basePackages = "com.dbe.ref")
public class RefmsApplication extends SpringBootServletInitializer {
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(RefmsApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(RefmsApplication.class, args);
}
and also my 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.dbe.ref</groupId>
<artifactId>refms</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>refms</name>
<description>project for Rural electrification fund</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>LATEST</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<start-class>com.RefmsApplication</start-class>
</properties>
<dependencies>
<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-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>angularjs</artifactId>
<version>1.4.10</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.4</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>eu.michael-simons</groupId>
<artifactId>wro4j-spring-boot-starter</artifactId>
<version>0.3.4</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.14</version>
</dependency>
<dependency>
<groupId>net.sourceforge.dynamicreports</groupId>
<artifactId>dynamicreports-core</artifactId>
<version>5.0.0</version>
</dependency>
</dependencies>
<build>
<finalName>refms</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Here is part of the log:
2017-09-19 10:38:20.564 INFO 6660 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'errorPageFilter' to: [/*]
2017-09-19 10:38:20.565 INFO 6660 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-09-19 10:38:20.566 INFO 6660 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-09-19 10:38:20.568 INFO 6660 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-09-19 10:38:20.568 INFO 6660 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-09-19 10:38:20.571 INFO 6660 --- [ main] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2017-09-19 10:38:20.571 INFO 6660 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'configurableWroFilter' to urls: [/wro4j/*]
2017-09-19 10:38:20.572 INFO 6660 --- [ main] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServletRegistration' to [/refms/*]
2017-09-19 10:38:20.573 INFO 6660 --- [ main] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
There is a little difference when you deploy application on embedded server and external server by default.
With embedded server you can access you application by using:
http://localhost:<port>/<resourceName>
While if you deploy war in another container then you need to add application name with version like:
http://localhost:<port>/<applicationNameWithVersion>/<resourceName>
For example if you deploy this example then URL for embedded server is:
http://localhost:8080/greeting
And URL for Externally deployed application if like:
http://localhost:8999/gs-rest-service-0.1.0/greeting
Note: This URL is of my application server so it may have some changes for yours.
Comment if you need help.
Check if the
<build>
<finalName>refms</finalName>
...
</build>
in the pom.xml corresponds with the
server.contextPath=/refms
in the application.properties and check the
<Context path="/refms"/>
in the context.xml. Perhaps your root context in tomcat
after deploy was different.
Additionally, change this dependence
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
by this
<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>
for external tomcat
Check the root package in src/main/java, it should be the same as the package name mentioned in the POM groupid ie. com.dbe.ref if there is any mismatch than the same issue occurs.
Make sure you have added context path to your spring Boot application. Typically it is in application.properties file inside src\main\resources. In that properties file, add the properties:
server.contextPath=/refms
You should be able to access your application using the bellow link
localhost:8080/refms/api/account/authenticate or localhost:8080/refms-xxxx/api/account/authenticate ( where xxxx is your artifact version )
in your comments you mentioned /authenticate is giving 404, this is because you have set the login process URL to “authenticate”. It’s the URL that the login form is posted to. If unspecified, it defaults to /login.
Spring Security framework intercepts that URL and gets login and password parameter.
When you deploy your application into Tomcat the URL depends on the context path under which your application gets deployed. Most of the time this is an exact match with the name of the war file which you put into the Tomcat 'webapps' directory. You can see the name by looking at your 'webapps' directory. Your war file is probably also expended into a directory by now.
Since you've put a finalName into your maven build section, your war file should be named: refms.war, so your application will run under:
http://host:port/refms/
My assumption is that you did not rename the war file to ROOT.war before you copied it into tomcat, so your application will not be running on:
http://host:port/
If you would do so your application will run similar to the embedded Tomcat instance; on the root context.
From your log file I can see that your authentication endpoint is mapped on /refms/
Mapping servlet: 'dispatcherServletRegistration' to [/refms/*]
This is relative to the context root of your application.
So in case you did not rename your war file, the authentication endpoint on which you receive a 404 is probably going to be under:
http://localhost:8080/refms/refms/api/account/authenticate

Spring netflix server config not returns key encripted

I'm creating a server config with Spring Netflix. I have configured the POM.XML and I have added the security dependency. Also I have configured the application.yml and bootstrap.yml files. When I call to the server with the encrypt command for returns the key encripted, the server responses:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing
this as a fallback.
Thu Jul 23 10:20:46 CEST 2015 There was an unexpected error (type=Not
Found, status=404). No message available
The call:
http://user:s3cret#localhost:8888/encrypt -d s3cret
Maven console:
2015-07-23 11:02:05.217 INFO 7948 --- [ main]
s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s):
8888 (http) 2015-07-23 11:02:05.218 INFO 7948 --- [ main]
nubbler.netflixserver.ConfigServerApp : Started ConfigServerApp in
5.106 seconds (JVM running for 5.922) 2015-07-23 11:02:13.765 INFO 7948 --- [nio-8888-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] :
Initializing Spring FrameworkServlet 'dispatcherServlet' 2015-07-23
11:02:13.766 INFO 7948 --- [nio-8888-exec-1]
o.s.web.servlet.DispatcherServlet : FrameworkServlet
'dispatcherServlet': initialization started 2015-07-23 11:02:13.785
INFO 7948 --- [nio-8888-exec-1] o.s.web.servlet.DispatcherServlet
: FrameworkServlet 'dispatcherServlet': initialization completed in 19
ms 2015-07-23 11:02:13.885 INFO 7948 --- [nio-8888-exec-1]
o.s.b.a.audit.listener.AuditListener : AuditEvent [timestamp=Thu
Jul 23 11:02:13 CEST 2015, principal=user,
type=AUTHENTICATION_SUCCESS,
data={details=org.springframework.security.web.authentication.WebAuthenticationDetails#b364:
RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null}]
¿Any idea? I have installed JCE extensions in the jdk (jdk_1.8.0_40) and I have checked that the application and maven use this jdk.
application.yml:
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri: https://github.com/xxxxx
basedir: target/config
security:
user:
password: s3cret
bootstrap.yml:
spring:
encrypt:
key: foobar
POM.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nubbler</groupId>
<artifactId>netflixserver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
</parent>
<name>netflixserver</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>1.0.3.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
</project>
I resolve it using Curl with the call.
Before I tried it with the browser (Chrome) and SoapUI, with both the server responses an error.

Categories