0 Replies Latest reply on Jul 26, 2018 10:32 AM by Estevao Jordao

    Jboss EAP 7.1 not load Spring Boot Context/Application When package as EAR

    Estevao Jordao Newbie

      I'm having a hard time, I'm not able to generate an EAR using Maven with Spring boot in my POC project.

      When deploying in JBoss 7.1 EAP, jboss does not load the context/application of spring, but also does not appear any error, could you help me, by kindly already tried in several ways.

      When I perform the deploy of WAR, everything works perfectly, the problem is in the packaging of my EAR I think.

      Main pom.xml

       

      <?xml version="1.0" encoding="UTF-8"?>
      <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/xsd/maven-4.0.0.xsd">
      
      
         <modelVersion>4.0.0</modelVersion>
         <groupId>br.com.me.security</groupId>
         <artifactId>security</artifactId>
         <version>0.0.1-SNAPSHOT</version>
         <packaging>pom</packaging>
         <name>security</name>
         <description>Aplicação para gerenciamento de segurança</description>
      
      
         <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <version>1.5.14.RELEASE</version>
         <relativePath/> <!-- lookup parent from repository -->
         </parent>
      
      
         <modules>
         <module>security-commons</module>
         <module>security-services</module>
         <module>security-ear</module>
         </modules>
      
      
         <properties>
         <security.version>0.0.1-SNAPSHOT</security.version>
         <version.ear.plugin>2.6</version.ear.plugin>
         <version.war.plugin>2.6</version.war.plugin>
      
      
         <swagger.version>2.6.1</swagger.version>
      
      
         <java-version>1.8</java-version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      
      
         <maven.compiler.target>1.8</maven.compiler.target>
         <maven.compiler.source>1.8</maven.compiler.source>
         </properties>
      
      
      
      
         <dependencyManagement>
         <dependencies>
         <dependency>
         <groupId>br.com.me.security</groupId>
         <artifactId>security-commons</artifactId>
         <version>${security.version}</version>
         <type>jar</type>
         <!-- <type>ejb</type> -->
         <scope>compile</scope> 
         </dependency>
      
      
         <dependency>
         <groupId>br.com.me.security</groupId>
         <artifactId>security-services</artifactId>
         <version>${security.version}</version>
         <type>war</type>
         </dependency>
      
      
         <!-- swagger -->
         <dependency>
         <groupId>io.springfox</groupId>
         <artifactId>springfox-swagger-ui</artifactId>
         <version>${swagger.version}</version>
         </dependency>
      
      
         <dependency>
         <groupId>io.springfox</groupId>
         <artifactId>springfox-swagger2</artifactId>
         <version>${swagger.version}</version>
         </dependency>
      
      
         <dependency>
         <groupId>io.swagger</groupId>
         <artifactId>swagger-core</artifactId>
         <version>1.5.10</version>
         </dependency>
      
      
         </dependencies>
         </dependencyManagement>
      
      
         <build>
         <plugins>
         <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-release-plugin</artifactId>
         <version>2.5.3</version>
         </plugin>
         </plugins>
         </build>
      
      
         <repositories>
         <repository>
         <id>spring-snapshots</id>
         <name>Spring Snapshots</name>
         <url>https://repo.spring.io/snapshot</url>
         <snapshots>
         <enabled>true</enabled>
         </snapshots>
         </repository>
         <repository>
         <id>spring-milestones</id>
         <name>Spring Milestones</name>
         <url>https://repo.spring.io/milestone</url>
         <snapshots>
         <enabled>false</enabled>
         </snapshots>
         </repository>
         </repositories>
      
      
         <pluginRepositories>
         <pluginRepository>
         <id>spring-snapshots</id>
         <name>Spring Snapshots</name>
         <url>https://repo.spring.io/snapshot</url>
         <snapshots>
         <enabled>true</enabled>
         </snapshots>
         </pluginRepository>
         <pluginRepository>
         <id>spring-milestones</id>
         <name>Spring Milestones</name>
         <url>https://repo.spring.io/milestone</url>
         <snapshots>
         <enabled>false</enabled>
         </snapshots>
         </pluginRepository>
         </pluginRepositories>
      
      
      </project>
      

       

       

      WAR 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/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
      
      
          <artifactId>security-services</artifactId>
          <packaging>war</packaging>
      
      
          <name>security-services</name>
      
      
          <parent>
              <groupId>br.com.me.security</groupId>
              <artifactId>security</artifactId>
              <version>0.0.1-SNAPSHOT</version>
          </parent>
      
      
          <dependencies>
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-web</artifactId>
              </dependency>
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-tomcat</artifactId>
                  <scope>provided</scope>
              </dependency>
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-devtools</artifactId>
              </dependency>
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-hateoas</artifactId>
              </dependency>
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-data-rest</artifactId>
              </dependency>
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-security</artifactId>
              </dependency>
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-test</artifactId>
              </dependency>
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-actuator</artifactId>
              </dependency>
      
      
              <dependency>
                  <groupId>br.com.me.security</groupId>
                  <artifactId>security-commons</artifactId>
                  <version>${security.version}</version>
              </dependency>
      
      
              <!-- swagger -->
      
      
              <dependency>
                  <groupId>io.springfox</groupId>
                  <artifactId>springfox-swagger2</artifactId>
              </dependency>
      
      
              <dependency>
                  <groupId>io.springfox</groupId>
                  <artifactId>springfox-swagger-ui</artifactId>
              </dependency>
      
      
              <dependency>
                  <groupId>io.swagger</groupId>
                  <artifactId>swagger-core</artifactId>
              </dependency>
          </dependencies>
      
      
          <properties>
              <start-class>br.com.me.security.SecurityApplication</start-class>
          </properties>
      
      
          <build>
              <finalName>${project.artifactId}</finalName>
              <plugins>
                  <plugin>
                      <groupId>org.springframework.boot</groupId>
                      <artifactId>spring-boot-maven-plugin</artifactId>
                      <!-- <version>${spring.boot.version}</version> -->
                      <executions>
                          <execution>
                              <goals>
                                  <goal>repackage</goal>
                              </goals>
                          </execution>
                      </executions>
                  </plugin>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-war-plugin</artifactId>
                      <!-- <version>2.6</version> -->
                      <configuration>
                          <failOnMissingWebXml>false</failOnMissingWebXml>
                      </configuration>
                  </plugin>
              </plugins>
          </build>
      </project>
      

       

       

      EAR 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/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
          <parent>
              <groupId>br.com.me.security</groupId>
              <artifactId>security</artifactId>
              <version>0.0.1-SNAPSHOT</version>
          </parent>
          <artifactId>security-ear</artifactId>
          <name>security-ear</name>
          <packaging>ear</packaging>
          <dependencies>
              <dependency>
                  <groupId>br.com.me.security</groupId>
                  <artifactId>security-services</artifactId>
                  <type>war</type>
              </dependency>
              <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>
          </dependencies>
          <build>
              <finalName>${project.artifactId}</finalName>
              <plugins>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-ear-plugin</artifactId>
                      <version>${version.ear.plugin}</version>
                      <configuration>
                          <version>6</version>
                          <defaultLibBundleDir>lib</defaultLibBundleDir>
                          <modules>
                              <webModule>
                                  <groupId>br.com.me.security</groupId>
                                  <artifactId>security-services</artifactId>
                                  <bundleFileName>security-services.war</bundleFileName>
                                  <contextRoot>/security</contextRoot>
                              </webModule>
                          </modules>
                          <fileNameMapping>no-version</fileNameMapping>
                      </configuration>
                  </plugin>
              </plugins>
          </build>
      </project>
      

       

       

      Deployment content:

       

      C:.
      └───security-ear.ear
          ├───lib
          ├───META-INF
          │   └───maven
          │       └───br.com.me.security
          │           └───security-ear
          └───security-services.war
              ├───br
              │   └───com
              │       └───me
              │           └───security
              │               ├───infra
              │               │   └───config
              │               └───web
              ├───META-INF
              │   └───maven
              │       └───br.com.me.security
              │           └───security-services
              └───WEB-INF
                  └───lib
                      └───security-commons-0.0.1-SNAPSHOT.jar
                          └───META-INF
                              └───maven
                                  └───br.com.me.security
                                      └───security-commons
      

       

       

      My application class:

       

      //@PropertySources({ @PropertySource("classpath:application.properties")})
      /*@Configuration
      @ComponentScan(basePackages="br.com.me.security")
      @EnableAutoConfiguration*/
      @SpringBootApplication
      public class SecurityApplication extends SpringBootServletInitializer implements CommandLineRunner {
      
      
      
      
          private static final Class<SecurityApplication> applicationClass = SecurityApplication.class;
      
      
      
      
          @Override
          protected SpringApplicationBuilder configure(final SpringApplicationBuilder app) {
              System.out.println("Up here test");
              return app.sources(SecurityApplication.class);
          }
      
      
          public static void main(final String[] args) {
              SpringApplication.run(SecurityApplication.class, args);
          }
      
      
          @Override
          public void run(String... args) throws Exception {
      
      
      
      
          }
      
      
      /*  @Override
          public void onStartup(ServletContext container) throws ServletException {
              AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
              ServletRegistration.Dynamic registration = container.addServlet("dispatcher", new DispatcherServlet(context));
              registration.setLoadOnStartup(1);
              registration.addMapping("/*"); // required JBOSS EAP 6 / AS 7
              super.onStartup(container);
          }*/
      }
      

       

       

      File jboss-web.xml

       

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

       

      File jboss-deployment-structure.xml

       

      <jboss-deployment-structure>
          <deployment>
              <!-- Exclusions allow you to prevent the server from automatically adding some dependencies     -->
              <exclusions>
                  <module name="org.slf4j" />
                  <module name="org.slf4j.impl" />
              </exclusions>
          </deployment>
      </jboss-deployment-structure>
      

       

      Thank you for your time and attention!!