Publishing EAR containing Spring Rest Service in WebLogic 12.1.3 - java

I've built a small project to provide rest services using springframework. the problem is to access this project inside an EAR after publishing this EAR into a WebLogic server.
When I publish this project as an standalone war in my weblogic everything ends well, my SpringWebAppInitializer is loaded as expected when the server starts and I can reach the webservice using the address localhost:7001/internal-webservices/project/12. But when I add this WAR to the EAR, the SpringWebAppInitializer is never invoked.
Any ideas?
Some of my configurations:
The pom.xml:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.1.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<dependency>
My ApplicationContextConfig class:
#Configuration
#EnableWebMvc
#ComponentScan("my_package.*")
public class ApplicationContextConfig {
// No need ViewSolver
// Other declarations if needed ...
}
My WebApplicationInitializer:
public class SpringWebAppInitializer implements WebApplicationInitializer{
#Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
appContext.register(ApplicationContextConfig.class);
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("internal-webservices",
new DispatcherServlet(appContext));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
// UTF8 Charactor Filter.
FilterRegistration.Dynamic fr = servletContext.addFilter("encodingFilter", CharacterEncodingFilter.class);
fr.setInitParameter("encoding", "UTF-8");
fr.setInitParameter("forceEncoding", "true");
fr.addMappingForUrlPatterns(null, true, "/*");
}
}
And, my RestController class:
#RestController
public class ProjectController {
#RequestMapping(value = "/project/{id}", method = RequestMethod.GET,
produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
public List<String> getProject(#PathVariable("id") String id) {
List<String> result = new ArrayList<String>();
result.add("id: "+ id);
return result;
}
}
Regards,
Felipe

Related

Request method 'GET' not supported in AWS server Spring Boot REST API status 500

my Rest API is working fine locally but the moment I put the same JAR and run it from cloud server, I can only call the GET API and none of the POST API from Postmen.
Below are my code.
RestController
#CrossOrigin(origins = "*", maxAge = 3600)
#RestController
#RequestMapping("/api/test")
public class TestController {
#GetMapping("/all")
public String allAccess() {
return "Public Content.";
}
#PostMapping("/testpostA")
public ResponseEntity<?> testPostA() {
return ResponseEntity.ok(new MessageResponse("Test POST successfully!"));
}
#PostMapping("/testpostB")
public String testPostB() {
return "String return POST successfully.";
}
}
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.4.2</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.eurogain</groupId>
<artifactId>WebPortal</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>WebPortal</name>
<description>Java Spring Boot project for the Eurogain web portal for both internal and external client.</description>
<properties>
<java.version>15</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</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-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</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-web</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</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>
</plugin>
</plugins>
</build></project>
WebSecurityConfigurationAdapter
#Configuration
#EnableWebSecurity
#EnableGlobalMethodSecurity(
// securedEnabled = true,
// jsr250Enabled = true,
prePostEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
#Autowired
UserDetailsServiceImpl userDetailsService;
#Autowired
private AuthEntryPointJwt unauthorizedHandler;
#Bean
public AuthTokenFilter authenticationJwtTokenFilter() {
return new AuthTokenFilter();
}
#Override
public void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
authenticationManagerBuilder.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
}
#Bean
#Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
#Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
#Override
protected void configure(HttpSecurity http) throws Exception {
System.out.println("============================ Inside WebSecurityConfig ===========================Ken");
http.csrf().disable().authorizeRequests().anyRequest().permitAll();
}}
Lastly, the web application:
#SpringBootApplication
public class WebPortalApplication {
public static void main(String[] args) {
SpringApplication.run(WebPortalApplication.class, args);
}}
Running the same JAR file locally, no issue on calling all of the POST and GET API. However, when we move the same JAR over to AWS EC2 cloud instance and run it, we can only call the GET API. The following error was thrown at the Postmen console when calling any of the POST API:
However, no issue when calling the GET API:
Server console output - no error:
UPDATE - Round 1
Tested using wget, error 500 as well. No futher info.
UPDATE - Round 2
Tested using wget POST, and after modifying WebSecurityConfig. Here is the screeshot:
Server console contains warning upon the wget POST:
The updated code for WebSecurityConfig:
#Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
#Override
public void configure(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable();
}
}
Try config cors like that:
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
#Configuration
public class CorsConfig {
#Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
#Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("HEAD", "GET", "PUT", "POST", "DELETE", "PATCH");
}
};
}
}
The problem was due to the Nginx reverse proxy handling. In localhost, I was using HTTP, but in the dev server, we are only using HTTPS. Thus, I used HTTPS for all the RESTful API URLs.

Primefaces Spring boot - authentication provider is called twice

