4

I have one web app which is working fine on the local machine, but when I am trying to deploy the same JAR to one of my windows server, it's not working fine. it's running as a service but when I'm trying to access the web app through the Browser it doesn't render anything, is their any additional configuration is required in order to deploy it and up it over windows server, any help will be highly appreciable, the stack that I'm using the Web App is mentioned below.

Spring Boot - 1.4.7.RELEASE

Java - Version - 1.8

MySQL - 5.7

Embedded Tomcat Version- 8.5.15

@SpringBootApplication
@ComponentScan(basePackages = "com.abc.xyz")
public class Application extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

application.properties file is as follows

 #JPA
    #spring.datasource.hikari.username = root
    #spring.datasource.hikari.password = root
    #spring.datasource.hikari.jdbc-url = jdbc:mysql://localhost:3306/dbname?useUnicode=yes&characterEncoding=UTF-8
    #spring.datasource.type = com.zaxxer.hikari.HikariDataSource
    spring.datasource.driverClassName=com.mysql.jdbc.Driver
    spring.datasource.username = root
    spring.datasource.password = xyz
    spring.datasource.url = jdbc:mysql://localhost:3306/dbname?useUnicode=yes&characterEncoding=UTF-8&useSSL=false

    spring.jpa.hibernate.ddl-auto = update
    spring.jpa.show-sql = false
    #spring.jpa.format-sql = true
    spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect
    spring.jpa.properties.hibernate.current_session_context_class = org.springframework.orm.hibernate5.SpringSessionContext
    spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
    #Logging
    logging.level.org.springframework = INFO
    logging.level.org.hibernate = INFO
    logging.level.com.karza = INFO
    logging.file= D:/abc/xyz.log
    # MVC
    #spring.view.prefix=/templates/views/
    #spring.view.suffix=.jsp
    spring.mvc.view.prefix=/WEB-INF/jsp/views/
    spring.mvc.view.suffix=.jsp
    #spring.view.prefix=/WEB-INF/jsp/views/
    #spring.view.suffix=.jsp
    #server
    server.context-path = /
    server.port = 8090
    server.compression.enabled = true
    server.compression.mime-types = application/json,application/xml,text/html,text/xml,text/plain

pom.xml is as follows

<?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.abc.xyz</groupId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>ABC</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.7.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.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jersey</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-thymeleaf</artifactId> 
            </dependency> -->
         <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
        </dependency> 
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</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.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> -->
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>

        <!-- <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> 
            </dependency> -->
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.7</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>3.4.1</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <!-- <version>1.4.196</version> -->
        </dependency>
        <dependency>
            <groupId>net.sf.flexjson</groupId>
            <artifactId>flexjson</artifactId>
            <version>3.3</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.8.3</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>applicationinsights-web</artifactId>
            <version>1.0.6</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-storage</artifactId>
            <version>5.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>applicationinsights-logging-logback</artifactId>
            <version>1.0.6</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-svc-mgmt</artifactId>
            <version>0.9.7</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-svc-mgmt-compute</artifactId>
            <version>0.9.7</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-svc-mgmt-network</artifactId>
            <version>0.9.1</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-svc-mgmt-sql</artifactId>
            <version>0.9.7</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-svc-mgmt-storage</artifactId>
            <version>0.9.7</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-svc-mgmt-websites</artifactId>
            <version>0.9.7</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc-portlet</artifactId>
        </dependency>
    </dependencies>

    <build>
     <plugins>
        <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> 
            </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <executable>true</executable>
            </configuration>
        </plugin>
    </plugins> 
      <!-- <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.4.7.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins> -->
</build>


    <artifactId>ABC</artifactId>
</project>
Mavericks
  • 283
  • 1
  • 7
  • 20

1 Answers1

0

I just updated the pom.XML, I updated it from JAR to war and run it as WAR and it worked, I executed it JAVA -jar APPLICATION_NAME.jar, and it worked like charm. Hope this will help others as well.

Citing the link which saved me.

https://www.mkyong.com/spring-boot/spring-boot-hello-world-example-jsp/

Mavericks
  • 283
  • 1
  • 7
  • 20