users@jersey.java.net

Re: [Jersey] Failure [Returned null to createEntityManagerFactory.] in CustomerDB Sample (From NB 6.0.1) on Sailfin Milestone 4 Build

From: Peter Liu <Peter.Liu_at_Sun.COM>
Date: Thu, 15 May 2008 12:43:35 -0700

That's very strange. One thing you can try is to create the customerdb
project from scratch and see if it works. Here is how:

1. Create a web project.
2. Right click on the project node and select "Entity Classes from Database"
3. In the wizard, click on the Data Source combo box and select
jdbc/sample. (The wizard should then load
the available tables into the wizard.)
4. Select CUSTOMER and DISCOUNT_CODE tables from the Available Table
list and click on Add.
5. Click on Next and in the next panel, specify a package name and then
click on the
"Create Persistence Unit" button.
6. In the "Create Persistence Unit" dialog, simply click on Create.
7. Click on Finish to generated the entity classes.
8. Right click on the project node and select "RESTful Web Services from
Entity Classes".
9. In the wizard, you should see Customer and DiscountCode entity
classes. Click on Add All.
10. Click on Next and then Finish to generated the RESTful resource classes.
11. Right click on the project node and select "Test RESTful Web Services".

Let me know if you can get this to work.

Peter

Louis Alexander wrote:
> Yes it is registered, and i have gotten it to work with one of the
> persistence examples from Carol McDonald's blog
> (http://weblogs.java.net/blog/caroljmcdonald/archive/2007/09/sample_applicat_2.html)
>
> But when it comes to RESTful web serves + Persistence, i just get that
> exception.
>
> Thanks
>
>
> On Thu, May 15, 2008 at 3:05 PM, Peter Liu <Peter.Liu_at_sun.com
> <mailto:Peter.Liu_at_sun.com>> wrote:
>
> Hi Louis,
>
> The sample project uses the sample derby database that comes with
> NB and uses the jdbc/sample datasource registered with the appserver.
> Could you check to see if this datasource is registered with your
> Sailfin instance?
>
> Peter
>
>
> Louis Alexander wrote:
>
> All,
>
> Im running NB 6.0.1 with Sailfin (essentially glassfish)
> milestone 4 build. I am having trouble getting a RESTful
> service built on top of Entity classes to work. I have no
> problem getting persistent entity beans to work in general,
> and have had success using the TopLink as the Persistence
> Provider with derby. To make sure i wasn't going insane, i
> opened the new project wizard and created an instance of the
> Samples->RESTful Web Services->Customer Database project which
> is described as "a web project containing RESTful web services
> based on entity classes generated from a customer database".
> When i built and deployed the project (after launching my
> update manager in sailfin/glassfish to ensure that there were
> no new updates to the Jersey framework) i popped open the
> RESTful Web Service Tester only to find the same exception
> that i had with my own code. Can anyone point me in the right
> direction? I have tried tweaking my persistence.xml by hand,
> as well as changing Persistence providers (but i know TopLink
> should work, it has earlier this week).
>
> Here is this exception i get, i hope it looks familiar to someone:
>
> StandardWrapperValve[ServletAdaptor]: PWC1406:
> Servlet.service() for servlet ServletAdaptor threw exception
> javax.persistence.PersistenceException: No Persistence
> provider for EntityManager named CustomerDBPU: The following
> providers:
> oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
> oracle.toplink.essentials.PersistenceProvider
> Returned null to createEntityManagerFactory.
> at
> javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:154)
> at
> javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
> at
> customerdb.service.PersistenceService.<init>(PersistenceService.java:69)
> at
> customerdb.service.PersistenceService.<init>(PersistenceService.java:55)
> at
> customerdb.service.PersistenceService$1.initialValue(PersistenceService.java:60)
> at
> customerdb.service.PersistenceService$1.initialValue(PersistenceService.java:59)
> at
> java.lang.ThreadLocal$ThreadLocalMap.getAfterMiss(ThreadLocal.java:374)
> at
> java.lang.ThreadLocal$ThreadLocalMap.get(ThreadLocal.java:347)
> at
> java.lang.ThreadLocal$ThreadLocalMap.access$000(ThreadLocal.java:225)
> at java.lang.ThreadLocal.get(ThreadLocal.java:127)
> at
> customerdb.service.PersistenceService.getInstance(PersistenceService.java:86)
> at
> customerdb.service.DiscountCodesResource.get(DiscountCodesResource.java:101)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
> com.sun.ws.rest.impl.model.method.dispatch.EntityParamDispatchProvider$TypeOutInvoker._dispatch(EntityParamDispatchProvider.java:107)
> at
> com.sun.ws.rest.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:66)
> at
> com.sun.ws.rest.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:108)
> at
> com.sun.ws.rest.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:55)
> at
> com.sun.ws.rest.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:88)
> at
> com.sun.ws.rest.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:49)
> at
> com.sun.ws.rest.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:369)
> at
> com.sun.ws.rest.spi.container.servlet.ServletContainer.service(ServletContainer.java:130)
> at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
> at
> org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
> at
> org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
> at
> org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
> at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
> at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
> at
> com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
> at
> com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
> at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
> at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
> at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
> at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
> at
> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
> at
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
> at
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
> at
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
> at
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
> at
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
> at
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
> at
> com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
> at
> com.sun.enterprise.web.connector.grizzly.WorkerThreadImpl.run(WorkerThreadImpl.java:116)
>
> --
> Thanks,
>
> Louis
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> <mailto:users-unsubscribe_at_jersey.dev.java.net>
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
> <mailto:users-help_at_jersey.dev.java.net>
>
>
>
>
> --
> Thanks,
>
> Louis