Guice JPA + HIbernate

37 views
Skip to first unread message

Ronak Patel

unread,
Jul 2, 2009, 4:50:20 PM7/2/09
to guiceyfruit
HI,

How do I use Guiceyfruit's JPA support with Hibernate??

I can't seem to find anything written about it on your website....

Thanks!!

Ronak Patel

Ronak Patel

unread,
Jul 14, 2009, 9:43:53 PM7/14/09
to guiceyfruit
So, all I ever get is:

[#|2009-07-14T18:08:56.958-0700|SEVERE|sun-appserver2.1|
javax.enterprise.system.container.web|
_ThreadID=25;_ThreadName=Thread-262;_RequestID=aed4d972-
e489-42c7-9f4b-1920de37a62f;|WebModule[/afe.service-1.0]PWC1275:
Exception sending context initialized event to listener instance of
class com.sun.xml.ws.transport.http.servlet.WSServletContextListener
com.sun.xml.ws.transport.http.servlet.WSServletException: WSSERVLET11:
failed to parse runtime descriptor:
com.google.inject.CreationException: Guice creation errors:

1) No implementation for javax.persistence.EntityManager was bound.
while locating
com.google.inject.Provider<javax.persistence.EntityManager>
for parameter 0 at
org.guiceyfruit.jpa.support.PersistenceMemberProvider.<init>
(PersistenceMemberProvider.java:44)
while locating org.guiceyfruit.jpa.support.PersistenceMemberProvider

1 error
at
com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized
(WSServletContextListener.java:118)
at org.apache.catalina.core.StandardContext.listenerStart
(StandardContext.java:4632)
at org.apache.catalina.core.StandardContext.start
(StandardContext.java:5312)
at com.sun.enterprise.web.WebModule.start(WebModule.java:353)
at org.apache.catalina.core.ContainerBase.addChildInternal
(ContainerBase.java:989)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
973)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:
704)
at com.sun.enterprise.web.WebContainer.loadWebModule
(WebContainer.java:1627)
at com.sun.enterprise.web.WebContainer.loadWebModule
(WebContainer.java:1232)
at
com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed
(WebModuleDeployEventListener.java:182)
at
com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed
(WebModuleDeployEventListener.java:278)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.invokeModuleDeployEventListener
(AdminEventMulticaster.java:1005)
at
com.sun.enterprise.admin.event.AdminEventMulticaster.handleModuleDeployEvent
(AdminEventMultic

When I have the following Guice Module:

public class ServiceModule extends AbstractModule {

private static final Logger logger = Logger.getLogger
(ServiceModule.class);

/* (non-Javadoc)
* @see com.google.inject.AbstractModule#configure()
*/
@Override
protected void configure() {

ServiceModule.logger.info("AFE Service: Configure Start
Initialization Commencing...");
final long now = System.currentTimeMillis();

//Install the JPA and JSR-250 modules
this.install(new JpaModule());

//Install Hibernate as the JPA Provider
this.bind(PersistenceProvider.class).to(HibernatePersistence.class);
}
}

How do I use Guiceyfruit with JPA here?? If I don't get an answer...I
will have to switch to Spring Framework to get this to work
correctly....

James Strachan

unread,
Jul 15, 2009, 10:10:48 AM7/15/09
to guice...@googlegroups.com
I think you need to register a EntityManager instead?

I've hacked the test case for JPA to show how you could register an
EntityManagerFactory instance object; then a provider method to use it
to create the EntityManager objects (the method annotated with
@Provides).

http://code.google.com/p/guiceyfruit/source/browse/trunk/guiceyfruit-jpa/src/test/java/org/guiceyfruit/jpa/InjectionTest.java

Does that help? The only change from the JpaModule used in this test
case should be a different instance of the EntityManagerFactory

2009/7/15 Ronak Patel <rona...@gmail.com>:
--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Ronak Patel

unread,
Jul 21, 2009, 4:03:08 PM7/21/09
to guiceyfruit
James,

When I try to register Hibernate using Hibernate EntityManager's
EntityManagerImpl.class, Guiceyfruit complains that EntityManagerImpl
does not have a default constructor...which it does not....

What do I do then? I don't control Hibernate nor want to....(I've
spent many hours frustrated with this...as I'm sure you can tell....)

On Jul 15, 7:10 am, James Strachan <james.strac...@gmail.com> wrote:
> I think you need to register a EntityManager instead?
>
> I've hacked the test case for JPA to show how you could register an
> EntityManagerFactory instance object; then a provider method to use it
> to create the EntityManager objects (the method annotated with
> @Provides).
>
> http://code.google.com/p/guiceyfruit/source/browse/trunk/guiceyfruit-...
>
> Does that help? The only change from the JpaModule used in this test
> case should be a different instance of the EntityManagerFactory
>
> 2009/7/15 Ronak Patel <ronak2...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages