0
votes

I am working with Spring Boot version 1.5.2.Release Angular 2 with systemjs config for front end Maven build with following high-level configuration

Pom.xml

<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>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
        <exclusion>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <fork>true</fork>
        <skip>false</skip>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19.1</version>
    <configuration>
        <testFailureIgnore>true</testFailureIgnore>
    </configuration>
</plugin>

<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>mmm.his.empi.WebComponentApplication</start-class>
</properties>

Application.java

@SpringBootApplication
@EnableJpaRepositories
@EnableAutoConfiguration (exclude = {HibernateJpaAutoConfiguration.class})
@Import({ AppConfig.class, HibernateConfiguration.class,  SwaggerConfig.class })
public class Application extends SpringBootServletInitializer{

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

    public static void main(String[] args) {
        System.out.println("WebComponentApplication started... 7.10");
        SpringApplication.run(applicationClass, args);
    }

    private static Class<Application> applicationClass = Application.class;
}

This configuration works fine with Tomcat deployment on Windows. But when i deploy the same war on tomcat, i am just getting 404 - No Resource found error

War Structure

  • ROOT.war
  • META-INF - Maven - MANIFEST
  • WEB-INF - classes - lib - lib-provided
  • org - springframework - boot - loader - (loader classes)

classes contains the spring boot application class and controllers. classes folder also contains the dist folder of Angular application

MANIFEST

Manifest-Version: 1.0
Implementation-Title: test-component
Implementation-Version: 0.0.1-SNAPSHOT
Built-By: XXX
Implementation-Vendor-Id: com.test.proj
Spring-Boot-Version: 1.5.2.RELEASE
Implementation-Vendor: Pivotal Software, Inc.
Main-Class: org.springframework.boot.loader.WarLauncher
Start-Class: com.test.proj.Application
Spring-Boot-Classes: WEB-INF/classes/
Spring-Boot-Lib: WEB-INF/lib/
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_91
Implementation-URL: http://maven.apache.org

I am deploying my war at the root context of Tomcat as ROOT.war I am not sure what is going wrong here. Please help.

1

1 Answers

0
votes

I resolved this issue. Its actually a JDK conflict on the linux machine. I have JDK 1.8 installed, but set the environment variable only for the user. but i deployed the app as a ROOT user. I had to set it for the ROOT user again for it to work properly.