java - Error creating bean with name 'entityManagerFactory' -> Cannot parse persistence unit from class path resource [META-INF/persistence.xml] -
i have problem in j2e application , can't find solution. build successful there thrown runtime exception. tried many advices google nothing can solve problem.
severe: exception sending context initialized event listener instance of class org.springframework.web.context.contextloaderlistener org.springframework.beans.factory.beancreationexception: error creating bean name 'entitymanagerfactory' defined in servletcontext resource [/web-inf/datasource-config.xml]: invocation of init method failed; nested exception java.lang.illegalargumentexception: cannot parse persistence unit class path resource [meta-inf/persistence.xml]
entitymanagerfactory in data-source
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <bean id="datasource" class="oracle.jdbc.pool.oracledatasource" > <property name="connectioncachingenabled" value="true" /> <property name="url" value="jdbc:postgresql://localhost:5432/postgres" /> <property name="user" value="postgres" /> <property name="password" value="" /> </bean> <bean id="entitymanagerfactory" class="org.springframework.orm.jpa.localcontainerentitymanagerfactorybean"> <property name="jpavendoradapter"> <bean class="org.springframework.orm.jpa.vendor.hibernatejpavendoradapter"> <property name="showsql" value="true" /> <property name="generateddl" value="true" /> <property name="databaseplatform" value="org.hibernate.dialect.postgresqldialect" /> </bean> </property> <property name="datasource" ref="datasource" /> <property name="persistenceunitname" value="default" />
<bean id="transactionmanager" class="org.springframework.orm.jpa.jpatransactionmanager"> <property name="datasource" ref="datasource" /> <property name="entitymanagerfactory" ref="entitymanagerfactory" /> </bean> <tx:annotation-driven transaction-manager="transactionmanager" /> <bean class="org.springframework.orm.jpa.support.persistenceannotationbeanpostprocessor" />
persistence.xml
<persistence-unit name="default" transaction-type="resource_local"> <class>com.example.j2eeapp.domain.userentity</class> </persistence-unit>
firstly, java compiler not validate existence of persistence.xml during compile time. error happen @ runtime.
stack trace you're getting pretty clear, program not locate persistence.xml on classpath.
the location of persistence.xml within jar has be: meta-inf/persistence.xml, or if it's war: web-inf/classes/meta-inf/persistence.xml
Comments
Post a Comment