-1

I am trying to deploy my Spring boot application on a Tomcat 7 server and start it. I am able to deploy, while I am facing problems in starting the server.

What I did ?

1) Created a spring starter project with the initial configurations and dependencies.

2) Edited the 'org.eclipse.wst.common.project.facet.core.xml' file and changed the 'jst.web' version from 3.1 to 3.0. Cleaned the project.

3) Implemented ServletContextInitializer with onStartup method override based on the explicit configuration steps as per https://github.com/spring-projects/spring-boot/issues/522. Code looks like below

@Configuration
public class ContextInitializer implements ServletContextInitializer {

@Override
public void onStartup(ServletContext arg0) throws ServletException {
    // TODO Auto-generated method stub
}

}

and in my Application class

public static void main(String[] args) {
    SpringApplication.run(new Class[] { SocialIntegrationApplication.class, ContextInitializer.class }, args);
}

4) Performed a mvn clean install. Builds successfully.

But when starting the server, I am getting an error as Server Java Web Tomcat 7 Server failed to start.

Could you please help me out. Thanks.

EDIT : Sharing the catalina.out. Not able to see any error though.

127.0.0.1 - - [07/Feb/2017:18:16:17 +0530] "GET / HTTP/1.1" 404 899
0:0:0:0:0:0:0:1 - - [07/Feb/2017:18:16:18 +0530] "GET /ROOT/ HTTP/1.1" 200 37264
0:0:0:0:0:0:0:1 - - [07/Feb/2017:18:16:19 +0530] "GET /ROOT/pages/images/favicon.ico HTTP/1.1" 401 923
127.0.0.1 - - [07/Feb/2017:18:22:17 +0530] "GET / HTTP/1.1" 404 899
0:0:0:0:0:0:0:1 - - [07/Feb/2017:18:22:18 +0530] "GET /ROOT/ HTTP/1.1" 200 37264
0:0:0:0:0:0:0:1 - - [07/Feb/2017:18:22:18 +0530] "GET /ROOT/pages/images/favicon.ico HTTP/1.1" 401 923
0:0:0:0:0:0:0:1 - - [07/Feb/2017:18:22:27 +0530] "GET /ROOT/facebook HTTP/1.1" 200 37264
0:0:0:0:0:0:0:1 - - [07/Feb/2017:18:22:27 +0530] "GET /ROOT/pages/images/favicon.ico HTTP/1.1" 401 923
0:0:0:0:0:0:0:1 - - [07/Feb/2017:18:22:38 +0530] "GET /ROOT/facebook HTTP/1.1" 200 37264
0:0:0:0:0:0:0:1 - - [07/Feb/2017:18:22:38 +0530] "GET /ROOT/pages/images/favicon.ico HTTP/1.1" 401 923
0:0:0:0:0:0:0:1 - - [07/Feb/2017:18:25:17 +0530] "GET /ROOT/ HTTP/1.1" 200 37264
0:0:0:0:0:0:0:1 - - [07/Feb/2017:18:25:17 +0530] "GET /ROOT/pages/images/favicon.ico HTTP/1.1" 401 923
127.0.0.1 - - [07/Feb/2017:18:25:59 +0530] "GET / HTTP/1.1" 404 899
0:0:0:0:0:0:0:1 - - [07/Feb/2017:18:26:00 +0530] "GET /integration/ HTTP/1.1" 404 923
0:0:0:0:0:0:0:1 - - [07/Feb/2017:18:28:31 +0530] "GET /integration/ HTTP/1.1" 404 923
0:0:0:0:0:0:0:1 - - [07/Feb/2017:18:29:02 +0530] "GET / HTTP/1.1" 404 899
0:0:0:0:0:0:0:1 - - [07/Feb/2017:18:29:05 +0530] "GET / HTTP/1.1" 404 899

Sharing the server console log

    15:27:19.848 [localhost-startStop-1] ERROR org.slf4j.helpers.Util - SLF4J: Class path contains multiple SLF4J bindings.
15:27:19.852 [localhost-startStop-1] ERROR org.slf4j.helpers.Util - SLF4J: Found binding in [jar:file:/C:/XM/neo-java-web-sdk-2.53.6/repository/.archive/bin/logback-classic.jar!/org/slf4j/impl/StaticLoggerBinder.class]
15:27:19.852 [localhost-startStop-1] ERROR org.slf4j.helpers.Util - SLF4J: Found binding in [jar:file:/C:/XM/XM_Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/social-integration/WEB-INF/lib/logback-classic-1.1.9.jar!/org/slf4j/impl/StaticLoggerBinder.class]
15:27:19.853 [localhost-startStop-1] ERROR org.slf4j.helpers.Util - SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
15:27:20.269 [localhost-startStop-1] ERROR org.slf4j.helpers.Util - SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