I am building an application with spring boot(war) and primefaces. I created a login with a custom authentication provider. When my app is processing the credentials, spring verify them twice. Why?
ColombianApplication.java
#Configuration
#EnableJpaRepositories("com.colombian.online.repository")
#EntityScan("com.colombian.online.entity")
#ComponentScan("com.colombian.online")
#SpringBootApplication
public class ColombianApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(ColombianApplication.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ColombianApplication.class);
}
}
CustomAutheticationProvider.java
#Component
public class CustomAuthenticationProvider implements AuthenticationProvider {
#Autowired
private LoginService loginService;
#Override
public Authentication authenticate(Authentication auth) throws AuthenticationException {
Usuario usuario = getCurrentUser();
if (usuario == null) {
String username = auth.getName();
String password = auth.getCredentials().toString();
Usuario usuarioQuery = loginService.findUserByCredentials(username, password);
if (usuarioQuery == null) {
throw new UsernameNotFoundException("User not exist or your credentials are incorrect");
}
return new UsernamePasswordAuthenticationToken(usuarioQuery, password);
}
return new UsernamePasswordAuthenticationToken(usuario
, usuario.getPwd());
}
#Override
public boolean supports(Class<?> type) {
return type.equals(UsernamePasswordAuthenticationToken.class);
}
public Usuario getCurrentUser() {
if (SecurityContextHolder.getContext().getAuthentication() != null) {
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if (principal instanceof String) {
return null;
}
return (Usuario) principal;
} else {
return null;
}
}
}
CustomContextInitializer.java
#Configuration
public class CustomContextInitializer {
#Bean
public ServletContextInitializer servletContextInitializer() {
return servletContext -> {
servletContext.setInitParameter("com.sun.faces.forceLoadConfiguration", Boolean.TRUE.toString());
servletContext.setInitParameter("primefaces.THEME", "nova-light");
};
}
#Bean
public ServletRegistrationBean servletRegistrationBean() {
ServletRegistrationBean registration = new ServletRegistrationBean<>(new FacesServlet(), "*.xhtml");
registration.setName("Faces Servlet");
registration.setLoadOnStartup(1);
return registration;
}
#Bean
public ServletListenerRegistrationBean<ConfigureListener> jsfConfigureListener() {
return new ServletListenerRegistrationBean<>(new ConfigureListener());
}
}
SecurityConfiguration.java
#Configuration
#EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
#Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity.csrf().disable().authorizeRequests()
.antMatchers("/resources/**", "/javax.faces.resource/**", "/"
).permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/").failureUrl("/?error=true")
.defaultSuccessUrl("/home")
.and()
.logout().logoutUrl("/logout").permitAll().logoutSuccessUrl("/");
}
#Bean
public FilterRegistrationBean rewriteFilter() {
FilterRegistrationBean rwFilter = new FilterRegistrationBean(new RewriteFilter());
rwFilter.setDispatcherTypes(EnumSet.of(DispatcherType.FORWARD, DispatcherType.REQUEST,
DispatcherType.ASYNC, DispatcherType.ERROR));
rwFilter.addUrlPatterns("/*");
return rwFilter;
}
}
My pom.xml
<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>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- Primefaces with spring -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>7.0</version>
</dependency>
<!--dependency>
<groupId>org.joinfaces</groupId>
<artifactId>joinfaces-dependencies</artifactId>
<version>4.1.1</version>
<type>pom</type>
</dependency-->
<!-- Pretty faces -->
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-servlet</artifactId>
<version>3.4.4.Final</version>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<!-- Loggers -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<!-- Spring tests -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.1-b04</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.1-b04</version>
<type>jar</type>
</dependency>
</dependencies>
The project has not web.xml. I use ocp library.
I fixed the problem, verifying the current user from SecurityContextHolder, and sending the same credentials.

Unable to find message body reader with content type application/json in Jersey Test Framework

I have selected Jersey Test Framework to implement unit test cases for REST services.But i am getting following issue once i ran the test.
Note: I even add the resteasy-jackson-provider into pom file but couldn't help.
Here is the .pom file dependency
<!-- jersey security dependency -->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey.version}</version>
</dependency>
<!-- jersey test framework dependency -->
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>2.3.4.Final</version>
</dependency>
<!--junit Dependency-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
MockServices.Java
#Path("/hello")
public class MockServices {
#GET
#Produces(MediaType.APPLICATION_JSON)
#Path("/world")
public DateVO getHello() {
DateVO j=new DateVO ();
j.setActive(true);
return j;
}
}
MockServicesTest.Java
public class MockServicesTest extends JerseyTest {
#Override
protected Application configure() {
return new ResourceConfig(MockServices.class);
}
#Test
public void test() {
Response hello = target("/hello/world").request().get();
System.out.println(hello.readEntity(String.class));//throw an above exception
}
}
Please let me know how can i overcome this problem.
Override your provider method like this
#Override
protected Application configure() {
ResourceConfig config =new ResourceConfig(MockServices.class).register(JacksonFeature.class).register("Your ContextResolver<ObjectMapper> implementation class");
return config;
}
I had to use explicitly Jersey client implementation to invoke the REST end points.
#Test
public void test() {
final Client client = new JerseyClientBuilder().build();
WebTarget target = client.target("http://localhost:9998");
final Response response =
target.path("/hello/world").request().get();
final String json = response.readEntity(String.class);
}
Reference

