Back Forum Reply New

Spring + JPA persistence unit not found error

Hi

I am trying to use JPA with Spring framework for web services. I am having an error since 3 days.
Code:
ERROR [org..web.context.ContextLoader] - lt;Context initialization failedgt;

org..beans.factory.BeanCreationException: Error creating bean with name 'myEntityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No persistence unit with name 'mypersistenceunit' found ...............................

here are my configurations
I have persistence.XML under META-INF
applicationContext.xml, my-ws-servlet.xml under WEB-INF

in application contextc i am defining a bean like thisCode:lt;bean id=quot;myEntityManagerFactoryquot;       class=quot;org..orm.jpa.LocalContainerEntityManagerFactoryBeanquot;gt;       lt;property name=quot;persistenceUnitManagerquot; ref=quot;persistenceUnitManagerquot; /gt;       lt;property name=quot;persistenceUnitNamequot; value=quot;mypersistenceunitquot; /gt;       lt;property name=quot;persistenceXmlLocationquot; value=quot;classpath:META-INF/persistence.xmlquot; /gt;          lt;property name=quot;jpaVendorAdapterquot;gt;lt;bean    class=quot;org..orm.jpa.vendor.HibernateJpaVendorAdapterquot;gt;    lt;property name=quot;databasequot; value=quotOSTGRESQLquot; /gt;    lt;property name=quot;showSqlquot; value=quot;truequot; /gt;lt;/beangt;       lt;/propertygt;                 lt;/beangt;
and here is my maven dependencied list

Code:
lt;dependencygt;  lt;groupIdgt;org.hibernatelt;/groupIdgt;  lt;artifactIdgt;hibernate-entitymanagerlt;/artifactIdgt;  lt;versiongt;3.3.1.galt;/versiongt;
lt;/dependencygt;

lt;dependencygt;       lt;groupIdgt;org.hibernatelt;/groupIdgt;       lt;artifactIdgt;hibernate-c3p0lt;/artifactIdgt;       lt;versiongt;3.3.1.GAlt;/versiongt;   lt;/dependencygt;

lt;dependencygt;  lt;groupIdgt;concurrentlt;/groupIdgt;
lt;artifactIdgt;concurrentlt;/artifactIdgt;
lt;versiongt;1.3.4lt;/versiongt;   lt;/dependencygt;      lt;dependencygt;
lt;groupIdgt;org.lt;/groupIdgt;
lt;artifactIdgt;spring-webmvclt;/artifactIdgt;
lt;versiongt;2.5.6lt;/versiongt;
lt;/dependencygt;

lt;dependencygt;
lt;groupIdgt;org.lt;/groupIdgt;
lt;artifactIdgt;spring-weblt;/artifactIdgt;
lt;versiongt;2.5.6lt;/versiongt;
lt;/dependencygt;
i tried different methods but did not find any solution yet. currently when i try to deploy the service on tomcat 5.5.28 it gives an error quot;FAIL - Application at context path /myService could not be startedquot; and after reading the log files i found that the problem is due to persistence.xml

any solution please

i also added the following dependency   lt;dependencygt;   lt;groupIdgt;javax.persistencelt;/groupIdgt;   lt;artifactIdgt;persistence-apilt;/artifactIdgt;   lt;versiongt;1.0lt;/versiongt;
lt;/dependencygt;

but not working yet

When you open your persistence.xml file you find lt;persistence-unit name=quot;somethingquot;gt; , please make sure that the value that you mentioned for name (name=quot;somethingquot;) matches with entitymanager's persistenceUnitName value.
¥
Back Forum Reply New