1
votes

I am trying to deploy a spring boot application as a WAR to a tomcat server. I can build and deploy the war to the tomcat server just fine. When I start the server though my spring application never runs. The server starts up just fine. I have done everything Spring says to do here,

http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file

My project has its own custom Parent POM and consists of 2 modules.

I have read several other similar threads and as far as I can tell I have everything set up properly but clearly something is wrong. Any help would be much appreciated.

THank You!

Parent pom

<groupId>com.project</groupId>
<artifactId>TelematicsNotificationSystem</artifactId>
<name>TelematicsNotificationSystem</name>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
    <java.version>1.8</java.version>
    <artifact-deployer.version>2.0.0-RELEASE</artifact-deployer.version>
    <cxf.version>2.5.2</cxf.version>
    <start-class>com.project.TNS.TelematicsNotificationSystem</start-class>
</properties>

<modules>
    <module>TelematicsNotificationSystem-wsclient</module>
    <module>TelematicsNotificationSystem-web</module>
</modules>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
        <version>1.5.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>1.5.0.RELEASE</version>
    </dependency>

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

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
        <version>1.5.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>com.sun.mail</groupId>
        <artifactId>javax.mail</artifactId>
        <version>1.5.6</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.ldap</groupId>
        <artifactId>spring-ldap-core</artifactId>
        <version>1.3.0.RELEASE</version>
    </dependency>       
</dependencies>

Web Project Pom

<artifactId>TelematicsNotificationSystem-Web</artifactId>
<name>TelematicsNotificationSystem-Web</name>
<packaging>war</packaging>


<parent>
    <groupId>com.project</groupId>
    <artifactId>TelematicsNotificationSystem</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</parent>

<properties>
    <start-class>com.project.TNS.TelematicsNotificationSystem</start-class>
</properties>



<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <resources>
                <resource>
                    <filtering>true</filtering>
                    <directory>src/main/resources/</directory>
                </resource>
                </resources>
            </configuration>
        </plugin>
    </plugins>
</build>

My Application Class

package TNS;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;

@SpringBootApplication
public class TelematicsNotificationSystem extends SpringBootServletInitializer{

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

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

}

2
How are you deploying your war to Tomcat? - ck1
Check your catalina.out and localhost log file in tomcat logs directory. May be it log any config error. - Sangam Belose
For starters fix your dependencies, you are mixing Spring Boot 1.3.3, 1.3.0 and 1.5.0 jars. Next to that you have an old, non-compatible, version of spring-context-support added (remove that dependency as that is already pulled in elsewhere) and replace the mail dependency with spring-boot-starter-mail. I also strongly suggest to have your parent extend the sprig boot parent then also remove the war plugin (as you don't need that anymore). - M. Deinum
I am using the STS default pivotal tc server. I am just using the Add/Remove option when right clicking the server to deploy the war. Deinum I have edited my poms above, still the server starts without deploying the war. - Karaja

2 Answers

1
votes

Remember to refresh the application once deployed in Tomcat. It may be working well and only a refresh is needed.

0
votes

Although I agree with Deinum that I needed to clean up my Pom that was not the overall fix. The fix was to simply add a component scan to my class which contained my main method.

@SpringBootApplication
@ComponentScan(basePackageClasses = DashBoardController.class)
public class TelematicsNotificationSystem extends SpringBootServletInitializer

The starting app couldn't find the Controller so it could handle any of my mapping requests.