0
votes

How to deploy "war" file built with spring boot to jetty? I am unable to access restful services of my spring boot application when I deploy the war file to jetty.

Steps I followed:

  1. Referring to Spring boot war documentation I created a war file. I could see the files are available in the war file.
    1. Copied the war to ${jetty home}/webapps. (/usr/share/jetty/webapps)
    2. Added a contexts.xml file with my war name (excluding .war suffix)
    3. Restarted Jetty service

When I browse localhost:8080 I see folder structure of my web app. (i.e WEB-INF resources) None of spring resource paths are available from localhost. My spring application has JAX-RS resource. Below is my ApplicationInitializer class (Groovy).

class ApplicationInitializer extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        Properties props = getPropertiesFromArgs()
        return new SpringApplicationBuilder([Application, "classpath:/META-INF/com/foo/testapp/bootstrap.xml"] as Object[])
            .properties(props)

    }

Its as-if jetty start did not start spring context. What am I missing? Application works fine if I run the spring boot built uber jar. I can access all restful resources of the app.

1

1 Answers

0
votes

Figured out. I was not using Servlet 3.0 compliant jetty version. sudo apt-get install jetty pulled 2.5 compliant version. Once I updated to Jetty 9.x, it worked fine.