Binding to Provider<EntityManager> not found

0 views
Skip to first unread message

Gili

unread,
Oct 22, 2008, 6:32:20 PM10/22/08
to warp-core
Hi,

I am having problems using warp-persist.

My web.xml contains:

<listener>
<listener-class>method.adcaster.guice.ServletContextInjector</
listener-class>
</listener>
<filter>
<filter-name>warpServletFilter</filter-name>
<filter-class>com.wideplay.warp.servlet.WebFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>warpServletFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>javax.ws.rs.core.Application</param-name>
<param-value>method.adcaster.network.Application</param-value>
</context-param>

Where ServletContextInject is defined as:

public class ServletContextInjector extends WarpServletContextListener
{
@Override
protected Injector getInjector()
{
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("moduleClass", "method.adcaster.guice.Module");

Injector injector =
Guice.createInjector(Servlets.configure().filters().filter("/
*").through(
SessionPerRequestFilter.class).servlets().
serve("/*").with(GuiceServlet.class, parameters).buildModule(),

PersistenceService.usingJpa().across(UnitOfWork.REQUEST).buildModule(),
new GuiceModule());
injector.getInstance(PersistenceService.class).start();
return injector;
}
}

But I'm getting this exception at runtime:

com.google.inject.ConfigurationException: Error at
method.adcaster.persistence.AdministratorManager.<init>(AdministratorManager.java:
28) Error while injecting at
method.adcaster.network.resources.Administrators.administratorManager(Administrators.java:
25): Binding to
com.google.inject.Provider<javax.persistence.EntityManager> not found.
No bindings to that type were found.

I find this very confusing because I copy/pasted most of this code
from another project (which works fine) and I am fairly sure that
"injector.getInstance(PersistenceService.class).start()" is working
because the line right before the above exception reads:

[EL Info]: 2008.10.22 18:26:25.200--ServerSession(1581180546)--
EclipseLink, version: Eclipse Persistence Services - 1.0.1 (Build
20080905)
[EL Info]: 2008.10.22 18:26:25.746--ServerSession(1581180546)--file:/
C:/Users/Gili/Documents/method/trunk/adcaster/Server/Netbeans6.5/build/
web/WEB-INF/classes/-AdCaster login successful

So warp-persist should have an instance of EntityManager. Any idea
what could be wrong?

Thanks,
Gili

Gili

unread,
Oct 22, 2008, 6:34:33 PM10/22/08
to warp-core
Nevermind. I think I just figured it out. GuiceServlet is an adapter I
built for Jersey (JAX-RS) so it will use Guice under the hood.
Unfortunately, warp-persist is already creating an injector so I end
up with two different instances.

I'm going to correct this by getting GuiceServlet to reuse warp-
persist's Injector instance.

Gili

Dhanji R. Prasanna

unread,
Oct 22, 2008, 6:46:39 PM10/22/08
to warp...@googlegroups.com
warp-persist does not create any injectors. None of the warp-libs do, this is always left up to the user.

You just have to install the warp-persist module in your injector config above (where you configure warp-servlet).

a simple:

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

should fix the problem.

Dhanji.

Gili

unread,
Oct 22, 2008, 6:47:44 PM10/22/08
to warp-core
Dhanji,

Is it possible to expose WarpServletContextListener.INJECTOR_NAME as
protected? Right now it's package-protected so I can't reference it,
nor can I get a handle to the servlet context from the getInjector()
method. I'm going to need one or the other to make this work.

Thanks,
Gili

Dhanji R. Prasanna

unread,
Oct 22, 2008, 7:51:18 PM10/22/08
to warp...@googlegroups.com
Done. New jar uploaded (0.9_06).

Dhanji.

Gili

unread,
Oct 22, 2008, 11:31:02 PM10/22/08
to warp-core
Thank you! :)

As a side-note, please tag future releases. I like adding library
source-codes to my application (to help debugging) and as far as I can
tell you only publish the binaries so I'd like to be able to check out
the source-code for each specific version.

Gili

On Oct 22, 7:51 pm, "Dhanji R. Prasanna" <dha...@gmail.com> wrote:
> Done. New jar uploaded (0.9_06).
> Dhanji.
>
Reply all
Reply to author
Forward
0 new messages