Javax.persistence.PersistenceException: class or package [PersistenceUnit: vodPersistenceUnit] not found

I got the following error:

Error creating bean named 'Org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor # 0' defined in path resource of path [jpaDaoContext.xml]: Bean initialization failed; org.springframework.beans.factory.BeanCreationException nested exception: error creating a bean with the name 'vodEntityManagerFactory' defined in the class resource path [jpaDaoContext.xml]: the init method call failed; the nested exception is javax.persistence.PersistenceException: [PersistenceUnit: vodPersistenceUnit] class or package not found.

I looked at Google and I was told to select the transaction type = RESOURCE_LOCAL, but the settings were already like that. What is wrong with these settings:

<?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <!-- transaction-type is RESOURCE_LOCAL or JTA --> <persistence-unit name="vodPersistenceUnit" transaction-type="RESOURCE_LOCAL"> <class>mypackage.persistent.HistoriqueAction</class> <class>mypackage.persistent.ParametresTechniques</class> <class>mypackage.persistent.TicketType</class> <class>mypackage.persistent.TransactionType</class> <class>mypackage.persistent.StatutSession</class> <class>mypackage.persistent.Statistique</class> <class>mypackage.persistent.StatUser</class> <!-- Avoid to scan *.class and *.hbm.xml --> <exclude-unlisted-classes /> </persistence-unit> </persistence> 

Hi

+4
source share
4 answers

I fixed the problem. I had to comment on these three lines in the file "persistence.xml":

  <!--class>mypackage.persistent.TicketType</class> <class>mypackage.persistent.TransactionType</class> <class>mypackage.persistent.StatutSession</class--> 

At the moment, I have no idea why it is fixing the problem. It is very difficult to debug this spring file.

+5
source

If you needed to comment on the "class" elements, it is likely that one of these classes is either undefined or inaccessible to the class path.

I came across the same exact error, and this was resolved after the fully qualified names were correct. Ideally, Hibernate should tell you which class was not found, but unfortunately it does not do this in this case.

+3
source

You did not do this, put <property name="persistenceUnitName" value="vodPersistenceUnit" /> in your jpaDaoContext.xml as a property of your entityManagerFactory bean definition, for example:

 <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceUnitName" value="vodPersistenceUnit" /> <property name="dataSource" ref="dataSource" /> <property name="jpaVendorAdapter">...</property> </bean> 
+1
source

I came across this exception when trying to run the Spring boot application in WebLogic 12.1.3. In the dependency tree I discovered, spring -tx was included from one of the common project libraries. Our specific application only calls a web service, so there is no need to access the database. Therefore, depending on the library, I added:

 <exclusions><exclusion> <groupId>org.springframework</groupId><artifactId>spring-tx</artifactId></exclusion></exclusions> 
0
source

Source: https://habr.com/ru/post/1495283/


All Articles