EDIT 2 : Adding the logging.level.root=INFO to the properties file, getting the following exception

    11:53:20.995 [localhost-startStop-1] ERROR org.slf4j.helpers.Util - SLF4J: Class path contains multiple SLF4J bindings.
11:53:20.997 [localhost-startStop-1] ERROR org.slf4j.helpers.Util - SLF4J: Found binding in [jar:file:/C:/XM/neo-java-web-sdk-2.53.6/repository/.archive/bin/logback-classic.jar!/org/slf4j/impl/StaticLoggerBinder.class]
11:53:20.997 [localhost-startStop-1] ERROR org.slf4j.helpers.Util - SLF4J: Found binding in [jar:file:/C:/XM/XM_Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/social-integration-tomcat7/WEB-INF/lib/logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
11:53:20.998 [localhost-startStop-1] ERROR org.slf4j.helpers.Util - SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
11:53:21.283 [localhost-startStop-1] ERROR org.slf4j.helpers.Util - SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
11:53:22.303 [main] ERROR java.lang.Throwable - java.lang.ClassCircularityError: java/util/logging/LogRecord
11:53:22.303 [main] ERROR java.lang.Throwable -     at org.slf4j.bridge.SLF4JBridgeHandler.getSLF4JLogger(SLF4JBridgeHandler.java:198)
11:53:22.304 [main] ERROR java.lang.Throwable -     at org.slf4j.bridge.SLF4JBridgeHandler.publish(SLF4JBridgeHandler.java:293)
11:53:22.304 [main] ERROR java.lang.Throwable -     at java.util.logging.Logger.log(Logger.java:616)
11:53:22.304 [main] ERROR java.lang.Throwable -     at java.util.logging.Logger.doLog(Logger.java:641)
11:53:22.304 [main] ERROR java.lang.Throwable -     at java.util.logging.Logger.logp(Logger.java:841)
11:53:22.305 [main] ERROR java.lang.Throwable -     at org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:185)
11:53:22.305 [main] ERROR java.lang.Throwable -     at org.apache.juli.logging.DirectJDKLog.fatal(DirectJDKLog.java:161)
11:53:22.305 [main] ERROR java.lang.Throwable -     at org.apache.catalina.startup.Catalina.start(Catalina.java:695)
11:53:22.305 [main] ERROR java.lang.Throwable -     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
11:53:22.306 [main] ERROR java.lang.Throwable -     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
11:53:22.306 [main] ERROR java.lang.Throwable -     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
11:53:22.306 [main] ERROR java.lang.Throwable -     at java.lang.reflect.Method.invoke(Method.java:606)
11:53:22.307 [main] ERROR java.lang.Throwable -     at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
11:53:22.307 [main] ERROR java.lang.Throwable -     at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:428)

and my current pom.xml

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<groupId>com.xm</groupId>
<artifactId>social-integration</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>social-integration</name>
<description>Social integration using Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.1.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.7</java.version>
    <tomcat.version>7.0.59</tomcat.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-batch</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-social-facebook</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-social-linkedin</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-social-twitter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web-services</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-juli</artifactId>
        <version>7.0.59</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</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-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
    </dependency>
    <!-- Facebook APIs -->
    <dependency>
        <groupId>com.facebook.ads.sdk</groupId>
        <artifactId>facebook-java-ads-sdk</artifactId>
        <version>0.4.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

Vishnukk
  • 524
  • 2
  • 11
  • 27
  • There must be more informations in the catalina.out logfile. Please take a lokk and post it here – Jens Feb 27 '17 at 09:00
  • Judging by the `ClassCircularityError` it looks like the dependency on `org.slf4j:slf4j-log4j12` is the problem – Andy Wilkinson Feb 28 '17 at 08:28

2 Answers2

2

Spring Boot and Tomcat 7

pom.xml

version specification:

<properties>
    <tomcat.version>7.0.78</tomcat.version>
    <servlet-api.version>3.0.1</servlet-api.version>
</properties>

dependencies downgrade:

<dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>${servlet-api.version}</version>
        <scope>provided</scope>  <!-- provided: tomcat/lib/servlet-api.jar -->
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-juli</artifactId>
        <version>${tomcat.version}</version>
        <scope>runtime</scope> <!-- runtime: tomcat/bin/tomcat-juli.jar -->
    </dependency>
    <!-- remove it:
     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    -->
</dependencies>

Traditional deployment

To create a deployable war file (Tomcat 7) read this guide: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html

  • <packaging>war</packaging>
  • override: SpringBootServletInitializer.configure:

    @SpringBootApplication
    public class Application extends SpringBootServletInitializer {
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(Application.class);
        }
        public static void main(String[] args) throws Exception {
            SpringApplication.run(Application.class, args);
        }
    }
    
kinjelom
  • 6,105
  • 3
  • 35
  • 61
0

Can you add the following to your pom.xml and try,

<properties>
        <tomcat.version>your tomcat version</tomcat.version>
</properties>
sparrow
  • 1,825
  • 6
  • 24
  • 35