Looking at your persistence.xml, could you update the main tag (2.0, xsd) to this and try again ?
<persistence version="2.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_2_0.xsd">
Also, this shouldn't be needed in v3 :
<property name="eclipselink.target-server" value="SunAS9"/>
I have this scenario working with the web service implemented using an @WebService pojo packaged in a WAR file as well as using a @Statetless bean.
hth,
-Alexis
On 16 mars 2010, at 09:15, glassfish_at_javadesktop.org wrote:
> Is JPA possible with Glassfish v3 web services or are there some known JPA web service examples for glassfish v3 somewhere?
>
> I find that it always gives the exception shown below, when I do the following in a web service:
>
> @PersistenceUnit(unitName = "CustomerServicePersistenceUnit")
> private EntityManagerFactory emf;
>
> then:
>
> emf.createEntityManager().find(....)
>
> with persistence.xml as follows:
>
> <?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="CustomerServicePersistenceUnit" transaction-type="JTA">
> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
> <jta-data-source>tabs/TabsPool</jta-data-source>
> <properties>
> <property name="eclipselink.target-server" value="SunAS9"/>
> <property name="eclipselink.logging.level" value="FINEST"/>
> </properties>
> </persistence-unit>
> </persistence>
>
> Here's what it does:
>
> Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Unable to retrieve EntityManagerFactory for unitName CustomerServicePersistenceUnit
> at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:171)
> at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:102)
> at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:240)
> at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:210)
> at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:103)
> at $Proxy29.getCustomerById(Unknown Source)
> at cstwsclient.Main.main(Main.java:14)
> Caused by: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName CustomerServicePersistenceUnit
> at com.sun.enterprise.container.common.impl.EntityManagerWrapper.init(EntityManagerWrapper.java:121)
> at com.sun.enterprise.container.common.impl.EntityManagerWrapper._getDelegate(EntityManagerWrapper.java:162)
> at com.sun.enterprise.container.common.impl.EntityManagerWrapper.find(EntityManagerWrapper.java:309)
> [Message sent by forum member 'dcam' (david_at_pastornet.net.au)]
>
> http://forums.java.net/jive/thread.jspa?messageID=392108
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>