GUJ Discussões   :   últimos tópicos   |   categorias   |   GUJ Respostas

Spring Boot Admin no JBoss EAP 7.1

spring
jboss
java
Tags: #<Tag:0x00007fdbdfa56258> #<Tag:0x00007fdbdfa56118> #<Tag:0x00007fdbdfa55ee8>

#1

Olá, tudo bem?

Alguém sabe me dizer se o Spring Boot Admin na versão 2.1.1 funciona se as aplicações (server e client) estiverem em um servidor JBoss. Digo isso porque testei ambas as aplicações no Tomcat (servidor embutido do Spring Boot) e funcionou, porém quando coloquei as aplicações em um servidor externo (JBoss EAP 7.1) parou de funcionar e me retornou a seguinte exceção ao tentar o deploy através do Maven:

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:16 min
[INFO] Finished at: 2019-01-04T09:52:43-02:00
[INFO] Final Memory: 43M/400M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.2.2.Final:deploy (default-cli) on project prjSgeBackend: Failed to execute goal deploy: {“WFLYCTL0062: A operação de composição falhou e foi revertida. Segue abaixo as etapas que falharam:” => {“Operação step-1” => {“WFLYCTL0080: Falha de serviços” => {“jboss.undertow.deployment.default-server.default-host./prj-sge-backend” => “java.lang.RuntimeException: java.lang.IllegalStateException: Error processing condition on de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration.registrator
[ERROR] Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: Error processing condition on de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration.registrator
[ERROR] Caused by: java.lang.IllegalStateException: Error processing condition on de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration.registrator
[ERROR] Caused by: java.lang.IllegalStateException: Failed to introspect Class [de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration$ServletConfiguration] from ClassLoader [ModuleClassLoader for Module “deployment.prj-sge-backend.war” from Service Module Loader]
[ERROR] Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/autoconfigure/web/servlet/DispatcherServletPath
[ERROR] Caused by: java.lang.ClassNotFoundException: org.springframework.boot.autoconfigure.web.servlet.DispatcherServletPath from [Module “deployment.prj-sge-backend.war” from Service Module Loader]”}}}}
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException


#2

Boa tarde amigo

Funciona, eu estou utilizando o wildfly 3.0.6 Final, mas o problema que você encontrou é sobre configuração do springboot, você precisa fazer configuração manual do servlet, caso contrário não funcionara, como eu estava sem tempo não terminei de ler sobre o assunto e mudei para o wildfly que funciona com o autoconfigure.

Caso queira tentar fazer configuração, bora lá…é só postar.


#3

Posta seu pom.xml e a classe com o main que fica mais fácil de ajudar.

O DispatcherServletPath foi adicionado ao Spring Boot 2.0.4, portanto, provavelmente a incompatibilidade de versão é a causa raiz desse problema. Porém a configuração ainda é necessária.


#4

POM do projeto Client

<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.energia</groupId>
	<artifactId>prjSgeBackend</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>

	<name>Projeto SGE Backend</name>
	<url>http://maven.apache.org</url>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.0.3.RELEASE</version>
	</parent>

	<properties>
		<maven.compiler.source>1.8</maven.compiler.source>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven.compiler.target>1.8</maven.compiler.target>
	</properties>

	<dependencies>
		<dependency>
			<groupId>br.com.energia</groupId>
			<artifactId>sgeModel</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>
		<dependency>
			<groupId>org.reactivestreams</groupId>
			<artifactId>reactive-streams</artifactId>
		</dependency>
		<dependency>
			<groupId>org.wildfly.plugins</groupId>
			<artifactId>wildfly-maven-plugin</artifactId>
			<version>1.2.2.Final</version>
		</dependency>
		<dependency>
			<groupId>io.springfox</groupId>
			<artifactId>springfox-swagger2</artifactId>
			<version>2.9.2</version>
		</dependency>
		<dependency>
			<groupId>io.springfox</groupId>
			<artifactId>springfox-swagger-ui</artifactId>
			<version>2.9.2</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
		</dependency>
		<dependency>
			<groupId>oracle</groupId>
			<artifactId>ojdbc6</artifactId>
			<version>11.2.0.3</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-integration</artifactId>
		</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>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-rest-webmvc</artifactId>
		</dependency>
		<dependency>
			<groupId>org.hamcrest</groupId>
			<artifactId>java-hamcrest</artifactId>
			<version>2.0.0.0</version>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>2.9.4</version>
		</dependency>
	</dependencies>

	<build>
		<finalName>prj-sge-backend</finalName>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>

			<plugin>
				<groupId>org.wildfly.plugins</groupId>
				<artifactId>wildfly-maven-plugin</artifactId>
				<version>1.2.2.Final</version>
				<configuration>
					<hostname>${wildfly-hostname}</hostname>
					<port>${wildfly-port}</port>
					<username>${wildfly-username}</username>
					<password>${wildfly-password}</password>
					<artifactItems>
						<artifactItem>
							<groupId>${project.groupId}</groupId>
							<artifactId>${project.artifactId}</artifactId>
							<version>${project.version}</version>
							<type>war</type>
							<overWrite>true</overWrite>
							<outputDirectory>/opt/jboss/wildfly/standalone/deployments</outputDirectory>
							<destFileName>backend.war</destFileName>
						</artifactItem>
					</artifactItems>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>deploy</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>

MAIN do projeto Client

package br.com.energia.prjsgebackend;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

/**
 * Classe inicializadora.
 * 
 * @author Cristian
 * @version 1 09/10/2018
 *
 */
@SpringBootApplication
@EntityScan(basePackages = { "br.com.energia.sge.model" })
public class App extends SpringBootServletInitializer {
	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(App.class);
	}

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

}

#5

Muito obrigado, amigo!


#6

Boa tarde amigo

Acredito com essas mudanças funcionara:

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

   <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-server</artifactId>
        <version>2.0.4</version>
    </dependency>
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-server-ui</artifactId>
        <version>2.0.4</version>
    </dependency>

    @EnableAdminServer
    @SpringBootApplication
    @EntityScan(basePackages = {"br.com.energia.sge.model"})
    public class App extends SpringBootServletInitializer {

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

   }

image

Aqui comigo funcionou normalmente.
Espero que consiga resolver seu problema. :smiley:


#7

Opa.

Esse eh o problema o Spring esta querendo se registrar no ServletContainer, mas como JBoss eh um servidor de aplicação, vc terá que fazer alguns workarounds para funcionar. Agora sinceramente não eh uma boa ideia utilizar Spring com servidores de aplicação, pois a experiência diz que mais cedo ou mais tarde vc terá problemas de compatibilidade e conflito.

\o


#8

Isso foi uma exigência de um cliente de grande porte e pouco flexível. :confused:


#9

Muito obrigado!