Message source not found .properties file [duplicate] - spring

After upgrading from Spring Boot 1.2.8 to 1.3.2 my application suddenly stopped working.
Upon application's startup I get the following exception.
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.context.support.ResourceBundleMessageSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
... 25 more
It looks like there is a problem with ResourceBundleMessageSource but I do not have any idea why. In version 1.2.8 everything worked like a charm.
This 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--replace with your namespace and version -->
<groupId>my</groupId>
<artifactId>project</artifactId>
<version>0.1</version>
<properties>
<hibernate.version>5.0.2.Final</hibernate.version>
<spring.data.jpa.version>1.9.0.RELEASE</spring.data.jpa.version>
<spring.social.version>1.1.2.RELEASE</spring.social.version>
<spring.social.twitter.version>1.1.1.RELEASE</spring.social.twitter.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<start-class>my.project.Application</start-class>
<java.version>1.8</java.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath />
</parent>
<repositories>
<repository>
<id>project.local</id>
<name>my-project</name>
<url>file:${project.basedir}/repo</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-social-facebook</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-google</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1203-jdbc42</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-java8</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.jadira.usertype</groupId>
<artifactId>usertype.jodatime</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>net.tanesha.recaptcha4j</groupId>
<artifactId>recaptcha4j</artifactId>
<version>0.0.7</version>
</dependency>
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.4</version>
</dependency>
</dependencies>
</project>

It sounds like you have one or more messages_${locale}.properties files but don't have a messages.properties file. From the 1.3.2 release announcement:
If you are upgrading from 1.3.1 there is one potentially breaking change; we now only search for messages.properties (and not messages*.properties) to enable auto-configuration of a message source. If you previously had a message file of the form messages_en.properties and you didn’t include a default messages.properties file, you will now need to add one.

#Jagger, #XtremeBiker point is valid to use the parent dependencies which will in turn include all required libraries on its own & you end up with clean pom file as well. Reason why your earlier version spring-boot project was working is that you had all required dependencies in place but its quite common that on any successive SPRING release some dependencies were removed while some are included & hence its highly likely it would break any working code after an update.
Now about the above issue, it can be seen that ResourceBundleMessageSource is missing on your project classpath so pls include the latest version of spring-context & try :-
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>

Related

Unable to load config data from optional:configserver:http//localhost:8012

