Unable to run ZipKin server with spring boot - spring

Zipkin won't launch with spring boot.
When I run the application from the server side (java), it throws this exception (probably a dependency issue, but I can't find it). I have tried many ways to troubleshoot it and have changed the spring versions each time i ran into difficulties.):
It is necessary to start rabbitmq first?
What is the best way to launch zipkin in spring boot?
Why would it be a good idea to run Zipkin with spring boot?
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>zipkin-distributed-tracing-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>zipkin-distributed-tracing-server</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2021.0.3</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-server</artifactId>
<version>2.12.9</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
<version>2.12.9</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Application.java
package com.example.zipkindistributedtracingserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import zipkin2.server.internal.EnableZipkinServer;
#SpringBootApplication
#EnableEurekaClient
#EnableZipkinServer
public class ZipkinDistributedTracingServerApplication {
public static void main(String[] args) {
SpringApplication.run(ZipkinDistributedTracingServerApplication.class, args);
}
}
application.properties
spring.application.name=zipkin-distributed-tracing-server
server.port=9411
eureka.client.service-url.default-zone=http://localhost:8761/eureka
ERROR
2022-06-07 11:37:48.608 WARN 4660 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [zipkin2.server.internal.InternalZipkinConfiguration]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class zipkin2.server.internal.ZipkinServerConfiguration
2022-06-07 11:37:48.612 INFO 4660 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-06-07 11:37:48.628 ERROR 4660 --- [ restartedMain] o.s.b.SpringApplication : Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [zipkin2.server.internal.InternalZipkinConfiguration]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class zipkin2.server.internal.ZipkinServerConfiguration
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:610) ~[spring-context-5.3.20.jar:5.3.20]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:311) ~[spring-context-5.3.20.jar:5.3.20]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:250) ~[spring-context-5.3.20.jar:5.3.20]

Copy the zipkin jar under src/main/resources
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>copy-file</id>
<phase>verify</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>src/main/resources/zipkin-server-2.22.1-exec.jar</sourceFile>
<destinationFile>${project.build.directory}/${project.build.finalName}.jar</destinationFile>
</configuration>
</execution>
</executions>
</plugin>

Related

java: package org.springframework.boot does not exist

I am trying to build a very basic Spring Boot Application. Although I imported SpringApplication and SpringBootApplication, as well as added dependencies spring-boot-starter-data-jpa, spring-boot-starter-parent and spring-boot-starter-web, I get error saying "Cannot resolve symbol 'springframework' ". It seems that IntelliJ IDEA cannot actually import org.springframework libraries.
The pom.xml file looks like this
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.10</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<vaadin.version>23.1.2</vaadin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</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-autoconfigure</artifactId>
<version>2.6.10</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.7.2</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>production</id>
<build>
<plugins>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.version}</version>
<executions>
<execution>
<id>frontend</id>
<phase>compile</phase>
<goals>
<goal>prepare-frontend</goal>
<goal>build-frontend</goal>
</goals>
<configuration>
<productionMode>true</productionMode>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
The application class:
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
The errors I get after running the application class:
java: package org.springframework.boot does not exist
java: package org.springframework.boot.autoconfigure does not exist
java: cannot find symbol
symbol: class SpringBootApplication
java: cannot find symbol
symbol: variable SpringApplication
location: class com.example.demo.DemoApplication
I have auto-import turned on.
What should I do to resolve these errors?

deploy war file in a TOMCAT server and “service.bat” file

I developed a Spring boot app and generated the war file in order to deploy it to a TOMCAT cloud server. However, when I did, it didn’t work. It gave me “HTTP Status 404-not found”. So I tried the same steps on a local TOMCAT server. First, it didn’t work too, but when I uninstalled and installed again the “service.bat” file it works fine (it fixed my problem in local).
But my doubt is, making this same procedure in production may affect other apps and result very risky, because other apps are running. There is an additional configuration in the spring Environment to avoid uninstalling an install service.bat.
I show the main function with extends SpringBootServletInitializer I set up:
package com.example.capacitaciones;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
#SpringBootApplication
public class CapacitacionesApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(CapacitacionesApplication.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(CapacitacionesApplication.class);
}
}
My pom.xml file too
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>capacitaciones</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>capacitaciones</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</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-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.6.3</version>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
<build>
<finalName>capacitaciones</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
</plugin>
</plugins>
</build>
</project>
Also, the errors i got when i used local TOMCAT server (my first try).
The errors is about port 8080 is in use, but when i changed port it passed same with "8082,8089...". Thats why i tried to eliminating "service.bat">
error pic

