Module not found when running tests in Maven
Hi, I'm trying to create a modular application for fetching articles from popular news sources in Poland. A part of the app is a module saving these articles into a database using Hibernate. I wrote a couple of tests for this module and when I run them through intellij they work just fine, but when I try to use Maven it throws errors like these:
What should I do to fix this?
Github link to the project:
https://github.com/Eukon05/infodb/tree/hibernate
The class that is responsible for these tests is "HibernateDAOTests" in the "infodb-persistence-hibernate" module
19 Replies
⌛
This post has been reserved for your question.
Hey @Eukon05! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
Can you show the dependency tree? What exactly are you starting such that you are getting the error? What is using jakarta.transaction?
I assume it's just
infodb-persistence-hibernate
?
Can you try adding jakarta.cdi as a dependency?
if you get a similar error with
jakarta.interceptor
, you might need to add that as well in a similar way
if necessary
It's because Jakarta Transaction uses Jakarta CDI but declares it as a provided
dependency: https://repo1.maven.org/maven2/jakarta/transaction/jakarta.transaction-api/2.0.1/jakarta.transaction-api-2.0.1.pomNow it went through, but then gave me another error:
Should I create another persistence.xml file in the test/resources directory?
I don't think that should be necessary
You can try specifying a
<provider>
in your persistence.xml similar to https://stackoverflow.com/a/1285436/10871900Stack Overflow
No Persistence provider for EntityManager named
I have my persistence.xml with the same name using TopLink under the META-INF directory.
Then, I have my code calling it with:
EntityManagerFactory emfdb = Persistence.createEntityManagerFactory("...
Ok, let me try that
the class name of the provider may also be
org.hibernate.jpa.HibernatePersistenceProvider
make sure the provider you are using exists
And you might also want to specify the hibernate dialect
I think it should be that oneIt didn't help, I also get a warning before the error:
WARNING: jakarta.persistence.spi::No valid providers found.
I also tried making a copy of the persistence.xml file in the test dir. but it did nothingDoes the class
org.hibernate.jpa.HibernatePersistenceProvider
exist anywhere in your dependencies?I tried to check if it's being loaded by the class loader with this in an @BeforeAll block:
But it fails and gives an error:
java.lang.IllegalAccessError: superclass access check failed: class org.jboss.logging.JBossLogRecord (in module org.jboss.logging) cannot access class java.util.logging.LogRecord (in module java.logging) because module org.jboss.logging does not read module java.logging
Can you show the full stack trace?
You can try
--add-reads org.jboss.logging=java.logging
to the JVM args when running it💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Sorry for a late response, I've just tried it and the tests went through! Thank you so much!
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@352745203322585088>.