4
votes

I am trying to deploy a simple Spring Boot web app to Pivotal Cloud foundry, but I get the below error in my logs when i perform a cf push

java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextInitializer

Here is my pom.xml

    <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.0.BUILD-SNAPSHOT</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.7</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </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</groupId>
        <artifactId>spring-webmvc-portlet</artifactId>
    </dependency>
</dependencies>

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

<repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

The same app gets deployed in my local host and I have no issues building the war. Any thoughts on this ?

2
Looks like you may want to try deploying without tomcat and using a fat jar. A little confused by the portlet dependency. Is it a portlet? - code
This is a current limitation of CloudFoundry's Java buildpack. It doesn't yet support Spring Boot 1.4 due to a change in the layout of Spring Boot's executable jars: github.com/spring-projects/spring-boot/wiki/…. Using Spring Boot 1.3.3.RELEASE will avoid the problem for the time being. - Andy Wilkinson

2 Answers

6
votes

As Andy Wilkinson pointed out, this is an issue in a mismatch between Spring Boot 1.4 and the java_buildpack. It can be solved by explicitly mentioning the URL to the java_buildpack:

$ cf push -b https://github.com/cloudfoundry/java-buildpack.git …
0
votes

Seems like a jar did not download during the maven build due to an SSL handshake exception. For some reason my build did not fail in spite of the missing jar. Found this by enabling debug during the mvn clean install