Quarkus runtime does not inject EntityManager - jpa

I have tried #PersistenceContext, #PersistenceUnit, and #Inject combinations but nothing works. #Inject fails maven-quarkus-plugin build:
[ERROR] Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers [#Default]
I have tried with and without persistence.xml.
My datasource and application.properties work fine, as I can just inject a AgroalDataSource and do direct JDBC, but I want to port over my JPA Entity classes and use them.
my parent module pom
<!-- versions set by quarkus-bom, but they don't pass in, when changing quarkus version, update this from quarkus bom -->
<properties>
<quarkus.version>1.0.0.CR1</quarkus.version>
<agroal.version>1.7</agroal.version>
<jakarta.enterprise.cdi-api.version>2.0.2</jakarta.enterprise.cdi-api.version>
<jboss-jaxrs-api_2.1_spec.version>2.0.1.Final</jboss-jaxrs-api_2.1_spec.version>
<jboss-logging.version>3.3.2.Final</jboss-logging.version>
<jboss-threads.version>3.0.0.Final</jboss-threads.version>
<smallrye-config.version>1.3.9</smallrye-config.version>
<wildfly-common.version>1.5.0.Final-format-001</wildfly-common.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-universe-bom</artifactId>
<version>${quarkus.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
my pom
<dependencies>
<dependency>
<groupId>com.lmco.is3.cs</groupId>
<artifactId>datatypes</artifactId>
<exclusions>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
</exclusions>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.lmco.is3.cs</groupId>
<artifactId>utils</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.lmco.is3.nc</groupId>
<artifactId>netcentric-if</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>io.undertow</groupId>
<artifactId>undertow-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.spec.javax.websocket</groupId>
<artifactId>jboss-websocket-api_1.1_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.agroal</groupId>
<artifactId>agroal-api</artifactId>
<version>${agroal.version}</version>
</dependency>
<dependency>
<groupId>io.agroal</groupId>
<artifactId>agroal-narayana</artifactId>
<version>${agroal.version}</version>
</dependency>
<dependency>
<groupId>io.agroal</groupId>
<artifactId>agroal-pool</artifactId>
<version>${agroal.version}</version>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-config</artifactId>
<version>${smallrye-config.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-agroal</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-artemis-jms</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>${jboss-logging.version}</version>
</dependency>
<dependency>
<groupId>org.wildfly.common</groupId>
<artifactId>wildfly-common</artifactId>
<version>${wildfly-common.version}</version>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<version>${jakarta.enterprise.cdi-api.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
<version>${jboss-jaxrs-api_2.1_spec.version}</version>
</dependency>
application.properties
# Configures the Artemis properties.
quarkus.artemis.url=tcp://mq:61616?type=CF
quarkus.artemis.username=artemis
quarkus.artemis.password=simetraehcapa
quarkus.datasource.url=jdbc:postgresql://db:5432/stsdb
quarkus.datasource.driver=org.postgresql.Driver
quarkus.datasource.username=appuser
quarkus.datasource.password=appuser
quarkus.resteasy.gzip.enabled=true
quarkus.resteasy.gzip.max-input=10M
quarkus.log.category."com.lmco.is3.nc.micro.clock".level=INFO

I figured it out! Not real "intuitive", but I had not migrated over any Entity classes yet. All it took was to put one class in scope and everything started working. So much for simple prototyping. Maybe it should have warned "no entity classes found".

Friend, I had the same problem. Here's what I did that worked for me, I hope to help you:
added on application.properties
quarkus.hibernate-orm."db".packages = packages with their entities
example:
quarkus.hibernate-orm."db".packages=br.com.application.base.models
in my repositories:
#ApplicationScoped
#ActivateRequestContext
public class HeaderRepository {
#PersistenceUnit("db")
EntityManager entityManager;
I hope to help you
following documentation: https://quarkus.io/guides/hibernate-orm
thanks

Related

Failed to connect jira api: failed to access class org.apache.http.impl.client.cache.BasicHttpCache from class CachingHttpAsyncClient

I faced an issue durring connecting to jira api by existing code on ear application using application server wildfly19.0.1.Final :
1- the added code :
AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
IssueRestClient client= factory.createWithBasicHttpAuthentication(URI.create("https://jiralink.com"), "username", "password");
2- Pom xml file dendencies:
<dependency>
<groupId>com.atlassian.event</groupId>
<artifactId>atlassian-event</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.atlassian.httpclient</groupId>
<artifactId>atlassian-httpclient-api</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.atlassian.httpclient</groupId>
<artifactId>atlassian-httpclient-library</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-api</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>com.atlassian.sal</groupId>
<artifactId>sal-api</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>io.atlassian.fugue</groupId>
<artifactId>fugue</artifactId>
<version>4.7.2</version>
</dependency>
<dependency>
<groupId>io.atlassian.util.concurrent</groupId>
<artifactId>atlassian-util-concurrent</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpasyncclient-cache</artifactId>
<version>4.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient-cache</artifactId>
<version>4.5.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpasyncclient</artifactId>
<version>4.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore-nio</artifactId>
<version>4.4.10</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.5</version>
</dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.1</version>
</dependency>
the issue:
Caused by: java.lang.IllegalAccessError: failed to access class org.apache.http.impl.client.cache.BasicHttpCache from class org.apache.http.impl.client.cache.CachingHttpAsyncClient (org.apache.http.impl.client.cache.BasicHttpCache is in unnamed module of loader 'deployment.MegaPack.ear.httpclient-cache-4.5.5.jar' #51bff63e; org.apache.http.impl.client.cache.CachingHttpAsyncClient is in unnamed module of loader 'deployment.MegaPack.ear.httpasyncclient-cache-4.1.4.jar' #1746dc55)
at org.apache.http.impl.client.cache.CachingHttpAsyncClient.(CachingHttpAsyncClient.java:174) ~[httpasyncclient-cache-4.1.4.jar:4.1.4]
at com.atlassian.httpclient.apache.httpcomponents.ApacheAsyncHttpClient.(ApacheAsyncHttpClient.java:214) ~[atlassian-httpclient-library-2.0.0.jar:?]
at com.atlassian.httpclient.apache.httpcomponents.ApacheAsyncHttpClient.(ApacheAsyncHttpClient.java:102) ~[atlassian-httpclient-library-2.0.0.jar:?]
at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClientFactory.doCreate(DefaultHttpClientFactory.java:61) ~[atlassian-httpclient-library-2.0.0.jar:?]
at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClientFactory.create(DefaultHttpClientFactory.java:36) ~[atlassian-httpclient-library-2.0.0.jar:?]
at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory.createClient(AsynchronousHttpClientFactory.java:65) ~[jira-rest-java-client-core-5.2.0.jar:?]
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:36) ~[jira-rest-java-client-core-5.2.0.jar:?]
at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:42) ~[jira-rest-java-client-core-5.2.0.jar:?]
it looks like i have an issue with jars compatibilities related to :
org.apache.httpcomponents.httpclient-cache: 4.5.5
any one have an idea by how to correct the issue ?
Thanks,

Error while building NAR with mongo controller service api dependency

I have tried building NAR in apache NIFI. when debugging in local no dependency errors popped up while execution. Post that While building NAR to deploy in production facing the following error.
[ERROR] Failed to execute goal org.apache.nifi:nifi-nar-maven-plugin:1.3.1:nar (default-nar) on project nifi-porter-nar: Execution default-nar of goal org.apache.nifi:nifi-nar-maven-plugin:1.3.1:nar failed: A required class was missing while executing org.apache.nifi:nifi-nar-maven-plugin:1.3.1:nar: org/apache/nifi/mongodb/MongoDBClientService
Below is my NAR pom.xml
<parent>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-custom-processor-porter</artifactId>
<version>4.0.0</version>
</parent>
<artifactId>nifi-porter-nar</artifactId>
<version>4.0.0</version>
<packaging>nar</packaging>
<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>
<source.skip>true</source.skip>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-porter-processors</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-standard-services-api-nar</artifactId>
<version>1.12.0</version>
<type>nar</type>
</dependency>
</dependencies>
Dependencies pom.xml
<dependencies>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-utils</artifactId>
<version>1.12.0</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-mock</artifactId>
<version>1.12.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.0</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-dbcp-service-api</artifactId>
<version>1.12.0</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-mongodb-client-service-api</artifactId>
<version>1.12.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-gcp-services-api</artifactId>
<version>1.12.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.8</version>
</dependency>
</dependencies>
Can anyone help me in building the NAR successfully?
Note: Tried this solution too, but couldn't resolve

Spring's ConstructorResolver#instantiateUsingFactoryMethod ignoring spring.mongodb.embedded.version for embedded mongodb

I'm trying to run a Spring Boot application with an embedded mongodb (not just for testing, but live). It was working fine until I decided to modernize to use latest available Spring jars, etc. Upgrading to Spring Boot 2.6.1 I now get an 'IllegalStateException: Set the spring.mongodb.embedded.version property or define your own MongodConfig bean to use embedded MongoDB' from EmbeddedMongoAutoConfiguration#determineVersion, where my application.properties entry for 'spring.mongodb.embedded.version=3.6.3' is being reported as null. Tracing back to ConstructorResolver#instantiateUsingFactoryMethod I see it passes in an EmbeddedMongoProperties with null 'version'. That method is way over my head but I believe it is the cause. I suspect it's somehow using the older MongoProperties which does not have version but I'm not sure. I've been debugging for hours and I'm not getting anywhere fast. Any help appreciated.
application.properties:
server.port=8090
spring.mongodb.embedded.version=3.6.3
spring.mongodb.embedded.features=SYNC_DELAY,NO_HTTP_INTERFACE_ARG
spring.datasource.driver-class-name=mongodb.jdbc.MongoDriver
#spring.data.mongodb.uri=mongodb://127.0.0.1:27017
spring.data.mongodb.database=jokes
spring.data.mongodb.host=127.0.0.1
spring.data.mongodb.port=27017
#spring.data.mongodb.username=craig
#spring.data.mongodb.password=***
#spring.data.mongodb.authentication-database=admin
spring.mongodb.embedded.storage.database-dir=/home/craig/.ca.footeware.web-mongodb/
pom.xml dependencies:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<!-- exclude junit 4 -->
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-imaging</artifactId>
<version>1.0-alpha2</version>
</dependency>
</dependencies>
Please add below lines to test class.
#DataMongoTest
#ImportAutoConfiguration(exclude = EmbeddedMongoAutoConfiguration.class)

Maven using wrong version of javax.validation

I have a dynamic web project I have been working on that uses hibernate as a jpa provider. Up until the last week, I could insert, update, query, and delete from my databases using hibernate. Recently, I began working on validation, and brought in a lot of different maven dependencies. In the course of doing this, I somehow have ended up with my project using an older, deprecated version of javax.validation jar, which throws a no such method exception. I have included the relevant lines of the stack trace below:
Caused by: java.lang.NoSuchMethodError: javax.validation.BootstrapConfiguration.getClockProviderClassName()Ljava/lang/String;
at org.hibernate.validator.internal.xml.ValidationBootstrapParameters.<init>(ValidationBootstrapParameters.java:63)
However, in my pom.xml I have the following dependency (which, when examined via javap and through eclipse, it has the method getClockProviderClassName() in the specified class):
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.0.Final</version>
</dependency>
I put the following exclusion tag in my pom in multiple dependencies to try and ensure that it does not pull this jar from other sources:
<exclusion>
<artifactId>validation-api</artifactId>
<groupId>javax.validation</groupId>
</exclusion>
I have also simplified my build path, so there is three elements in it: one properties folder that contains only my log4j configuration, the JRE System library (version 1.8) and maven dependencies. Is there any way to tell where the deprecated javax.validation jar is coming from? Can I force the program to use version 2.0.0 I bring in with maven? Thank you for your help.
Additional Information:
full stack trace
persistence.xml source
working datasource properties
Java Build Path
Line where root exception occurs (in my code)
look inside the included jar to see it contains the method
using javap to examine artifact in maven (m2) directory
dependency overview from maven
Dependencies from pom.xml
<dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.0.2.RELEASE</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.2.Final</version>
<exclusions>
<exclusion>
<artifactId>jboss-logging</artifactId>
<groupId>org.jboss.logging</groupId>
</exclusion>
<exclusion>
<artifactId>validation-api</artifactId>
<groupId>javax.validation</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.10.0</version>
</dependency>
<!-- https://stackoverflow.com/questions/20859379/cannot-import-javax-ejb-packages -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jboss.logging/jboss-logging -->
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.3.0.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.ejb/ejb-api -->
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.3</version>
</dependency>
<!-- ********************************************************************************************************** -->
<!-- THE FOLLOWING ARE SEPERATE FROM HIBERNATE THAT IS USED TO CONNECT
TO DB, THESE ARE FOR USE WITH VALIDATION -->
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.7.Final</version>
<exclusions>
<exclusion>
<artifactId>validation-api</artifactId>
<groupId>javax.validation</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator-annotation-processor -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-annotation-processor</artifactId>
<version>6.0.7.Final</version>
<exclusions>
<exclusion>
<artifactId>validation-api</artifactId>
<groupId>javax.validation</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-cdi</artifactId>
<version>6.0.7.Final</version>
<exclusions>
<exclusion>
<artifactId>validation-api</artifactId>
<groupId>javax.validation</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.0.Final</version>
</dependency>
<!-- ********************************************************************************************************** -->
<!-- API and reference implementation of expression language {a.b} in html
code -->
<!-- https://mvnrepository.com/artifact/javax.el/javax.el-api -->
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.web/javax.el -->
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
<version>2.2.6</version>
</dependency>
</dependencies>
Try adding this dependency to your pom.xml
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
The situation is provoked by having javaee-web-api 7.0 as dependency:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
This dependency provided by your servlet or application container at runtime is giving you an older api for javax.validation.
You have two things to try:
Change the version of javaee-web-api to 8.0
This is the fastest solution if you are deploying your web app to a servlet or application container that supports Java EE 8.0 (for example: it seems to work in Tomcat 8.5.X but reading the documentation, only Tomcat 9 provides support for Java EE 8).
Keep javaee-web-api as 7.0 and downgrade hibernate-validator, validation-api dependencies:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.4.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-annotation-processor</artifactId>
<version>5.4.2.Final</version>
</dependency>
You have to change also some imports such as #Email or #NotEmpty from javax.validation package to org.hibernate.validator.constraints (those annotations are Deprecated in 6.0.X hibernate-validator versions because they're included inside javax.validation api).
Do mvn dependency:tree , May you have another dependencies that use hibernate-annotations, and conflict with your spring version, also you can find them and exclude from class path, as below:
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
</exclusion>
</exclusions>
I hopefully help you.
Had the same problem with Springboot 2.1.4.RELEASE and some GeoTools dependencies.
Validation-api was specified from javax.validation and javaee-api jars.
Put them as dependencies like following:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
Had the same issue as jekho, but solved it with:
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-referencing</artifactId>
<version>22.3</version>
<exclusions>
<exclusion>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
</exclusion>
</exclusions>
</dependency>
I found which dependency was using javaee-api by using maven's dependency:tree on my project which points out which packages are being used by which dependency.

How to enable Apache Ignite REST API on Springboot application?

I'm developing distributed computing application with Apache Ignite and Springboot and wanna use ignite REST API.
Below is my dev spec.
java 1.8
springboot 1.5.6
ignite 2.1.0
I added dependency ignite-rest-http(2.1.0 ver.) on my pom file.
But there is one problem at starting my springboot application.
Here is error log.
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ignite.Ignite]: Factory method 'igniteInstance' threw exception; nested exception is java.lang.NoSuchMethodError: org.eclipse.jetty.util.log.StdErrLog.setProperties(Ljava/util/Properties;)V
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 35 common frames omitted
Caused by: java.lang.NoSuchMethodError: org.eclipse.jetty.util.log.StdErrLog.setProperties(Ljava/util/Properties;)V
at org.apache.ignite.internal.processors.rest.protocols.http.jetty.GridJettyRestProtocol.<clinit>(GridJettyRestProtocol.java:72)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.ignite.internal.processors.rest.GridRestProcessor.startHttpProtocol(GridRestProcessor.java:864)
at org.apache.ignite.internal.processors.rest.GridRestProcessor.start(GridRestProcessor.java:477)
at org.apache.ignite.internal.IgniteKernal.startProcessor(IgniteKernal.java:1788)
at org.apache.ignite.internal.IgniteKernal.start(IgniteKernal.java:937)
at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.start0(IgnitionEx.java:1896)
at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.start(IgnitionEx.java:1648)
at org.apache.ignite.internal.IgnitionEx.start0(IgnitionEx.java:1076)
at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:574)
at org.apache.ignite.IgniteSpring.start(IgniteSpring.java:66)
at com.ssg.framework.config.ignite.IgniteDefaultConfiguration.igniteInstance(IgniteDefaultConfiguration.java:59)
at com.ssg.framework.config.ignite.IgniteDataConfiguration$$EnhancerBySpringCGLIB$$84d5bde0.CGLIB$igniteInstance$7(<generated>)
at com.ssg.framework.config.ignite.IgniteDataConfiguration$$EnhancerBySpringCGLIB$$84d5bde0$$FastClassBySpringCGLIB$$a827740d.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at com.ssg.framework.config.ignite.IgniteDataConfiguration$$EnhancerBySpringCGLIB$$84d5bde0.igniteInstance(<generated>)
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.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 36 common frames omitted
In StdErrLog class, there is not 'setProperties(Properties)' method, but is called in GridJettyRestProtocol class.
I can't understand how it was built without syntax error.
Anyway, is there anyone who has solution?
============================================================================
I added my pom file below.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-spring</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-indexing</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-spring-data</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-urideploy</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</dependency>
<dependency>
<groupId>org.lazyluke</groupId>
<artifactId>log4jdbc-remix</artifactId>
</dependency>
<dependency>
<groupId>org.bgee.log4jdbc-log4j2</groupId>
<artifactId>log4jdbc-log4j2-jdbc4.1</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
</dependency>
<dependency>
<groupId>net.openhft</groupId>
<artifactId>compiler</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
</dependency>
<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>reflectasm</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-rest-http</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
ignite-rest-http module depends on Jetty 9.2.11.v20150529. Your error most likely means that there is already another version of Jetty on classpath and they conflict with each other. You should check your Maven (or Gradle, etc.) project go get to the bottom of this.
If you use spring boot 2.0.0+ then it has a dependency on jetty-bom which is only available in maven central since v9.3.19...
Ignites 2.6.0 uses jetty 9.2.11...
A quick and dirty workaround is to setup jetty like this, where jetty.base.version is the version Ignite uses. ex Ignite v2.6.0 this = 9.2.11.v20150529.
This way the jetty-bom gets resolved but not used.
The correct jetty libs for Ignite are loaded.
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-bom</artifactId>
<version>9.4.12.v20180830</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-continuation</artifactId>
<version>${jetty.base.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<version>${jetty.base.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
<version>${jetty.base.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.base.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty.base.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-xml</artifactId>
<version>${jetty.base.version}</version>
<scope>compile</scope>
</dependency>