I'm at wit's end.  Now the situation is that I can connect to the database 
using my persistence.xml settings when I run from my IDE (intellij.)  
Previously, I was using a properties file.  So that is a small amount of 
progress.

However, when I deploy my webservice, it accepts messages but can't connect to 
the database using the same persistence.xml file.

I asked on the Jetspeed boards and they say jetspeed does nothing that should 
inhibit the persistence. I also verified that I'm using Tomcat as my 
container.  All versions were the latest and greatest 3 weeks ago.  Java 1.6_10.

Here's my persistence.xml file:

<persistence 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";
             version="1.0">
    <persistence-unit name="Snapshot" transaction-type="RESOURCE_LOCAL">
        <!-- 
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider> 
 -->
        <!-- 
<provider>oracle.toplink.essentials.PersistenceProvider</provider>  -->
        <provider>org.hibernate.ejb.HibernatePersistence</provider>

        <mapping-file> (snip) </mapping-file>
        <class> (snip) </class>

        <properties>
            <property name="hibernate.connection.driver_class" 
value="oracle.jdbc.driver.OracleDriver"/>
            <property name="hibernate.connection.url" 
value="jdbc:oracle:thin:@(ip):1546:ESDD01"/>
            <property name="hibernate.connection.username" value="scott"/>
            <property name="hibernate.connection.password" value="tiger"/>

            <property name="hibernate.c3p0.min_size" value="5"/>
            <property name="hibernate.c3p0.max_size" value="20"/>
            <property name="hibernate.c3p0.timeout" value="1800"/>
            <property name="hibernate.c3p0.max_statements" value="50"/>
            <property name="hibernate.dialect" 
value="org.hibernate.dialect.Oracle10gDialect"/>
        </properties>
    </persistence-unit>
</persistence>

Where the IP, user, and password have been redacted and the noisy mappings 
paired back.

Here's the relevant part of the web service:

            emf = Persistence.createEntityManagerFactory("Snapshot");
            em = emf.createEntityManager();

Webservices are deployed as aar files.  This is a gussied-up jar that includes 
a services.xml file in the META-INF folder.  I added a lib directory containing 
everything the webservice needs:

aar file:
--- lib
--- --- antlr-2.7.6.jar
--- --- asm-2.2.jar
--- --- asm-attrs-2.2.jar
--- --- bsh-2.0b1.jar
--- --- c3p0-0.9.1.jar
--- --- cglib-nodep-2.2.jar
--- --- commons-collections-3.1.jar
--- --- commons-logging-1.0.4.jar
--- --- dom4j-1.6.1.jar
--- --- ehcache-1.2.3.jar
--- --- ejb3-persistence.jar
--- --- freemarker.jar
--- --- hibernate-annotations.jar
--- --- hibernate-commons-annotations.jar
--- --- hibernate-core.jar
--- --- hibernate-entitymanager.jar
--- --- hibernate-tools.jar
--- --- hibernate3.jar
--- --- javassist-3.9.0.GA.jar
--- --- jta-1.1.jar
--- --- jtidy-r8-20060801.jar
--- --- junit-4.7.jar
--- --- log4j-1.2.15.jar
--- --- ojdbc14.jar
--- --- slf4j-api-1.5.8.jar
--- --- slf4j-log4j12-1.5.8.jar
--- --- this-is-my-jar.jar
---  --- --- com
--- --- --- mycompany
--- --- --- --- mypackage
--- --- --- --- --- *.class
--- --- --- META-INF
--- --- --- --- persistence.xml
--- META-INF
--- --- services.xml


That's the aar, if it were exploded.  So you can see the aar has the lib and 
META-INF directories and nothing else.
The lib has bunch of common jars, and this-is-my-jar.jar which has a class 
files and its own META-INF.

Now I know the persistence.xml file works since it works if I don't deploy it.  
I also know I have the proper jars in my IDE.  As far as I know, I hgave copied 
them all into the aar file.  It seems to me if Tomcat can find the web service 
to run it then all those jars should be on the classpath.  I'm not too sure 
about the META-INF folder however.

I tried copying the persistence.xml file into axis2/WEB-INF/classes, 
axis2/WEB-INF/lib, and axis2/WEB-INF/conf.  Nothing changes.

I also tried putting the persistence.xml file into the root and under the com 
directory in this-is-my-jar.jar.

I have tried about 50 different things lately and *nothing* makes the web 
service behave differently.

Here's the first few lines of the exception I get in every case:

javax.persistence.PersistenceException: No Persistence provider for 
EntityManager named Snapshot
        at 
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:56)
        at 
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
        at 
com.papajohns.snapshot.webservice.SurveySubmissionWebService.getSurvey(SurveySubmissionWebService.java:66)
        at 
com.papajohns.snapshot.webservice.SurveySubmissionWebService.submitSurvey(SurveySubmissionWebService.java:39)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)


Any additional suggestions would be appreciated.


Reply via email to