All persistence jars are added in
<tomcat.home>/common/lib.
After talking to Ludo, I wonder if this could be something
related to class loading.
Anyone knowing the specifics of how persistence.xml is being
loaded? (I know, I know, I should check the code myself, but in case
someone has that information handy :-))
-- Pierre
Mitesh Meswani wrote:
> Hi Pierre,
>
> Where have you put the persistence jars (javaee.jar,
> toplink-essentials.jar, asm.jar, antlr.jar)
>
> Thanks,
> Mitesh
>
> Pierre Delisle wrote:
>
>> I have been successful in running the persistence example at
>> https://glassfish.dev.java.net/javaee5/persistence/persistence-example.html
>>
>> on Java SE using the no.weaving property (so I would not have to specify
>> -javaagent).
>>
>> Now, I would like to run a very similar example (i.e. uses Persistence
>> with
>> Java SE), but within a web application in a container that is not
>> Java EE 5 compliant (e.g. Tomcat 5.5.x).
>>
>> I have persistence.xml located in WEB-INF/classes/META-INF of my webapp
>> that looks like this:
>>
>> <persistence xmlns="http://java.sun.com/xml/ns/persistence">
>> <persistence-unit name="pu1">
>>
>> <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
>>
>> <class>crud.models.Product</class>
>> <properties>
>> <property name="jdbc.driver"
>> value="org.gjt.mm.mysql.Driver"/>
>> <property name="jdbc.connection.string"
>> value="jdbc:mysql://localhost:3306/test?autoReconnect=true"/>
>> <property name="jdbc.user" value=""/>
>> <property name="jdbc.password" value=""/>
>> <property name="toplink.logging.level" value="INFO"/>
>> <property name="no.weaving" value="true"/>
>> </properties>
>> </persistence-unit>
>> </persistence>
>>
>>
>> When I run the webapp under Tomcat 5.5.7, it fails when the
>> code tries to create the EntityManagerFactory:
>>
>> javax.persistence.PersistenceException: No Persistence provider for
>> EntityManager named pu1
>>
>> javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:67)
>>
>>
>> Looks like the 'persistence.xml' descriptor is not being picked up.
>>
>> So... Where exactly is the 'persistence.xml' file supposed to be located
>> in my webapp so it can be picked up by Java Persistence?
>>
>> Thanks,
>>
>> -- Pierre
>>
>
>