Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
638 views
in Technique[技术] by (71.8m points)

java - javax.persistence.PersistenceException : [PersistenceUnit: vodPersistenceUnit] class or package not found

I got the following error :

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

I had a look on Google and I was told to choose transaction-type=RESOURCE_LOCAL but the settings were already that way. 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>

Regards

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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

For the moment i have no idea why it fixes the issue. It is really hard to debug this spring file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...