Announcement Announcement Module
Collapse
No announcement yet.
Error: configure Could not find persistence.xml Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error: configure Could not find persistence.xml

    Hi All,

    I am trying to test the following code:
    Code:
    @Transactional
    public void updateT(Testtbl pTest) { 
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("test"); 
    EntityManager em = emf.createEntityManager();
    em.getTransaction().begin();
    em.createNativeQuery( "UPDATE Testtbl e SET e.firstName = 'xxx'").executeUpdate(); 
    em.getTransaction().commit();
    em.close();
    emf.close();
    }
    As you can see this method may update my Testbl table, but when I run the project, the websphere consol returns the following error:

    Code:
    org.hibernate.ejb.Ejb3Configuration configure Could not find any META-INF/persistence.xml file in the classpath
    The file where I configure the persistence is named META-INF/spring-persistence.xml

    my spring-persistence.xml is the following:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
    	<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
    		<!--  provider -->
    		<provider>org.hibernate.ejb.HibernatePersistence</provider>
    		<properties>
    			<property name="hibernate.show_sql" value="true"/>
    			<property name="hibernate.format_sql" value="true"/>
    			<property name="use_sql_comments" value="false"/>
    			<property name="hibernate.dialect" value="org.hibernate.dialect.InformixDialect" />
    		</properties>
    	</persistence-unit>
    </persistence>
    Any help will be greatly appreciated.
    Thanks and Regards,

    Student

  • #2
    Afaik you cannot arbitrarily name this file as it is specified to be "META-INF/persistence.xml". So I suggest giving it its default name and things should work as expected.

    Regards,
    Andreas

    Comment


    • #3
      Ok, I'll try it.
      Thanks,

      Comment

      Working...
      X