0
votes

I am deploying a REST application in PCF. Application was developed using spring boot in Spring tool suite (STS) IDE. I have added cloud foundry plugin and added the application to PCF from STS. It gives me a start up error.

I tried all options available over internet , even then ended up with following error

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication

I did checked my snapshot jar where it has the dependency jar in the lib folder which contains the SpringApplication class.

One peculiar thing is , my application started and working fine when i push the application to PCF from CLI

Am i missing anything in STS ?

2

2 Answers

0
votes

Cloud Foundry Tools (CFT) plugin has some known issues with packaging Spring Boot jar applications, which are currently being fixed for upcoming CFT releases.

That said, in some cases, refreshing the Spring Boot project (typically F5) from the Eclipse Package Explorer, as well as performing a Maven -> Update Project from the Package Explorer context menu, prior to deploying the application, may solve the NoClassDefFoundError problem.

However, an alternative to using CFT for Spring Boot deployment to Cloud Foundry is the Spring Boot Dashboard view, which has better support for packaging Spring Boot applications.

It is available in Spring Tool Suite (STS) 3.7.1 or higher.

You can create a PCF target in the Boot Dashboard view and simply drag and drop your Spring Boot project to deploy it.

Here is a tutorial for the Spring Boot Dashboard:

https://spring.io/blog/2015/10/15/the-spring-boot-dashboard-in-sts-part-2-working-with-cloud-foundry

You can find the latest STS distribution builds that contain the Spring Boot Dashboard view here:

http://dist.springsource.com/snapshot/STS/nightly-distributions.html

0
votes

Its possible you did what i just did and forget to add execution and configuration step in packaging Plugin.

this will package you application as an executable jar

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>${spring.boot.version}</version>
    <executions>
        <execution>
            <id>repackage</id>
            <goals>
                <goal>repackage</goal>
            </goals>
            <configuration>
                <executable>true</executable>
            </configuration>
        </execution>
    </executions>
</plugin>