1

I have a spring boot application that I'm working on in IntelliJ. The views are JSP files stored in the /src/main/webapp/WEB-INF/view/

This application previously was setup as a WAR file running in a Tomcat container, but today I've tried to make it a standalone application with embedded Tomcat and things are going wrong.

The main issue is that when I load the jar file onto a Centos server and execute it, Spring Boot starts up fine but when try to view the application in the browser all I see is a blank screen and there are no errors showing in the console to indicate that anything has gone wrong.

If I run the application in IntelliJ, then everything is working absolutely fine.

I've extracted the jar file and it contains jasper in the LIB folder, and the WEB-INF/view/ folder is in the extracted files too, so I can't understand why it might not be working.

Here is my POM file;

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.nationallocums</groupId>
    <artifactId>intranet</artifactId>
    <packaging>jar</packaging>
    <version>0.0.1</version>
    <name>National Locums Intranet</name>

    <properties>
        <java-version>1.8</java-version>
    </properties>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.0.RELEASE</version>
    </parent>

    <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.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</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-security</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.37</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>sqljdbc4</artifactId>
            <version>4.0</version>
        </dependency>
        <!-- Apache Commons FileUpload -->

        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3.1</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>

        <!-- Apache Commons IO -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>

        <!-- Open CSV -->
        <dependency>
            <groupId>net.sf.opencsv</groupId>
            <artifactId>opencsv</artifactId>
            <version>2.3</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.4</version>
        </dependency>

        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.9.2</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>intranet</finalName>
        <resources>
            <resource>
                <directory>${basedir}/src/main/webapp</directory>
                <includes>
                    <include>**/**</include>
                </includes>
            </resource>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
                <includes>
                    <include>**/**</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

In my application.properties file I have the following to tell Spring Boot where the views are located;

spring.mvc.view.prefix = /WEB-INF/view/
spring.mvc.view.suffix = .jsp
SheppardDigital
  • 3,165
  • 8
  • 44
  • 74
  • Must be an executable WAR not a JAR. See http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-jsp-limitations – M. Deinum Sep 27 '16 at 06:08
  • Possible duplicate of [Is it possible with Spring Boot to serve up JSPs with a stand alone JAR packaging](http://stackoverflow.com/questions/37206862/is-it-possible-with-spring-boot-to-serve-up-jsps-with-a-stand-alone-jar-packagin) – Brian Clozel Sep 27 '16 at 07:03

0 Answers0