java.lang.ClassNotFoundException: javax.validation.ValidatorFactory after upgrading Hibernate dependencies - java

I just updated my Hibernate dependencies in my gradle build file from:
implementation 'org.hibernate:hibernate-core:5.4.12.Final'
implementation 'org.hibernate.validator:hibernate-validator:6.0.18.Final'
implementation 'org.hibernate:hibernate-c3p0:5.4.21.Final'
to:
implementation 'org.hibernate:hibernate-core:5.5.7.Final'
implementation 'org.hibernate.validator:hibernate-validator:7.0.1.Final'
implementation 'org.hibernate:hibernate-c3p0:5.5.7.Final'
I already saw, that the validation API has been moved from javax.* to jakarta.* and I guess it has something to do with that. However, I was not able to find out which dependencies are in conflict in this case and what I would have to change to make it compatible.
Can someone help me there?

I solved it by adding 'javax.validation:validation-api:2.0.1.Final' to my dependencies. Can anyone explain to me why this is explicitly required? Are parts of the validation API still in the javax package?

I faced with same exception. It throws from TypeSafeActivator class
So according to https://hibernate.org/orm/releases/5.5/
Hibernate ORM 5.5 adds new artifacts with the artifact id suffix
"-jakarta" like hibernate-core-jakarta.

Related

class file for org.springframework.data.repository.query.QueryByExampleExecutor not found

