Error binding PersistenceService and EntityManager (JPA)

318 views
Skip to first unread message

Kristof

unread,
Mar 3, 2010, 10:21:03 AM3/3/10
to warp-core
Hey,

I've been experimenting with this for a while, and still can't get it
working, so I was hoping to get some help. I tried following the guide
on adding JPA to my guice project, and have an architecture like the
one on the page. In my module I have:

protected void configure() {

bindConstant().annotatedWith(JpaUnit.class).to("GuiceTestPU");
bind(MIInitializer.class).asEagerSingleton();

bind(DAO.class).to(DAOImpl.class).in(Scopes.SINGLETON);

...
}

My Initializer is

public class MIInitializer {
@Inject MIInitializer(PersistenceService service) {
service.start();
}

And I have a class called DAOImpl, where I have a line:

@Inject Provider<EntityManager> em;

Now when I try to run this, I get

com.google.inject.CreationException: Guice creation errors:

1) No implementation for com.wideplay.warp.persist.PersistenceService
was bound.
while locating com.wideplay.warp.persist.PersistenceService
for parameter 0 at
hu.misoftware.guice.modules.MIInitializer.<init>(MIInitializer.java:
17)
at hu.misoftware.guice.modules.MIModule.configure(MIModule.java:28)

2) No implementation for javax.persistence.EntityManager was bound.
while locating
com.google.inject.Provider<javax.persistence.EntityManager>
for field at hu.misoftware.persistence.DAOImpl.em(DAOImpl.java:34)
at hu.misoftware.guice.modules.MIModule.configure(MIModule.java:31)


I think I have all the jars in my classpath, and the persistence.xml
is OK.

What am I doing wrong?

Any help would be appreciated.

Kristof

Dhanji R. Prasanna

unread,
Mar 3, 2010, 10:29:27 PM3/3/10
to warp...@googlegroups.com
On Thu, Mar 4, 2010 at 2:21 AM, Kristof <kr1...@gmail.com> wrote:
Hey,

I've been experimenting with this for a while, and still can't get it
working, so I was hoping to get some help. I tried following the guide
on adding JPA to my guice project, and have an architecture like the
one on the page. In my module I have:

Oh that's simple, you just need to install the WP module:
 

protected void configure() {


  install(PersistenceService.usingJpa().buildModule());
 

--
You received this message because you are subscribed to the Google Groups "warp-core" group.
To post to this group, send email to warp...@googlegroups.com.
To unsubscribe from this group, send email to warp-core+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/warp-core?hl=en.


Kristof

unread,
Mar 4, 2010, 4:47:32 AM3/4/10
to warp-core
Thanks, it's working now.
If you accept a constructive suggestion, it would be really helpful to
have a sample application on the page that one could download and try
out instead of just code snippets.
It could help a lot of folks, who are just starting out with guice and
warp. If there is one, then I'm sorry :)

On Mar 4, 4:29 am, "Dhanji R. Prasanna" <dha...@gmail.com> wrote:

> > warp-core+...@googlegroups.com<warp-core%2Bunsu...@googlegroups.com>

Reply all
Reply to author
Forward
0 new messages