I'm working on a spring-boot project which I used JSP files and gives the Whitelabel Error Page. There was an unexpected error (type=Not Found, status=404).
I've put JSP in the /src/main/webapp/pages/ and the path has been given with the application properties.
This has several modules and the main component doesn't include the spring-boot dependancy and it only includes specific modules which needed. Codes inherit from other modules have been used with the spring-boot module since it cannot build separately.
And the particular sub-module doesn't include a spring-boot parent as the parent because the parent has to be defined at that point.
pom.xml (Some of the submodules inherited as dependencies has to remove from the pom due to privacy issues)
<?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>
<groupId>com.epic.cb</groupId>
<artifactId>EPICCB</artifactId>
<version>V1.00</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>M_EOD</artifactId>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.boot.eod.version>1.5.4.RELEASE</spring.boot.eod.version>
<spring.eod.version>4.3.4.RELEASE</spring.eod.version>
<apache.tomcat.version>7.0.55</apache.tomcat.version>
<com.epic.cb.version>V1.00</com.epic.cb.version>
<sql.version>6.2.1.jre8</sql.version>
<jquery.version>3.1.1</jquery.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.boot.eod.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>${spring.boot.eod.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
<version>${spring.boot.eod.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>${spring.boot.eod.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>${apache.tomcat.version}</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>${jquery.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.eod.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>${sql.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-dbcp</artifactId>
<version>${apache.tomcat.version}</version>
</dependency>
<dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</build>
</project>
application.properties
server.port=8589
spring.mvc.view.prefix=/WEB-INF/pages/
spring.mvc.view.suffix=.jsp
EodController.java
@Controller
public class EodController {
@Autowired
EodSchedulerService eodSchedulerService;
@ResponseBody
@RequestMapping(value = "/", method = {RequestMethod.GET})
public String viewMain() {
return "Hello World !!!";
}
@RequestMapping(value = "/viewEODDashboard", method = {RequestMethod.GET})
public String viewEODDashboard() {
return "eodTaskDashboard";
}
@RequestMapping(value = "/executeEodTasks", method = {RequestMethod.GET})
@ResponseStatus(code = HttpStatus.OK)
public void approveEODDashboard() {
eodSchedulerService.executeScheduledTasks();
}
}
EodStartup.java
@SpringBootApplication
@ComponentScan("com.epic.cb.*")
public class EodStartup {
public EodStartup() {
//default constructor
}
public static void main(String[] args) throws Exception {
SpringApplication.run(EodStartup.class, args);
}
}
File Structure
├── src
├── main
| ├── java
│ │ └── com
│ │ └── epic
│ │ └── cb
│ │ └── eod
│ │ ├── EodStartup.java
│ │ └── controller
│ │ └── EodController.java
| |
│ ├── resources
│ | └── application.properties
│ └── webapp
│ └── WEB-INF
│ └── pages
│ └── eodTaskDashboard.jsp
Following are a few links of what I've referred:
- Why do I always get Whitelabel Error Page with status "404" while running a simple Spring Boot Application
- Spring Boot JSP 404.Whitelabel Error Page
- Tomcat-embed-jasper added but jsp pages Whitelabel 404 Error
- Getting whitelabel error page when running springboot application etc..
I want to solve this with JSP. (since it has several other options ex: Thymeleaf)
Thank you in Advance!