2

I´m trying to deploy a Spring boot application on Jboss. I follow this tutorial for convert my jar in to a war file. But when i try to run the application on Jboss it´s give me this error:

17:02:31,462 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/ldap-service-1.0-SNAPSHOT]] (MSC service thread 1-2) Exception starting filter applicationContextIdFilter: java.lang.InstantiationException: org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextFilterConfiguration$1
    at java.lang.Class.newInstance(Class.java:359) [rt.jar:1.7.0_51]
    at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:80) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:72) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:441) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3865) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
    at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
17:02:31,472 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/ldap-service-1.0-SNAPSHOT]] (MSC service thread 1-2) Exception starting filter webRequestLoggingFilter: java.lang.InstantiationException: org.springframework.boot.actuate.trace.WebRequestTraceFilter
    at java.lang.Class.newInstance(Class.java:359) [rt.jar:1.7.0_51]
    at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:80) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:72) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:441) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3865) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
    at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
17:02:31,480 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/ldap-service-1.0-SNAPSHOT]] (MSC service thread 1-2) Exception starting filter authenticationFilter: java.lang.InstantiationException: br.gov.rs.defensoria.ldap.service.authentication.AuthenticationFilter
    at java.lang.Class.newInstance(Class.java:359) [rt.jar:1.7.0_51]
    at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:80) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:72) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:441) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3865) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
    at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
17:02:31,484 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/ldap-service-1.0-SNAPSHOT]] (MSC service thread 1-2) Exception starting filter errorPageFilter: java.lang.IllegalAccessException: Class org.jboss.as.web.deployment.WebInjectionContainer can not access a member of class org.springframework.boot.context.web.ErrorPageFilter with modifiers ""
    at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:109) [rt.jar:1.7.0_51]
    at java.lang.Class.newInstance(Class.java:368) [rt.jar:1.7.0_51]
    at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:80) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:72) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:441) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3865) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
    at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
17:02:31,493 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/ldap-service-1.0-SNAPSHOT]] (MSC service thread 1-2) Exception starting filter metricFilter: java.lang.InstantiationException: org.springframework.boot.actuate.autoconfigure.MetricFilterAutoConfiguration$MetricsFilter
    at java.lang.Class.newInstance(Class.java:359) [rt.jar:1.7.0_51]
    at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:80) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:72) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:441) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3865) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
    at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
17:02:31,505 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-2) Error filterStart
17:02:31,505 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-2) Context [/ldap-service-1.0-SNAPSHOT] startup failed due to previous errors
17:02:31,510 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/ldap-service-1.0-SNAPSHOT]] (MSC service thread 1-2) Closing Spring root WebApplicationContext
17:02:31,511 INFO  [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] (MSC service thread 1-2) Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2222014c: startup date [Thu Apr 24 17:02:23 BRT 2014]; root of context hierarchy
17:02:31,514 INFO  [org.springframework.context.support.DefaultLifecycleProcessor] (MSC service thread 1-2) Stopping beans in phase 0
17:02:31,523 INFO  [org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter] (MSC service thread 1-2) Unregistering JMX-exposed beans on shutdown
17:02:31,529 INFO  [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] (MSC service thread 1-2) Closing JPA EntityManagerFactory for persistence unit 'default'
17:02:31,554 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.web.deployment.default-host."/ldap-service-1.0-SNAPSHOT": org.jboss.msc.service.StartException in service jboss.web.deployment.default-host."/ldap-service-1.0-SNAPSHOT": JBAS018040: Failed to start context
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:95)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
    at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
17:02:31,774 INFO  [org.jboss.as.server] (HttpManagementService-threads - 1) JBAS015870: Deploy of deployment "ldap-service-1.0-SNAPSHOT.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host.\"/ldap-service-1.0-SNAPSHOT\"" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host.\"/ldap-service-1.0-SNAPSHOT\": JBAS018040: Failed to start context"}}
17:02:31,850 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment ldap-service-1.0-SNAPSHOT.war in 83ms
17:02:31,852 INFO  [org.jboss.as.controller] (HttpManagementService-threads - 1) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.web.deployment.default-host."/ldap-service-1.0-SNAPSHOT": org.jboss.msc.service.StartException in service jboss.web.deployment.default-host."/ldap-service-1.0-SNAPSHOT": JBAS018040: Failed to start context

My app Spring config file

