Springboot application on Jboss EAP, servlet context not lodaed

I have a very simple spring boot application that I want to deploy to Jboss EAP. Here is my simple application class:

@SpringBootApplication public class MayurApplication extends SpringBootServletInitializer{ public static void main(String[] args) { SpringApplication.run(MayurApplication.class, args); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(applicationClass); } private static Class<MayurApplication> applicationClass = MayurApplication.class; } @RestController class GreetingController { @RequestMapping("/hello/{name}") String hello(@PathVariable String name) { return "Hello, " + name + "!"; } } 

and my pom.xml is also very simple. When I run this application on Tomcat using the built-in Tomcat that comes with spring boot. Everything works like a charm in just one click. I can access http://localhost:8080/demo/hello/World , and it works too.

Now I tried to make JBoss EAP a compatible war, I disabled Tomcat, excluding spring-boot-starter-web from spring and turning it into a military project. (as suggested in the article http://spring.io/blog/2014/03/07/deploying-spring-boot-applications ).

I also added:

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

as he complained.

Now, after all this, it compiles perfectly and creates a war. When I copied this war to jboss deployment, I see that it has been successfully deployed to the console. But the rest of the api http://localhost:8080/demo/hello/World just does not work and constantly causes an error in the browser:

 JBWEB000068: message /demo/hello/World JBWEB000069: description JBWEB000124: The requested resource is not available. 

What am I doing wrong?

+6
source share
3 answers

The answer is here: Spring Java Config vs Jboss 7

Apparently, "/" does not work on Jboss EAP 6.3, but "/ *" works. and they seem to have fixed it with a wild butterfly 8

+6
source

Found this in the Spring Download Reference , add the following line to the application.properties file

 server.servlet-path=/* 

checked this in jBoss EAP 6.2 and worked fine.

+15
source

You mentioned JBoss 6 in your tags. Based on my experience with Spring Boot Autoconfigure , and JBoss 6 (in particular) is non-go. If Hot Deploy is turned on, or perhaps some other condition, JBoss VFS performs an aggressive scan of all cans in the war file. When it starts scanning classes in the autoconfiguration module, it will be interrupted due to an error similar to a ClassNotFoundException. If you use Autoconfigure, one solution might be to place Spring modules in the Container library. But that would make deployment cumbersome. I have not seen this behavior on JBoss 7 or Wildfly 8.

+2
source

Source: https://habr.com/ru/post/979967/


All Articles