I have developed a users microservice and it acts as a client to spring config server but while starting users microservice it is giving below error. Could you help me to get ride of this issue
Erro stack
java.lang.IllegalStateException: Unable to load config data from 'optional:configserver:http//localhost:8012'at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:128) ~[spring-boot-2.4.5.jar:2.4.5]
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 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.4.5</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.appsdeveloperblog.photoapp.api.users</groupId>
<artifactId>PhotoAppApiUsers</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>PhotoAppApiUsers</name>
<description>Users micro service</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>2020.0.2</spring-cloud.version>
<vaadin.version>14.5.3</vaadin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</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-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.modelmapper/modelmapper -->
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>2.3.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.9.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-config-server -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-bootstrap -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</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>
<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>```
**application.properties file of users microservice**
gateway.ip=192.168.56.109
token.expiration_time = 86400000
token.secret = hfgry463hf746hf573ydh475fhy5
login.url.path = /users/login
spring.config.import=optional:configserver:http//localhost:8012
The issue has been resolved by just replacing the below dependency
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
instead of
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
Didn't fully understand the issue, but can help with what we were doing to fetch config from a config server for a certain microservice.
as in your case, users microservice will have a dependency like this in pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
And project will have a file called bootstrap.yml or bootstrap.properties as below
spring:
application:
name: user-service
cloud:
config:
uri: <config-server-url>
username: <if-exists>
password: <if-exists>
hope this will be helpful to resolve your issue.
but it seems there is an issue with "name": "https://github.com/balanjaneyulu23/PhotoAppConfiguration/file:C:\Users\admin\AppData\Local\Temp\config-repo-8473851427074645327\application.properties"
In your app.properties or JAVA_OPTS end your path with / such that its not read as a file
-Dspring.config.location=/app/etc/
As you can see i got same error.
In maven panel its clearly shows that main reason of error is dependency. You have to import correct version of dependencies.
First thing you have to do is make sure that your config server is up.
For example you have xxx-dev.yml in your config file. You have to access this config file with http://localhost:8888/xxx/dev. (in this example config server process on port 8888)
If your config server up then you should check your dependencies & properties file in your project which will use config server.
Your project application.properties file
# APPLICATION NAME
spring.application.name=xxx
# PROFILE
spring.profiles.active=dev
# CONFIG SERVER
spring.config.import=optional:configserver:http://localhost:8888
Your project pom.xml file
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
Do not forget the add spring-cloud.version property into the pom.xml file. It will help you to import correct version of config client.
...
<properties>
<java.version>17</java.version>
<spring-cloud.version>2022.0.0</spring-cloud.version>
</properties>
...
After correcting the dependency it will be work fine.

javax.persistence and jakarta.persistence classpath errors

I have a springboot project that uses jpa and olingo. It runs ok locally for testing but when I create a war file and run it, I sometimes get this error
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.hibernate.cfg.AnnotationBinder.bindJoinedTableAssociation(AnnotationBinder.java:2531)
The following method did not exist:
javax.persistence.JoinTable.indexes()[Ljavax/persistence/Index;
The method's class, javax.persistence.JoinTable, is available from the following locations:
jar:file:/usr/sap/ljs/webapps/spring-boot-doeapis-0.0.1-SNAPSHOT/WEB-INF/lib/javax.persistence-2.0.5.jar!/javax/persistence/JoinTable.class
jar:file:/usr/sap/ljs/webapps/spring-boot-doeapis-0.0.1-SNAPSHOT/WEB-INF/lib/jakarta.persistence-api-2.2.3.jar!/javax/persistence/JoinTable.class
It was loaded from the following location:
file:/usr/sap/ljs/webapps/spring-boot-doeapis-0.0.1-SNAPSHOT/WEB-INF/lib/javax.persistence-2.0.5.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of javax.persistence.JoinTable
Now I'm trying to figure out which one of the libraries I'm using is downloading the javax.persistence or jakarata.persistence so I can try to prevent it from downloading. I'm using Maven if it helps.
<?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.2.2.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>
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
<olingo2.version>2.0.11</olingo2.version>
<sap.cloud.sdk.version>3.99.14</sap.cloud.sdk.version>
</properties>
<groupId>gov.doe.ph</groupId>
<artifactId>spring-boot-doeapis</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-doeapis</name>
<description>Doe project for Spring Boot</description>
<packaging>war</packaging>
<!--properties>
<java.version>1.8</java.version>
<olingo2.version>2.0.11</olingo2.version>
</properties-->
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-spring-service-connector</artifactId>
<version>1.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-cloudfoundry-connector</artifactId>
<version>1.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</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>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-el</artifactId>
</exclusion-->
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
</exclusions>
</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-logging</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sap.cloud</groupId>
<artifactId>neo-java-web-sdk</artifactId>
<version>${sap.cloud.sdk.version}</version>
<type>pom</type>
<scope>provided</scope>
</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>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Olingo 2 Dependencies -->
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-core</artifactId>
<version>${olingo2.version}</version>
<!-- Avoid jax-rs version conflict by excluding Olingo's version -->
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-jpa-processor-core</artifactId>
<version>${olingo2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-jpa-processor-ref</artifactId>
<version>${olingo2.version}</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-server -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.26</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api -->
<!-- <dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1</version>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<!--dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
</dependency-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>5.2.1.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.mchange/c3p0 For unable to acquire JDBC connection error-->
<!--dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.2</version>
</dependency-->
<!--dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>5.4.20.Final</version>
</dependency-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>org.apache.olingo.odata2.core.rest.ODataExceptionMapperImpl</pattern>
<shadedPattern>org.shaded.plexus.util</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin-->
</plugins>
</build>
<profiles>
<profile>
<id>cf</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<packaging.type>jar</packaging.type>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>neo</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<packaging.type>war</packaging.type>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
I tried to remove every library little by little so long as it still compiles but I still get both jar files so now I want know how to check what jar files each fo my libraries downloads.
Update: It seems that spring-boot-starter-data-jpa is the one that gets the jakarta.persistence and the olingo-odata2-jpa-processor-core, olingo-odata2-jpa-processor-ref and hibernate-testing are the ones using the javax.persistence.
I've only been using spring boot for a short while so would this actually cause problems? Thing is, I don't get the error consistently. When I restart the server, sometimes I get the error and other times I don't. I can't really figure out what causes the error to appear.
Run mvn dependency:tree and find which dependencies depends on javax.persistence and jakarta.persistence.
Then you have to make a decision. Do you want to use javax or jakarta?.
If you want to use javax, you will need to decrease the version of libraries that depends on persistence till you find javax from previous command. If you want to use jakarta you will need to increase that versions.
The important thing is that all dependencies are consistent with javax or jakarta.

Guava version 16.0 being used during runtime even though 18.0 is used during compile time

I am trying to run a project in wildfly. Following is the guava dependency version. I tried including 18.0 in the dependency management but it still uses 16.0. Been struggling with this for entire day, googled a lot but no solution on this.
Here is the stack trace
Caused by: java.lang.ExceptionInInitializerError
at com.verizon.fieldops.equipmentservice.dao.cassandra.CassandraDAO.init(CassandraDAO.java:155)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:363)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:307)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
... 39 more
Caused by: java.lang.IllegalStateException: Detected Guava issue #1635 which indicates that a version of Guava less than 16.01 is in use. This introduces codec resolution issues and potentially other incompatibility issues in the driver. Please upgrade to Guava 16.01 or later.
at com.datastax.driver.core.SanityChecks.checkGuava(SanityChecks.java:62)
at com.datastax.driver.core.SanityChecks.check(SanityChecks.java:36)
at com.datastax.driver.core.Cluster.<clinit>(Cluster.java:68)
... 47 more
As request in the comment editing the description to add pom file content
<?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.verizon.fieldops</groupId>
<artifactId>equipmentservice</artifactId>
<version>1.00.004</version>
<packaging>war</packaging>
<name>equipmentservice</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.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>
<maven.test.skip>true</maven.test.skip>
<libs.path>${basedir}/libs</libs.path>
</properties>
<dependencies>
<!-- Spring Boot Web 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>
<!-- Spring Boot Devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<!-- Spring Boot test framework -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Java JMS API dependency -->
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Spring JMS dependency -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
</dependency>
<!-- OmegaCore Dependency -->
<dependency>
<groupId>com.verizon.fieldops</groupId>
<artifactId>OmegaCore</artifactId>
<version>1.00.006</version>
<scope>system</scope>
<systemPath>${libs.path}/OmegaCore-1.00.006.jar</systemPath>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency> -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>
<!-- JSR Annotations -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jdbc -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandraDependency</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${libs.path}/cassandraDependency-1.0.jar</systemPath>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.0.1</version><!--$NO-MVN-MAN-VER$-->
<scope>system</scope>
<systemPath>${libs.path}/cassandra-driver-core-3.0.1.jar</systemPath>
</dependency>
<!-- Hystrix (Circuit Breaker) dependencies -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.M9</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<!-- <finalName>MSTemplate</finalName> -->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<!-- <version>3.2.2</version> -->
<configuration>
<!-- <includeSystemScope>true</includeSystemScope> -->
<webResources>
<resource>
<directory>libs/</directory>
<targetPath>WEB-INF/lib</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
<!-- Repositories -->
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<description>Equipment service</description>
</project>
Reviewing the dependency called archaius-core 0.7 5 currently is using guava version 16.0 then if you want to use guava version 18.0
You need to add the dependency by following way:
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
I think it is an issue of version typo when packing the jar what you are having.
It reminds me the class loading issue when I work with Glassfish4 long time ago. From the docs , the classes will first load from the following order before loading from the lib in the WAR :
(1) System Dependencies - These are dependencies that are added to the
module automatically by the container, including the Java EE api’s.
(2) User Dependencies - These are dependencies that are added through
jboss-deployment-structure.xml or through the Dependencies: manifest
entry.
It also mentions that the dependencies in (1) can be excluded through by the use of jboss-deployment-structure.xml.
And from this , jboss-deployment-structure.xml should be placed inside /WEB-INF/ and can prevent the server from automatically adding some dependencies by :
<jboss-deployment-structure>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="com.google.guava" />
</exclusions>
</jboss-deployment-structure>
Actually I don't know how to find the module name of the Guava module, I just search the docs and Github and found there is a one called com.google.guava .
I am also not sure it will work or not. But hope to give you some direction .Good luck.

To remove extra dependencies inherited from spring-boot-starter-parent

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
When spring-boot-starter-parent is used as parent, then it includes many unnecessary dependencies. Like in my case it fetches the dependencies for
(spring-mobile-device , spring-social-facebook , spring-social-linkedin , org.apache.activemq ) which i don't want.
If I open my effective POM(with get's auto created) , it's contains hell lot of dependencies which i don't want.
Is there any way to remove the unnecessary dependencies which are not used in the project? Is there a tool to identify such dependencies?
Any help is appreciated :)
Thanks
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>
<groupId>demo</groupId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>demo</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
<relativePath />
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId>
<version>2.2.4</version>$NO-MVN-MAN-VER$ </dependency> -->
<!-- <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-client</artifactId>
<version>1.17.1</version> </dependency> -->
<!-- <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId>
<version>4.4.1</version>$NO-MVN-MAN-VER$ </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId> <version>4.4.1</version> </dependency> -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<!-- <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId>
<version>2.8</version> </dependency> -->
<!-- <dependency> <groupId>com.rabbitmq</groupId> <artifactId>amqp-client</artifactId>
<version>3.5.4</version> </dependency> -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>demo.Application</start-class>
<java.version>1.7</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<artifactId>DEMO</artifactId>
spring-boot-starter-parent doesn't declare any dependencies. However, via spring-boot-dependencies, it does provide dependency management for a wide-range of potential dependencies.
From Maven's documentation:
The dependency management section is a mechanism for centralizing dependency information. When you have a set of projects that inherits a common parent it's possible to put all information about the dependency in the common POM and have simpler references to the artifacts in the child POMs
The references to artifacts can be simpler as, thanks to the dependency management, there's no need to declare a version. For example:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<dependency>
<dependencies>
If you don't specify a version, Maven will use the version that's configured in the dependency management.
Only when you add an entry in your pom's <dependencies> section will your project actually have that dependency and Maven will download it as part of the build.

Calling KieScanner throws ClassNotFoundException

I have several Drools projects and would like to be able to dynamically load rules changes. The projects all work fine until I tried to add KieScanner to them. I followed the directions here: http://docs.jboss.org/drools/release/6.0.1.Final/drools-docs/html/DroolsReleaseNotesChapter.html#d0e515
I am using drools 6.1.0.Final with Wildfly 8.0.0.Final
The documentation indicates that having the dependency for the kie-ci in my class path was enough. Clearly either I am doing something wrong or the documentation is wrong.
The project builds but when it is called, I get this trace:
10:21:17,946 ERROR [io.undertow.request] (default task-2) UT005023: Exception handling request to /catalog/vetec/search/facets/term: org.jboss.resteasy.spi.UnhandledException: javax.enterprise.inject.CreationException
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372) [resteasy-jaxrs-3.0.6.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) [resteasy-jaxrs-3.0.6.Final.jar:]
Caused by: java.lang.NoClassDefFoundError: org/apache/maven/repository/internal/MavenRepositorySystemSession
at org.kie.scanner.MavenRepository.getMavenRepository(MavenRepository.java:73) [kie-ci-6.1.0.Final.jar:6.1.0.Final]
at org.kie.scanner.ArtifactResolver.(ArtifactResolver.java:36) [kie-ci-6.1.0.Final.jar:6.1.0.Final]
at org.kie.scanner.KieRepositoryScannerImpl.getArtifactResolver(KieRepositoryScannerImpl.java:87) [kie-ci-6.1.0.Final.jar:6.1.0.Final]
at org.kie.scanner.KieRepositoryScannerImpl.getArtifactVersion(KieRepositoryScannerImpl.java:108) [kie-ci-6.1.0.Final.jar:6.1.0.Final]
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl$KieModuleRepo.load(KieRepositoryImpl.java:281) [drools-compiler-6.1.0.Final.jar:6.1.0.Final]
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl$KieModuleRepo.load(KieRepositoryImpl.java:267) [drools-compiler-6.1.0.Final.jar:6.1.0.Final]
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:90) [drools-compiler-6.1.0.Final.jar:6.1.0.Final]
at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:77) [drools-compiler-6.1.0.Final.jar:6.1.0.Final]
at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:97) [drools-compiler-6.1.0.Final.jar:6.1.0.Final]
at com.sial.rules.cdi.KSessionContextProvider.(KSessionContextProvider.java:49) [sial-rules-0.0.1-SNAPSHOT.jar:]
Here is the 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sial.rules</groupId>
<artifactId>sial-rules</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>JBoss Repository</id>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<!-- Added to ensure that we have the correct DROOLS/JBOSS versions -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-bom</artifactId>
<version>6.1.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-with-tools</artifactId>
<version>8.0.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-with-resteasy</artifactId>
<version>8.0.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-decisiontables</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-persistence-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>knowledge-api</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-internal</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<exclusions>
<exclusion>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0-rc1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.drools</groupId>
<artifactId>drools-maven-plugin</artifactId>
<version>6.0.0.CR5</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
This business rules project is itself incorporated into the actual WARs that are deployed to Wildfly.This is the dependency used in the application poms:
<dependency>
<groupId>com.sial.rules</groupId>
<artifactId>sial-rules</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
I recently discovered that the extra dependency breaks our Arquillian Unit tests. Since Arquillian has a completely different maven integration, my best guess is that this is a bug in KIE. It is very similar to BZ1098018
Adding this extra dependency "fixes" the issue when the code actually calls kie-ci, however with this dependency our Arquillian tests fail to deploy.
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-aether-provider</artifactId>
<version>3.0.5</version>
</dependency>
You should not need to declare the additional maven, aether and other dependencies manually. The kie-ci should transitively depend on everything it needs. If you look at the pom.xml of the kie-ci https://github.com/droolsjbpm/drools/blob/6.1.0.Final/kie-ci/pom.xml the dependencies you added are also listed there, so Maven resolves them automatically.
This seems to be either some weird bug or misconfiguration. I presume you have the following in your pom:
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<version>6.1.0.Final</version>
</dependency>
Could you post your whole pom?
The problem is that kie-ci includes an older version of maven (3.0.5) than does Arquillian (3.1.1) Specifically the maven-aether-provider. Arquillian (really ShrinkWrap) really wants to use the newer version.
I tried forcing the 3.0.5 version in the pom.xml but get the issue of the resolver.
This is the error:
java.lang.UnsupportedOperationException: Unable to boostrap Aether repository system. Make sure you're running Maven 3.1.0 or newer.
So basically kie 6.1.0.Final is incompatible with Arquillian 1.1.5.Final
I will have to see if the Kie 6.2.0CR3 release will work

Resources