package myapp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Application extends SpringBootServletInitializer {
    private static Class<Application> applicationClass = Application.class;

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

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

And here is my pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>myapp</groupId>
<artifactId>myapp</artifactId>
<version>1.0-SNAPSHOT</version>

<packaging>war</packaging>
<name>myapp</name>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.0.2.RELEASE</version>
</parent>

<dependencies>
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>
    <!-- tag::jetty[] -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
        <version>1.5.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>4.0.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>test</scope>
    </dependency>
    <!-- end::jetty[] -->
    <!-- tag::actuator[] -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <!-- end::actuator[] -->
    <dependency>
        <groupId>org.springframework.ldap</groupId>
        <artifactId>spring-ldap-core</artifactId>
        <version>2.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.ldap</groupId>
        <artifactId>spring-ldap-core-tiger</artifactId>
        <version>2.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>16.0.1</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.8.7</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>1.3</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.8.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>4.0.2.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>sqljdbc4</artifactId>
        <version>4.0</version>
        <scope>runtime</scope>
    </dependency>
</dependencies>

<properties>
    <start-class>myapp.Application</start-class>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.7</java.version>
</properties>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
        </plugin>
        <plugin>
            <groupId>com.googlecode.flyway</groupId>
            <artifactId>flyway-maven-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
                <url>jdbc:sqlserver://dpepoaap02\SQLEXPRESS;Databasename=dev_db_ldap_service</url>
                <user>user_dev</user>
                <password>dpe123</password>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>http://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>http://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>localRepo</id>
        <url>file://M://</url>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>http://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>http://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

Some idea? Thanks!

Matheus Alagia
  • 173
  • 2
  • 2
  • 9
  • Two things occur to me: 1. you have a non-"provided" dependency on Servlet 2.5 (so it will be on your classpath at runtime, and seriously crazy things could happen), 2. Spring LDAP has some unusual transitive dependencies. Can you try an app that doesn't use either of those and see if it works (even if you need LDAP it will tell you something about the problem)? JBoss is an abortion in recent versions so I can't recommend you try a different version, but you could try a different container (e.g. Tomcat) - again, even if it isn't what you need it will tell you something if it works (or not). – Dave Syer Apr 24 '14 at 21:02
  • I will try in Tomcat. Spring LDAP is very important – Matheus Alagia Apr 25 '14 at 02:09
  • continue... in this project, remove it is a good idea for test, but i don't want remove it from the project. Thank you @DaveSyer ! – Matheus Alagia Apr 25 '14 at 02:27
  • So, did you try it in Tomcat, or without LDAP? What happens? – Dave Syer Apr 27 '14 at 16:04
  • 1 - In Jboss: I changed the scope of Servlet 2.5 dependency to scoped and the same error happens. – Matheus Alagia Apr 28 '14 at 13:41
  • 2 - In Tomcat: I changed the scope of Servlet 2.5 dependency to scoped and the application start up. But when i try to access any endpoint a stackoverflow exception happens. After some debug i have removed a filter, and everything works. I don't know whats is wrong with my filter. – Matheus Alagia Apr 28 '14 at 13:49
  • In Jboss, even removing the filter the same initial error happens. – Matheus Alagia Apr 28 '14 at 13:54
  • 1
    I found the problem. It´s in spring-boot-starter-actuator dependency. I remove it from the pom.xml, solve the problem described in http://stackoverflow.com/questions/22365365/spring-boot-war-fails-to-deploy-properly-on-resin-server and so everything works in JBoss, including my custom filter. You know why actuator cause this problem? – Matheus Alagia Apr 28 '14 at 17:28
  • I don't know precisely, but maybe it's an old Servlet spec version? You'd have to be a bit more specific (maybe a new question?). – Dave Syer Apr 29 '14 at 08:02

2 Answers2

7

The main issue with deploying spring-boot is explained here

The post is a bit old by now and does not apply to the current spring-boot (1.3.3 as of this writing).

What is happening in your case is that some filter in spring-boot actuator do not have default constructors which JBoss will try to call so to get around this you need to do the following (This is for current spring-boot 1.3.3):

Create an ApplicationContext which will wrap all bean filters in a delegating class which has a default constructor. We can use spring's DelegatingFilterProxy for that

public class JBossWebApplicationContext extends AnnotationConfigEmbeddedWebApplicationContext {

private final Logger log = LoggerFactory.getLogger(getClass());

@Override
protected Collection<ServletContextInitializer> getServletContextInitializerBeans() {
    Collection<ServletContextInitializer> servletContextInitializerBeans = super.getServletContextInitializerBeans();
    for (ServletContextInitializer servletContextInitializerBean : servletContextInitializerBeans) {
        if (servletContextInitializerBean instanceof FilterRegistrationBean) {
            FilterRegistrationBean frb = (FilterRegistrationBean) servletContextInitializerBean;
            try {
                Field field = FilterRegistrationBean.class.getDeclaredField("filter");
                field.setAccessible(true);
                Filter origFilter = (Filter) field.get(frb);
                frb.setFilter(new DelegatingFilterProxy(origFilter));
            } catch (NoSuchFieldException | IllegalAccessException e) {
                throw new BeanCreationException("Error setting up bean. It does not have a filter field", e);
            }

        }
    }

    return servletContextInitializerBeans;
}
}

Then in your springboot main class make sure to use the context we created above:

@SpringBootApplication
public class MyApplication extends SpringBootServletInitializer {

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    application.sources(MyApplication.class);
    application.contextClass(JBossWebApplicationContext.class);
    return super.configure(application);
}

public static void main(String[] args) throws Exception {
    SpringApplication app = new SpringApplication(MyApplication.class);
    app.setApplicationContextClass(JBossWebApplicationContext.class);
    app.run(args);
}
}

Lastly you need to make sure your servlet path is configured to be "/*" since JBoss 7.1 does not seem to work with only the default (/). This can be configured in your application.yml (or application.properties)

server:
  servletPath: /*

This should allow you to deploy a springBoot application in JBoss 7.1 (Tested myself on 7.1.3)

Some extra points:

  • I have NOT tested this extensively and therefore you should make sure things are behaving as they should be before relying on this solution
  • I really don't like having to call reflection to get the FRB underlying filter but unfortunately the getFilter method is protected
  • This solution can probably be improved upon by someone who is more versed into spring than I am
Alexandre Thenorio
  • 2,288
  • 3
  • 31
  • 50
3

spring-boot on compile generate two files(.war).

myapp-0.0.1-SNAPSHOT
myapp-0.0.1-SNAPSHOT.war.original

If you wan to deploy to JBoss 7.1 you need to rename myapp-0.0.1-SNAPSHOT.war.original to e.g myapp-0.0.1.war(remove .original extension) and deploy to server.

abosancic
  • 1,776
  • 1
  • 15
  • 21