Logback configuration error detected: RedHat Jboss EAP 7.2

After adding the war generated from spring boot application to the deployments.
I got this error after deploying.
{"WFLYCTL0080: Les services ont échoué" => {"jboss.deployment.unit."administration-0.0.1.war".undertow-deployment" => "java.lang.RuntimeException: java.lang.IllegalStateException: java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.spi.Interpreter#5:71 - RuntimeException in Action for tag [contextListener] java.lang.NullPointerException
ERROR in ch.qos.logback.core.joran.action.PropertyAction - Could not find resource [application-profile_IS_UNDEFINED.properties].
ERROR in ch.qos.logback.core.joran.util.PropertySetter#65d93a4d - Failed to get charset [charset_IS_UNDEFINED] java.nio.charset.UnsupportedCharsetException: charset_IS_UNDEFINED
ERROR in ch.qos.logback.core.joran.util.PropertySetter#b60b639 - Failed to get charset [charset_IS_UNDEFINED] java.nio.charset.UnsupportedCharsetException: charset_IS_UNDEFINED
Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.spi.Interpreter#5:71 - RuntimeException in Action for tag [contextListener] java.lang.NullPointerException
ERROR in ch.qos.logback.core.joran.action.PropertyAction - Could not find resource [application-profile_IS_UNDEFINED.properties].
ERROR in ch.qos.logback.core.joran.util.PropertySetter#65d93a4d - Failed to get charset [charset_IS_UNDEFINED] java.nio.charset.UnsupportedCharsetException: charset_IS_UNDEFINED
ERROR in ch.qos.logback.core.joran.util.PropertySetter#b60b639 - Failed to get charset [charset_IS_UNDEFINED] java.nio.charset.UnsupportedCharsetException: charset_IS_UNDEFINED
Caused by: java.lang.IllegalStateException: java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.spi.Interpreter#5:71 - RuntimeException in Action for tag [contextListener] java.lang.NullPointerException
ERROR in ch.qos.logback.core.joran.action.PropertyAction - Could not find resource [application-profile_IS_UNDEFINED.properties].
ERROR in ch.qos.logback.core.joran.util.PropertySetter#65d93a4d - Failed to get charset [charset_IS_UNDEFINED] java.nio.charset.UnsupportedCharsetException: charset_IS_UNDEFINED
ERROR in ch.qos.logback.core.joran.util.PropertySetter#b60b639 - Failed to get charset [charset_IS_UNDEFINED] java.nio.charset.UnsupportedCharsetException: charset_IS_UNDEFINED
Caused by: java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.spi.Interpreter#5:71 - RuntimeException in Action for tag [contextListener] java.lang.NullPointerException
ERROR in ch.qos.logback.core.joran.action.PropertyAction - Could not find resource [application-profile_IS_UNDEFINED.properties].
ERROR in ch.qos.logback.core.joran.util.PropertySetter#65d93a4d - Failed to get charset [charset_IS_UNDEFINED] java.nio.charset.UnsupportedCharsetException: charset_IS_UNDEFINED
ERROR in ch.qos.logback.core.joran.util.PropertySetter#b60b639 - Failed to get charset [charset_IS_UNDEFINED] java.nio.charset.UnsupportedCharsetException: charset_IS_UNDEFINED"}}
pom.xml for the module:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.gti.sbe</groupId>
<artifactId>administration</artifactId>
<version>0.0.1</version>
<packaging>war</packaging>
<name>Administration</name>
<description>Administration</description>
<parent>
<groupId>com.gti</groupId>
<artifactId>sbe</artifactId>
<version>1.0.0</version>
<relativePath>..</relativePath>
</parent>
<properties>
<gti.shared>1.0.0</gti.shared>
</properties>
<dependencies>
<dependency>
<groupId>com.gti</groupId>
<artifactId>shared</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
<version>${gti.shared}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.gti.administration.Application</mainClass>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
pom.xml for the whole app:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.gti</groupId>
<artifactId>sbe</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>SBE</name>
<description>Refonte SBE</description>
<modules>
<module>Administration</module>
<module>Shared</module>
<module>TransfertVirement</module>
<module>interfacage</module>
<module>Domiciliation</module>
<module>Divers</module>
</modules>
<properties>
<arg-resolver.version>2.6.2</arg-resolver.version>
<hibernate-52.version>2.12.1</hibernate-52.version>
<java.version>11</java.version>
<jwt.version>3.18.2</jwt.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<modelmapper.version>2.4.4</modelmapper.version>
<spring.boot.version>2.5.5</spring.boot.version>
<spring.oracle.version>1.2.1.RELEASE</spring.oracle.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<scope>import</scope>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<!-- Logback -->
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- Mapper -->
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>${modelmapper.version}</version>
</dependency>
<!-- Spring Boot: AOP -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!-- Spring Boot: Data -->
<!--
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>`enter code here`
<artifactId>spring-data-oracle</artifactId>
<version>${spring.oracle.version}</version>
</dependency>
<dependency>
<groupId>com.vladmihalcea</groupId>
<artifactId>hibernate-types-52</artifactId>
<version>${hibernate-52.version}</version>
</dependency>
<!-- Specification Arg Resolver -->
<dependency>
<groupId>net.kaczmarzyk</groupId>
<artifactId>specification-arg-resolver</artifactId>
<version>${arg-resolver.version}</version>
</dependency>
<!-- Spring Boot: Security-->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>${jwt.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- Spring Boot: Tests -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Spring Boot: Tools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- Spring Boot: Web -->
<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-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<profiles>
<profile>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<id>development</id>
<properties>
<activatedProperties>development</activatedProperties>
</properties>
</profile>
<profile>
<id>production</id>
<properties>
<activatedProperties>production</activatedProperties>
</properties>
</profile>
<profile>
<id>staging</id>
<properties>
<activatedProperties>staging</activatedProperties>
</properties>
</profile>
</profiles>
</project>
Note : I already added this to application.properties:
server.servlet.context-path = /#artifactId#
server.servlet-path = /*
spring.application.name = #name#
Any help would be very appreciated.
Environment: RedHat Jboss EAP 7.2 , Spring boot 2.5.5 , JDK 11, Windows 11 Pro x64.
Thanks in advance.

How to specify own logging file while using spring boot with lombok

I am aware that some logging configuration can be specified in application.properties file. But I am interested in separating logging configuration from application configuration for obvious reasons and would prefer to use own logging file. I tried log4j2.properties, but spring boot seems to not detect it. Below is how my code and pom.xml is. Could someone suggest how to setup log4j2.properties when using with lombok.
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>LoggingWithLombak</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>LoggingWithLombak</name>
<description>Demo project for Logging With Lombak</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
and
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import lombok.extern.log4j.Log4j2;
import lombok.extern.slf4j.Slf4j;
#Slf4j
//#Log4j2
#SpringBootApplication
public class LoggingWithLombakApplication {
public static void main(String[] args) {
log.trace("some trace logging...");
log.debug("some debug logging...");
log.info("some info logging...");
log.warn("some warn logging...");
log.error("some error logging...");
log.info("log.getClass(): " + log.getClass());
SpringApplication.run(LoggingWithLombakApplication.class, args);
}
}
and adding below in log4j2.properties has no effect.
logging.level.org=WARN
logging.level.com.example.demo=ERROR
You should add the properties to file application.properties instead of log4j2.properties.
If you want more complex log4j2 configuration, use file log4j2-spring.xml or log4j2.xml.
Spring boot log level
Spring boot custom log configuration

org/springframework/boot/bind/RelaxedPropertyResolver not found

I am trying to connect Apache Artemis with Apache Camel in Spring Boot project.
I am getting problem when I am upgrading my spring boot version from 1.5.9.RELEASE to 2.2.2.RELEASE. Below is my POM and Java files which I am using:
<?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>com.learncamel</groupId>
<artifactId>activemq-learncamel-spring-boot</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>learncamel-spring-boot</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<camel-version>2.20.1</camel-version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>2.20.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--jdbc-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>1.5.9.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jdbc</artifactId>
<version>${camel-version}</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1212</version>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
<scope>provided</scope>
</dependency>
<!-- EMail-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>1.4.3.RELEASE</version>
</dependency>
<!--activeMQ-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
<version>5.15.3</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jms</artifactId>
<version>2.20.1</version>
</dependency>
<!--health Check-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http</artifactId>
<version>2.20.1</version>
</dependency>
<!--Test Dependencies-->
<!--Camel Spring Test-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-spring</artifactId>
<version>2.20.1</version>
<scope>test</scope>
</dependency>
<!--Clean Up directory-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
When I am upgrading parent version to 2.2.2.RELEASE then it start giving below error:-
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
21-06-2020 15:39:11.614 [main] ERROR o.s.boot.SpringApplication.reportFailure - Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.learncamel.ActiveMQCamelApplication]; nested exception is java.lang.IllegalStateException: Could not evaluate condition on org.apache.camel.spring.boot.security.CamelSSLAutoConfiguration due to org/springframework/boot/bind/RelaxedPropertyResolver not found. Make sure your own configuration does not rely on that class. This can also happen if you are #ComponentScanning a springframework package (e.g. if you put a #ComponentScan in the default package by mistake)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:597)
at org.springframework.context.annotation.ConfigurationClassParser.access$900(ConfigurationClassParser.java:109)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.lambda$processGroupImports$1(ConfigurationClassParser.java:805)
at java.util.ArrayList.forEach(ArrayList.java:1257)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:801)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:771)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:188)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:325)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:242)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at com.learncamel.ActiveMQCamelApplication.main(ActiveMQCamelApplication.java:10)
Caused by: java.lang.IllegalStateException: Could not evaluate condition on org.apache.camel.spring.boot.security.CamelSSLAutoConfiguration due to org/springframework/boot/bind/RelaxedPropertyResolver not found. Make sure your own configuration does not rely on that class. This can also happen if you are #ComponentScanning a springframework package (e.g. if you put a #ComponentScan in the default package by mistake)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:54)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:221)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:587)
... 19 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedPropertyResolver
at org.apache.camel.spring.boot.security.CamelSSLAutoConfiguration$Condition.getMatchOutcome(CamelSSLAutoConfiguration.java:51)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
... 22 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedPropertyResolver
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 24 common frames omitted
Process finished with exit code 1
I am using below Java files:
package com.learncamel.config;
import org.apache.activemq.camel.component.ActiveMQComponent;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.jms.ConnectionFactory;
#Configuration
public class ActiveMQConfig {
#Bean(name="activemq")
public ActiveMQComponent createComponent(ConnectionFactory factory){
ActiveMQComponent activeMQComponent = new ActiveMQComponent();
activeMQComponent.setConnectionFactory(factory);
return activeMQComponent;
}
}
Another Java file:
package com.learncamel.routes;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
#Component
public class ActiveMQRoute extends RouteBuilder{
#Override
public void configure() throws Exception {
from("{{fromRoute}}")
.log("Read Message from activemQ ${body}")
.to("{{toRoute}}");
}
}
Such errors could arise because of mixed Spring versions.
Do a Maven dependency tree and check for mixed Spring versions (the one of the parent POM and other versions from transitive dependencies.
If you got mixed Spring versions in your dependency tree, fix them with dependency management or similar Maven features.
I had spring-boot-starter-parent version in pom as 2.3.10.RELEASE but added spring-boot dependency of 2.1.8.RELEASE. I had to remove version from there to make the error go away
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<!--<version>2.1.8.RELEASE</version>-->
</dependency>

Resources