Spring cloud : Can not get Feign client to work with consul

I am trying to set up a simple spring cloud consul app.
I have a "distribution" service up and registered in consul (with the spring.application.name property set to "distribution")
I have an "acquisition" service that is trying to make a call to the "distribution" service using feign.
Here is my main class
#Configuration
#EnableAutoConfiguration
#EnableDiscoveryClient
#RestController
#EnableFeignClients
#EnableHystrix
public class Acquisition {
#Autowired
private DiscoveryClient discoveryClient;
#Autowired
private DistributionClient distributionClient;
#RequestMapping("/use-feign")
public String sendData() {
distributionClient.sendData(new Data("Hello World"));
return "sent";
}
#RequestMapping("/disco")
public String disco() {
List<ServiceInstance> list = discoveryClient.getInstances("distribution");
if (list != null && list.size() > 0) {
return list.get(0).getUri().toString();
}
return null;
}
public static void main(String[] args) {
SpringApplication.run(Acquisition.class, args);
}
}
here is my feign client
#FeignClient(value = "distribution")
interface DistributionClient {
#RequestMapping(method = RequestMethod.POST, value = "/data", consumes = "application/json")
void sendData(Data data);
}
and here is my pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-consul-dependencies</artifactId>
<version>1.0.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
When I request the "/disco" Url, the url of the "distribution" service is properly retrieved, which means that the whole discovery thing is working as expected.
But, when I request the "/use-feign" url, I get the following exception :
com.netflix.client.ClientException: Load balancer does not have
available server for client: distribution at
com.netflix.loadbalancer.LoadBalancerContext.getServerFromLoadBalancer(LoadBalancerContext.java:468)
~[ribbon-loadbalancer-2.2.0.jar:2.2.0] at
com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:184)
~[ribbon-loadbalancer-2.2.0.jar:2.2.0] at
com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:180)
~[ribbon-loadbalancer-2.2.0.jar:2.2.0] at
rx.Observable.unsafeSubscribe(Observable.java:8460)
~[rxjava-1.1.5.jar:1.1.5] at
rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:94)
~[rxjava-1.1.5.jar:1.1.5] at
rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:42)
~[rxjava-1.1.5.jar:1.1.5]
Am I missing any configuration ?
Thank you for your help.
spencergibb pointed out the problem : no health check endpoint was deployed.
Just adding spring-boot-actuator to the dependencies solved the issue.
In my case I had: spring-boot (2.4.2) with spring-cloud 2020.0.1, I have just added:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>

Spring MVC Java based config - JSP not resolving

I am developing a little demo project with Spring MVC on a Tomcat with hibernate and JSPs. The application was working with thymeleaf as a view resolver but I need to rewrite my thymeleaf template as a .JSP. So I needed to reconfig everything. I am also trying to only use annotation configuration files without any xml.
The problem is that I am seeing the source code of my JSP-File without resolving.
The Request-Mapping and the program logic already worked with thymeleaf + spring. I am getting no error messages in the log files. I tried a lot of changes so my config files may be inconsistent at the moment. Any pointers or advice is appreciated.
My config files are below:
MyWebAppInitializer:
public class MyWebAppInitializer implements WebApplicationInitializer {
private static final String CONFIG_LOCATION = "MvcConfiguration";
private static final String MAPPING_URL = "/";#Override
public void onStartup(ServletContext servletContext) throws ServletException {
WebApplicationContext context = getContext();
servletContext.addListener(new ContextLoaderListener(context));
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet", new DispatcherServlet(context));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping(MAPPING_URL);
}
private AnnotationConfigWebApplicationContext getContext() {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.setConfigLocation(CONFIG_LOCATION);
return context;
}
}
MvcConfiguration:
class MvcConfiguration extends WebMvcConfigurerAdapter {
#Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("/WEB-INF/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
#Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
#Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
}
BenutzerController:
#Controller
public class BenutzerController {
#Autowired
BenutzerRepository repository;
#ModelAttribute("Benutzer")
public Benutzer loadEmptyModelBean() {
return new Benutzer();
}
#ModelAttribute("userList")
public List < Benutzer > userList() {
return toList(repository.findAll());
}
#RequestMapping("/verwaltung")
public String verwaltung(#RequestParam(value = "message", required = false, defaultValue = "Defaultvalue") String message, ModelMap model) {
model.addAttribute("message", message);
return "verwaltung";
}
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>
<name>benutzerverwaltung</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<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-web</artifactId>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
EDIT: SOLUTION
editing the pom.xml:
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>8.0.29</version>
</dependency>
Are you using Spring Boot's embedded Tomcat? According to the answer to this question, you may need to add a dependency: compile("org.apache.tomcat.embed:tomcat-embed-jasper"). However, I've never got JSPs to work properly with an embedded tomcat - you can create a war file instead, as it says in the docs.

Categories

Resources