Christopher, thanks for your tips, I will check now
 *

-----------------------------------
   Gabriel Cardelli
   Software Developer
   gabrcardelli.appspot.com
*
*
-----------------------------------
*
*


*



2011/6/21 Christopher Currie <[email protected]>

> Gabriel,
>
> On github there is a minimal working Jersey + Guice application that
> might serve as a starting point for modification for your service.
>
> https://github.com/sunnygleason/j4-minimal
>
> In particular, I think that the reason your Resource class isn't
> getting injected is because you are using the Jersey ServletContainer
> as your servlet in your web.xml. Guice servlet is different; the
> request is handled at the filter level, and any servlets configured in
> the web.xml should (ideally) never be called.
>
> I think you will need, at the end of EventosModule, after the "filter"
> line, to add:
>
>   Map<String,String> jerseyParams = new HashMap<String,String>();
>   jerseyParams.put("com.sun.jersey.config.property.packages",
> "br.impa.apps.eventos.ws");
>   serve("/ws/*").with(GuiceContainer.class, jerseyParams);
>
> Also note that if you declare all of your Resource classes with
> "bind()" calls as Mischa suggests, then you don't need the
> jerseyParams argument.
>
> Please carefully read the docs on Guice Servlet:
> http://code.google.com/p/google-guice/wiki/ServletModule
>
> Good luck,
> Christopher
>
> On Tue, Jun 21, 2011 at 2:51 PM, Gabriel Cardelli
> <[email protected]> wrote:
> > Mischa Dasberg, added what you said and the error continues
> >
> > thz
> > -----------------------------------
> >    Gabriel Cardelli
> >    Software Developer
> >    gabrcardelli.appspot.com
> > -----------------------------------
> >
> >
> >
> >
> > 2011/6/21 Gabriel Cardelli <[email protected]>
> >>
> >> I have two projects, server and client.
> >>
> >> The server has the Jersey and Guice, the client has Wicket and Guice
> >> (Inject OK)
> >> I'm trying to expose my web service to be consumed by wicket
> >>
> >> The big problem is that server-side Guice does not work.
> >>
> >> When I call the web service it returns java.lang.NullPointerException
> >>          at br.impa.apps.eventos.ws.EventoWS.list (EventoWS.java: 34)
> >>
> >> Line 34 is: return eventoService.list ();
> >>
> >> eventoService should be injected by Guice but is not.
> >>
> >> Someone tell me what's going on?
> >>
> >>
> >>
> >> -----------------------------------
> >>    Gabriel Cardelli
> >>    Software Developer
> >>    gabrcardelli.appspot.com
> >> -----------------------------------
> >>
> >>
> >>
> >>
> >> 2011/6/20 Mischa Dasberg <[email protected]>
> >>>
> >>> Hi Gabriel,
> >>> Try adding the following in your Module:
> >>> bind(EventoWS.class);
> >>> That should work.
> >>> Regards,
> >>> Mischa
> >>>
> >>> On Mon, Jun 20, 2011 at 1:56 AM, Gabriel Cardelli
> >>> <[email protected]> wrote:
> >>>>
> >>>> I'm trying to set up a project
> >>>> using Google Guice 3.0 JAX-RS and Jersey 1.7 for the server
> >>>> side however google guice is not injecting any class.
> >>>> web.xml
> >>>> <?xml version="1.0" encoding="ISO-8859-1"?>
> >>>> <web-app xmlns="http://java.sun.com/xml/ns/j2ee";
> >>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >>>> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> >>>> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
> >>>> version="2.4">
> >>>> <display-name>Institucional Eventos - Wicket
> Application</display-name>
> >>>> <listener>
> >>>>
> >>>>
> <listener-class>br.impa.apps.eventos.config.servlet.listener.ImpaGuiceServletContextListener</listener-class>
> >>>> </listener>
> >>>> <servlet>
> >>>> <servlet-name>Jersey REST Service</servlet-name>
> >>>>
> >>>>
> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
> >>>> <init-param>
> >>>> <param-name>com.sun.jersey.config.property.packages</param-name>
> >>>> <param-value>br.impa.apps.eventos.ws</param-value>
> >>>> </init-param>
> >>>> <load-on-startup>1</load-on-startup>
> >>>> </servlet>
> >>>> <servlet-mapping>
> >>>> <servlet-name>Jersey REST Service</servlet-name>
> >>>> <url-pattern>/ws/*</url-pattern>
> >>>> </servlet-mapping>
> >>>> </web-app>
> >>>> ImpaGuiceServletContextListener
> >>>> public class ImpaGuiceServletContextListener extends
> >>>> GuiceServletContextListener{
> >>>> private final transient Logger log =
> >>>> Logger.getLogger(ImpaGuiceServletContextListener.class);
> >>>> @Override
> >>>> protected Injector getInjector() {
> >>>> log.info("getInject() - Executando");
> >>>> return Guice.createInjector(new EventosModule());
> >>>>
> >>>> }
> >>>> }
> >>>> EventosModule
> >>>> public class EventosModule extends ServletModule {
> >>>> private final transient Logger log =
> >>>> Logger.getLogger(EventosModule.class.getName());
> >>>> public final static String PERSISTENCE_UNIT = "eventosImpa";
> >>>> public void configureServlets() {
> >>>> log.info("Configurando Modulo - Eventos");
> >>>> final Map<String, String> params = new HashMap<String, String>();
> >>>> params.put("javax.ws.rs.Application",
> >>>> "br.impa.apps.eventos.config.module.JerseyApp");
> >>>> install(new JpaPersistModule(PERSISTENCE_UNIT));
> >>>> filter("/*").through(PersistFilter.class);
> >>>>
> >>>>
> bind(EventoService.class).to(EventoServiceImpl.class).in(Singleton.class);
> >>>> filter("/*").through(GuiceFilter.class);
> >>>> log.info("Cofigurando Modulo JPA");
> >>>> }
> >>>> }
> >>>> Web Service Rest
> >>>> @Path("/evento")
> >>>> @RequestScoped
> >>>> public class EventoWS {
> >>>> private final transient Logger log = Logger.getLogger(EventoWS.class);
> >>>> @Inject
> >>>> private EventoService eventoService;
> >>>> @GET
> >>>> @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
> >>>> public List<Evento> list() {
> >>>> log.info("Executando método list()");
> >>>> log.info("EventoService: " + eventoService );
> >>>>         return eventoService.list(null);
> >>>>     }
> >>>> public void setEventoService(EventoService eventoService) {
> >>>> this.eventoService = eventoService;
> >>>> }
> >>>> }
> >>>>
> >>>> When I try to run the web service
> >>>>  eventoService is null,
> >>>>  I am not able to understand why?
> >>>> thks all!
> >>>> Gabriel Cardelli
> >>>> Software Developer
> >>>>
> >>>>
> >>>> --
> >>>> 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.
> >>>
> >>> --
> >>> 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.
> >>
> >
> > --
> > 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.
> >
>
> --
> 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.
>
>

-- 
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