You're probably getting this error because you haven't called

     install(new JpaPersistModule("eventosImpa"));

before binding any other classes that require an EntityManager. Just
move it to the top of your configure() method:

See "Web Environments" in:
http://code.google.com/p/google-guice/wiki/JPA



On 4 July 2011 01:06, Gabriel Cardelli
<[email protected]> wrote:
> I'm trying execute Guice + JPA but i get an error:
>
> com.google.inject.ProvisionException: Guice provision errors:
>
> 1) Error in custom provider, java.lang.NullPointerException
>   while locating com.google.inject.persist.jpa.JpaPersistService
>   while locating javax.persistence.EntityManager
>

>
> public class GuiceServletConfig extends GuiceServletContextListener {
>
>     @Override
>     protected Injector getInjector() {
>         Injector i = Guice.createInjector(new ServletModule() {
>
>             @Override
>             protected void configureServlets() {
>                 // Bind classes
>                 bind(PerRequestResource.class);
>                 bind(EventoWS.class);
>                 bind(EventoService.class).to(EventoServiceImpl.class);
>                 bind(EventoDAO.class).to(EventoDAOImpl.class);
>                 bind(Principal.class).toProvider(PrincipalProvider.class);
>                 bind(SecurityContext.class).to(MySecurityContext.class);
>
>                 install(new JpaPersistModule("eventosImpa"));
>                 serve("/*").with(GuiceContainer.class);
>
>
>             }
>         });
>
>
>         return i;
>     }
> }
>
> DAO:
>
> public class EventoDAOImpl implements EventoDAO {
>
>       private final transient Logger log = 
> Logger.getLogger(EventoDAOImpl.class);
>       
>
>       @Inject private Provider<EntityManager> entityManager;
>       
>       public EntityManager save(Evento object) {
>               return entityManager.get();
>       }
>
> }
>
> The method save return an error.
>
> Thnks
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-guice/-/LvUn4p3OVkYJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>

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

Reply via email to