3

I created a Spring Boot application, then I created a war.

On my local server the app works correctly.

I added this app to a JBOSSEWS cartridge by renaming it ROOT.war, putting it in the webapps directory using git and restarting the server.

But I always have a 404 not found.

The tomcat logs are :

new-host-3:jbossews JARVIS$ rhc tail jbossews
Aug 30, 2014 3:27:25 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.54
Aug 30, 2014 3:27:25 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/openshift/540178a84382ec94b8000b75/app-        root/runtime/dependencies/jbossews/webapps/ROOT.war
Aug 30, 2014 3:27:37 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /var/lib/openshift/540178a84382ec94b8000b75/app-root/runtime/dependencies/jbossews/webapps/ROOT.war has finished in 11,864 ms
Aug 30, 2014 3:27:37 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-127.10.90.1-8080"]
Aug 30, 2014 3:27:37 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 12059 ms
Florian Courtial
  • 930
  • 1
  • 11
  • 20

4 Answers4

2

Make sure that your main class Application extends SpringBootServletInitializer

Initialize the servlet

By converting this into a WAR file with no XML files, you need a different signal to the servlet container on how to launch the application.

import org.springframework.boot.context.web.SpringBootServletInitializer;

public class HelloWebXml extends SpringBootServletInitializer {

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

}

HelloWebXml is a pure Java class that provides an alternative to creating a web.xml. It extends the SpringServletInitializer class. This extension offers many configurable options by overriding methods.

Source: Spring.io Guide

Community
  • 1
  • 1
0

Make sure that you removed the pom.xml file and the src/ directory, so that it will deploy your ROOT.war file when you do a git push. You can check out this kb article for further information: https://help.openshift.com/hc/en-us/articles/202399740-How-to-deploy-pre-compiled-java-applications-WAR-and-EAR-files-onto-your-OpenShift-gear-using-the-java-cartridges

  • I used this post to put my war on OpenShift, I well removed the pom.xml and src dir. I tried with tomcat and jboss, the problem is the same. – Florian Courtial Sep 03 '14 at 05:58
  • Do you have your code posted somewhere publicly? Does the spring boot application work on your local development server? –  Sep 03 '14 at 12:58
  • No the code is not public (no interest), it is a very simple spring boot project to test spring boot on Openshift. Firstly I made this [project](http://spring.io/guides/gs/serving-web-content/) and I converted the jar to a war using this [guide](http://spring.io/guides/gs/convert-jar-to-war/) and finally I put the war on OpenShift using this [tuto](https://help.openshift.com/hc/en-us/articles/202399740-How-to-deploy-pre-compiled-java-applications-WAR-and-EAR-files-onto-your-OpenShift-gear-using-the-java-cartridges) from OpenShift. Locally the .war works very well. – Florian Courtial Sep 03 '14 at 15:27
0

I had the same problem and was able to solve it by copying the .openshift directory from the original git-repo into the repo folder of the tar.gz. So afterwards my directory structure looked something like this:

myApp.tar.gz - dependencies - - jbossews - - - - webapps - - - - - ROOT.war - repo - - .openshift - - - - markers - - - - - java7 ...

I think the problem in my case was, that tomcat tried to deploy the application with JDK 1.6, as this seems to be the fallback, when there is no java7 file in the markers directory...

0

There are reasons:

  1. Check you don't use Java 8 if so turn it to Java 7 or DIY. When you using Java 8 container will not deploy war (tested myself).
  2. Use SpringBootServletInitializer as @Jakub said.
Community
  • 1
  • 1
njjnex
  • 1,490
  • 13
  • 23