Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

persistence.xml not detected in webapp

$
0
0
Hello.

My project is composed by :

  • a backend.jar project that contains entity, dao, services
  • a webapp.war file for my webapp.


The backend is build using spring.

To use JPA, I added a persistence.xml file that looks like that :

Code:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" 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 ">
    <persistence-unit name="myUnit" transaction-type="JTA">
          <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
          <jta-data-source>db.datasource</jta-data-source>
      </persistence-unit>
</persistence>

In my spring config file, I added:

Code:

<jee:jndi-lookup id="emf" jndi-name="persistence/myUnit" />
Then I retrieve the EntityManager in my dao's with :
Code:


@PersistenceContext
private EntityManager entityManager;

When I deploy my webapp (with the backend as lib), I got this error :

Code:

Caused By: javax.naming.NameNotFoundException: While trying to lookup 'persistence.myUnit' didn't find subcontext 'persistence'. Resolved ''; remaining name 'persistence/myUnit'
        at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
        at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
        at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
        at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
        at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)
        Truncated. see log file for complete stacktrace
>

when spring wants to instantiate my DAO.

I think that it's because the persistence.xml file isn't detected.

I've try to put this file in my webapp or in my backend under /src/main/resources/META-INF.

I use Weblogic.

What do I wrong?

Can someone help me please?

Tks.

Stephane

Viewing all articles
Browse latest Browse all 297

Trending Articles