1

I am using Spring Tool Suite Version: 3.7.0.RELEASE to deploy a spring boot project using tc server which works fine but fails on JBoss EAP 6.1+. I get a JBWEB000065: HTTP Status 404 - /shell/

ShellApplication.java

@SpringBootApplication
@ComponentScan("shell")
public class ShellApplication extends SpringBootServletInitializer {

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

public static void main(String[] args) {
      SpringApplication.run(ShellApplication.class, args);
}      
}

src/main/webapp/WEB-INF/jboss-web.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <context-root>/</context-root>
</jboss-web>

Console log

13:41:36,460 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "shell.war" (runtime-name: "shell.war")
13:42:15,089 INFO  [org.jboss.web] (ServerService Thread Pool -- 53) JBAS018210: Register web context: /shell
13:42:17,332 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "shell.war" (runtime-name : "shell.war")

Browser

JBWEB000065: HTTP Status 404 - /shell/

--------------------------------------------------------------------------------

JBWEB000309: type JBWEB000067: Status report

JBWEB000068: message /shell/

JBWEB000069: description JBWEB000124: The requested resource is not available.
Michael Petch
  • 46,082
  • 8
  • 107
  • 198
  • You deploy at `/` not `/shell`.... – M. Deinum Sep 30 '15 at 17:54
  • I tried both, but neither works, same result. – edward saab Sep 30 '15 at 18:15
  • Check your logs and see if it deploys, there must be some info. Is JBoss EAP 6 a servlet 3 container (I don't really keep track of JBoss). – M. Deinum Sep 30 '15 at 18:16
  • Yes it does get deployed with .deployed extension. I verified EAP 6 is using servlet 3.0 https://access.redhat.com/articles/113373. – edward saab Sep 30 '15 at 18:38
  • What is your server log telling you... Or the application log. If it is deployed there should something in your logging. Also why deploy why not simply create a standalone jar and run that.. – M. Deinum Sep 30 '15 at 18:47
  • Don't add logs, code, xml etc. as comments, edit your question. – M. Deinum Sep 30 '15 at 18:48
  • I tried the jar route as well, but it seems the trouble is the annotation based approach of Spring Boot which may not reconcile with JBoss' XML descriptor based approach. – edward saab Sep 30 '15 at 18:55
  • if JBoss is a full servlet 3 container it should support the java based approach else it isn't a servlet 3 container. Also a jar you don't deploy to jboss you simply do `java -jar shell.jar` and nothing more no more deployments that is all. – M. Deinum Sep 30 '15 at 19:00

2 Answers2

0

I met exactly same problem and finally found a solution.
Try the following steps:

1. In pom.xml:

<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>javax.servlet-api</artifactId>
   <scope>provided</scope>
</dependency>

2. Add a class implements WebApplicationInitializer:

@Configuration
public class WebApplicationInitializerImpl implements WebApplicationInitializer{

    @Override 
    public void onStartup(ServletContext container) throws ServletException {
        WebApplicationContext context = getContext();

        Dynamic registration = container.addServlet("dispatcher", new DispatcherServlet(context));
        registration.setLoadOnStartup(1);
        registration.addMapping("/*");
    } 

    private WebApplicationContext getContext() { 
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        context.setConfigLocation(ApplicationMain.class.getName());
        return context;
    } 

}

3. Remember to extend SpringBootServletInitializer by your application:

@SpringBootApplication
public class ApplicationMain extends SpringBootServletInitializer{

   @Override
   protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
      return builder.sources(ApplicationMain.class);
   }

   public static void main(String[] args) {
      SpringApplication.run(ApplicationMain.class, args);
   }
}

For more explanation I've answered in another question: Spring boot war not working on EAP 6
Hope it helps.

kinolollipop
  • 141
  • 1
  • 9
0

I had the same problem on JBoss EAP 6.4 / spring boot 1.5 and what fixed it was to add this property to application.properties

server.servlet-path=/*

as explained in this post : Deploying spring boot on JBOSS EAP 6.1

ascripter
  • 5,665
  • 12
  • 45
  • 68
Sebastien
  • 791
  • 5
  • 6