Hallo,
ich habe ein kleines Problem mit EclipseLink und JPA...hoffe mir kann jemand weiter helfen
ich bekomme die folgende Fehlermeldung:
meine persistance.xml sieht wie folgt aus:
Meine Providerklasse:
danke
Andy
ich habe ein kleines Problem mit EclipseLink und JPA...hoffe mir kann jemand weiter helfen
ich bekomme die folgende Fehlermeldung:
Java:
Aug 18, 2011 9:45:06 AM com.sun.jersey.api.core.WebAppResourceConfig init
Information: Scanning for root resource and provider classes in the Web app resource paths:
/WEB-INF/lib
/WEB-INF/classes
Aug 18, 2011 9:45:07 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
Information: Root resource classes found:
class uds.web.admin.server.EmailService
Aug 18, 2011 9:45:07 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
Information: Provider classes found:
class org.codehaus.jackson.jaxrs.JacksonJsonProvider
class org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider
class org.codehaus.jackson.jaxrs.JsonMappingExceptionMapper
class org.codehaus.jackson.jaxrs.JsonParseExceptionMapper
Aug 18, 2011 9:45:07 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
Information: Initiating Jersey application, version 'Jersey: 1.8 06/24/2011 12:17 PM'
Aug 18, 2011 9:45:20 AM com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
Schwerwiegend: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
javax.persistence.PersistenceException: No Persistence provider for EntityManager named EmailService
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at uds.web.admin.server.EmailService.read(EmailService.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
meine persistance.xml sieht wie folgt aus:
Java:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<persistence-unit name="EmailService" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>uds.web.admin.server.DEmail</class>
<class>uds.web.admin.server.DUploads</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://134.96.111.19:5434/lsf-test"/>
<property name="javax.persistence.jdbc.user" value="postgres"/>
<property name="javax.persistence.jdbc.password" value="!RX300%hdb"/>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
</properties>
</persistence-unit>
</persistence>
Meine Providerklasse:
Java:
package uds.web.admin.server;
import java.util.List;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import javax.persistence.Query;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
// [url]http://localhost:8888/rest/emails/1[/url]
/**
* Session Bean implementation class EmailService
*/
@Stateless
@LocalBean
@Path("/emails")
public class EmailService {
/**
* Default constructor.
*/
public EmailService() {
}
@PersistenceContext(unitName="EmailService", type=PersistenceContextType.TRANSACTION)
private static final String PERSISTENCE_UNIT_NAME = "EmailService";
private static EntityManagerFactory factory;
@POST
@Consumes(MediaType.APPLICATION_XML)
public void create(DEmail email) {
factory = Persistence.createEntityManagerFactory( PERSISTENCE_UNIT_NAME );
EntityManager em = factory.createEntityManager();
em.persist(email);
}
@GET
@Produces(MediaType.APPLICATION_XML)
@Path("{id}")
public DEmail read(@PathParam("id") long id) {
factory = Persistence.createEntityManagerFactory( PERSISTENCE_UNIT_NAME );
EntityManager em = factory.createEntityManager();
return em.find(DEmail.class, id);
}
@GET
@Produces(MediaType.APPLICATION_XML)
@Path("readAll")
public List<DEmail> readAll(){
factory = Persistence.createEntityManagerFactory( PERSISTENCE_UNIT_NAME );
EntityManager em = factory.createEntityManager();
Query query = em.createNamedQuery("findEmails");
List<DEmail> email = query.getResultList();
System.out.println("email : "+email);
return email;
}
}
danke
Andy