MarioC
MarioC

Reputation: 3228

Spring boot application does not start

I have a Spring Boot application which we install in some little servers for our products. It has always worked. This evening we have installed it in one of our servers and it did not start.

Every server is an image from a common image, so the OS is the same.

When we launch the .jar we are getting:

Oct 05, 2016 11:16:45 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Oct 05, 2016 11:16:45 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.5.5
Oct 05, 2016 11:16:46 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring embedded WebApplicationContext
Oct 05, 2016 11:17:03 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Tomcat

This is our application.properties which regards hibernate

# Username and password
spring.datasource.username = parkuser
spring.datasource.password = xxxxxxxxxxxxxxxxxxxxxx
spring.datasource.url= jdbc:mysql://xxxxxxxxxxxxxxxxxxxxxxxxx:3306/SMARTPARK?useSSL=false

# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
spring.jpa.show-sql = false

# Hibernate ddl auto (create, create-drop, update): with "update" the database
# schema will be automatically updated accordingly to java entities found in
# the project
spring.jpa.hibernate.ddl-auto = update

# Naming strategy
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy

# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext

In our pom.xml we have

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.1.RELEASE</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j</artifactId>
            <version>1.3.8.RELEASE</version>
        </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-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>

        </dependency>

This is our StartServer.class

@SpringBootApplication
@EnableScheduling
public class StartServer extends SpringBootServletInitializer{
    public static void main(String[] args){

        SpringApplication.run(StartServer.class, args);

    }


    @Bean
    public HibernateJpaSessionFactoryBean sessionFactory() {
        return new HibernateJpaSessionFactoryBean();
    }
}

I cannot understand why the same jar works in a device and gives this error in another one and i cannot understand which is the error...

Upvotes: 7

Views: 35269

Answers (3)

Kimchy
Kimchy

Reputation: 501

If in case you miss application.properties file in your project, then also you would face such issue. Check it's available in your classpath.

Upvotes: 0

I ran into same problem. Then after cleaning my local maven repository the application was up and running. Clean your local maven repo (due to corrupted dependency) and try again!

Upvotes: 2

AchillesVan
AchillesVan

Reputation: 4356

I'm not 100% sure but i would have replaced this :

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

With this:

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

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
...
 </dependencies>

See thus example below :

<groupId>org.springframework</groupId>
    <artifactId>gs-relational-data-access</artifactId>
    <version>0.1.0</version>

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

    <properties>
        ....
    </properties>

    <dependencies>

        <dependency>
           ....
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>[5,]</version>
        </dependency>
    </dependencies>

or else, just do this :

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

Upvotes: 0

Related Questions