WAR containing spring boot app, manual deployment to openshift tomcat not working

I created a Spring Boot Application, then created a War.

On my local server, the app is working correctly.

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

But I always have no 404 found.

Tomcat logs:

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

      

+3


source to share


4 answers


Make sure your main class app extends SpringBootServletInitializer

Initialize servlet

By converting this to a WAR file without XML files, you need another signal to the servlet container on how to start 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 creation web.xml

. It extends the class SpringServletInitializer

. This extension offers many configurable options through method overrides.

Source: Spring.io Guide

+2


source


Make sure you remove the pom.xml file and the src / directory so that it expands your ROOT.war file when you push git. You can check this kb article for more 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



0


source


I had the same problem and was able to solve it by copying the .openshift directory from the original git-repo to the tar.gz repo folder. Therefore, subsequently, the 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 fallback when there is no java7 file in the markers directory ...

0


source


There are reasons:

  • Make sure you are not using Java 8 if you are upgrading to Java 7 or DIY . When you are using Java 8 container will not deploy war (tested it myself).
  • Use SpringBootServletInitializer as @Jakub said.
0


source







All Articles