I am in the processing of upgrading spring-data-jpa and spring-data-commons dependencies.
Currently, ModuleA uses 1.8.0.RELEASE of data-jpa (which internally uses 1.10.0.RELEASE of jpa-commons.
ModuleB which has a dependency on ModuleA uses 1.9.4.RELEASE of data-jpa (which internally uses 1.11.4.RELEASE of jpa-commons).
I upgraded ModuleA to use 1.9.4 as well and everything still worked without any issues.
Now, when I upgrade ModuleB to pretty much anything above 1.9.x (say 1.10.0.RELEASE), I get the following error:
[FileName.Java] cannot access org.springframework.data.repository.query.QueryByExampleExecutor
class file for org.springframework.data.repository.query.QueryByExampleExecutor not found
I checked ModuleA (1.8.0 and 1.9.4) as well as ModuleB (1.9.4) and could not find a path to QueryByExampleExecutor, so why does it fail when I upgrade further? I did not find any explicit mention of QueryByExampleExecutor.
#Query annotation from import org.springframework.data.jpa.repository.Query is used, so it could be coming from that?
Any suggestions?

Is apache-camel source code buildable in open-jdk-11?

When building apache-camel with openJDK-11. There are a lot of missing dependencies like
* jaxb
* annotation
* ...
How to build apache-camel source code with openJDK?
Officially there is no documentation on how to build using openJDK; Is there is any way to force build it?
I have tried adding jaxb implementation for server like "org.eclipse.persistence.moxy" but the same wasn't picked up properly :(
I have restricted the build env to be only open source; hence using openJDK as the base for development.
According to this article https://blog.codefx.org/java/java-11-migration-guide/ several packages have been removed from JDK 11.
In particular the section called Migrating From Java 8 To Java 11 shed some light on how to deal with this.
In short the following packages were removed:
The JavaBeans Activation Framework (JAF) in javax.activation CORBA in the packages javax.activity, javax.rmi, javax.rmi.CORBA, and org.omg.*
The Java Transaction API (JTA) in the package javax.transaction
JAXB in the packages javax.xml.bind.*
JAX-WS in the packages javax.jws, javax.jws.soap, javax.xml.soap, and javax.xml.ws.*
Commons Annotation in the package javax.annotation
To fix this:
Add third-party dependencies that contain the classes you need. The easiest way to do that is to stick to the reference implementations (given as Maven coordinates without version – use the most current ones):
JAF: with com.sun.activation:javax.activation
CORBA: there is currently no artifact for this
JTA: javax.transaction:javax.transaction-api
JAXB: com.sun.xml.bind:jaxb-impl
JAX-WS: com.sun.xml.ws:jaxws-ri
Commons Annotation: javax.annotation:javax.annotation-api
You can also view some more information using this Stackoverflow answer

Which dependencies are necessary in hibernate 5.2.13?

I am upgrading my hibernate project and hibernate dependencies from 3 to 5.2.13.Final and I am changing my code to build SessionFactory and i found some articles like first
and second
and all of them are using instance MetadataExtractorIntegrator.INSTANCE but I don't have this kind of class(MetadataExtractorIntegrator) in my dependencies ( maven project ) and can not find any dependency which is implementing this class. Can you help me which dependency do I need ?
As you can see, MetadataExtractorIntegrator is class written in aricle you have mentioned. Just create such class and probably copy-paste it. What you need Integrator interface and that is included in Hibernate's ORM
https://github.com/hibernate/hibernate-orm/tree/master/hibernate-core/src/main/java/org/hibernate/integrator/spi

Dagger dependencies when overriding graph with mock module causes NoClassDefFoundError

I am am migrating project to dagger 1.2.2. I'd like to override some dependencies for functional tests. For that I included the dagger-compiler as a dependency of the androidTest-build(?) as well:
apt "com.squareup.dagger:dagger-compiler:$daggerVersion"
compile "com.squareup.dagger:dagger:$daggerVersion"
androidTestApt "com.squareup.dagger:dagger-compiler:$daggerVersion
Now the compiler complains that he cannot find a class (I guess because both builds now contain the transitive dependencies of dagger-compiler):
Error:Execution failed for task ':app:compileDebugAndroidTestJava'.
> java.lang.NoClassDefFoundError: javax/inject/Scope
Looking around github it seems the approach should work without manually excluding stuff.
Nevermind. Actually reading the whole buildfile helps alot.
Because of previous dependency-foo I had a directive that excluded the missing dependency explicitly:
configurations {
androidTestCompile.exclude(group:'javax.inject')
}
Removing that fixed it.

Gradle unable to resolve version for dependency

My project depends on the Pax Exam framework. I declare, among others, these dependencies on Pax (PAX_EXAM_VERSION = 3.4.0):
compile group: 'org.ops4j.pax.exam', name: 'pax-exam-junit4', version: PAX_EXAM_VERSION
compile group: 'org.ops4j.pax.exam', name: 'pax-exam-container-native', version: PAX_EXAM_VERSION
Both of these depend on org.ops4j.pax.exam:pax-exam-spi, which is the module causing my issue.
So, when I try to build my project, the error reported is this one:
Could not resolve org.ops4j.pax.exam:pax-exam-spi:3.4.0
...
Could not parse POM http://repo.maven.apache.org/maven2/org/ops4j/pax/exam/pax-exam-spi/3.4.0/pax-exam-spi-3.4.0.pom
Unable to resolve version for dependency 'com.google.guava:guava:jar'
I have tried:
excluding pax-exam-spi from the transitive dependencies of the modules I depend on (but notice I still need the classes in it to be able to compile), adding Guava to my first-level dependencies, then trying to make pax-exam-spi a first-level dependency with transitive = false (won't work, same problem as above).
same as above, but instead of doing transitive = false, trying to use artifact-only notation, like this:
compile "org.ops4j.pax.exam:pax-exam-spi:${PAX_EXAM_VERSION}#jar"
I know the root of the problem is that the guava version is not declared in the pax-exam-spi pom, but in its parent exam, which only declares the Guava version(s) to use in 2 different profiles' dependencyManagement sessions (this works in Maven because one of the profiles is activated if the property glassfish.release is NOT set, and the other if that property IS set). However, knowing this has not been useful so far :(
Please let me know if there's any not-so-hacky way to make sure Gradle does include the pax-exam-spi's jar in my classpath, but does not even try to parse its POM (in particular, referring to a hard-coded path to the jar is out of question!).

Categories