You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by pablo fernandez <fe...@gmail.com> on 2009/07/01 21:49:08 UTC
Re: OAuthDataStore Guice Injection Problem
Guys,
Thanks for your insight I finally solved the issue.
Regards
Pablo
On Tue, Jun 30, 2009 at 9:41 AM, pablo fernandez <fernandezpablo85@gmail.com
> wrote:
> Paul,
>
> I've set a breakpoint and I can positively say that GuiceModule gets
> injected.
>
> Viggo,
>
> I've read your post, but for laboral reasons I need to learn shindig in
> order to join a team that will integrate a product with opensocial (via
> shindig), Im deffinetly checking socialsite for insight though.
>
> Thanks for the replies, any idea is appreciated
>
>
> On Tue, Jun 30, 2009 at 8:51 AM, Paul Lindner <li...@inuus.com> wrote:
>
>> Are you sure that org.self.guice.modules.GuiceModule is getting injected?
>> Perhaps add some debugging code to GuiceModule.configure() to insure that
>> your bindings are being created?
>>
>> On Mon, Jun 29, 2009 at 7:12 PM, pablo fernandez <
>> fernandezpablo85@gmail.com
>> > wrote:
>>
>> > Paul,
>> >
>> > I did that, just modifiying the module to implement PersonService by my
>> > own,
>> > this is the module I used:
>> >
>> > package org.self.guice.modules;
>> >
>> > public class SampleModule extends SocialApiGuiceModule {
>> >
>> > @Override
>> > protected void configure() {
>> > super.configure();
>> >
>> > bind(String.class).annotatedWith(Names.named("
>> > shindig.canonical.json.db"))
>> > .toInstance("sampledata/canonicaldb.json");
>> > bind(ActivityService.class).to(JsonDbOpensocialService.class);
>> > bind(AppDataService.class).to(JsonDbOpensocialService.class);
>> > bind(PersonService.class).to(PersonServiceImpl.class);
>> >
>> > bind(OAuthDataStore.class).to(SampleOAuthDataStore.class);
>> >
>> > // We do this so that jsecurity realms can get access to the
>> > jsondbservice singleton
>> > requestStaticInjection(SampleRealm.class);
>> > }
>> >
>> > @Override
>> > protected Set<Object> getHandlers() {
>> > ImmutableSet.Builder<Object> handlers = ImmutableSet.builder();
>> > handlers.addAll(super.getHandlers());
>> > handlers.add(SampleContainerHandler.class);
>> > return handlers.build();
>> > }
>> >
>> > }
>> >
>> > The error is the same as before.
>> >
>> > What am I doing wrong?
>> >
>> > On Mon, Jun 29, 2009 at 2:06 PM, Paul Lindner <li...@inuus.com>
>> wrote:
>> >
>> > > I'd make a copy of SampleModule.java and use that instead of the
>> method
>> > > outlined below (where you extend SocialApiGuiceModule..)
>> > >
>> > > On Mon, Jun 29, 2009 at 6:55 AM, pablo fernandez <
>> > > fernandezpablo85@gmail.com
>> > > > wrote:
>> > >
>> > > > Hi,
>> > > >
>> > > > I'm developing a shinding database backed site. I downloaded shindig
>> > for
>> > > > Java recently, and tried to modify the code in order to make it work
>> > with
>> > > a
>> > > > different data store.
>> > > >
>> > > > I started small, implementing just PersonService, but I always get
>> this
>> > > > exception:
>> > > >
>> > > > com.google.inject.CreationException: Guice configuration errors:
>> > > >
>> > > > 1) Error at
>> > > >
>> > > >
>> > >
>> >
>> org.apache.shindig.social.core.oauth.OAuthAuthenticationHandler.<init>(OAuthAuthenticationHandler.java:64):
>> > > > Error while injecting at
>> > > >
>> > > >
>> > >
>> >
>> org.apache.shindig.social.core.oauth.AuthenticationHandlerProvider.<init>(AuthenticationHandlerProvider.java:36):
>> > > > Binding to org.apache.shindig.social.opensocial.oauth.OAuthDataStore
>> > not
>> > > > found. No bindings to that type were found.
>> > > >
>> > > > 1 error[s]
>> > > > at
>> com.google.inject.BinderImpl.createInjector(BinderImpl.java:277)
>> > > > at com.google.inject.Guice.createInjector(Guice.java:79)
>> > > > at
>> > > >
>> > > >
>> > >
>> >
>> org.apache.shindig.common.servlet.GuiceServletContextListener.contextInitialized(GuiceServletContextListener.java:64)
>> > > > at
>> > > >
>> > > >
>> > >
>> >
>> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
>> > > > at
>> > > >
>> >
>> org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
>> > > > at
>> > > >
>> > > >
>> > >
>> >
>> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
>> > > > at
>> > > >
>> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
>> > > > at
>> > > org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
>> > > > at
>> > > org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:850)
>> > > > at
>> > > >
>> org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:724)
>> > > > at
>> > > >
>> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:493)
>> > > > at
>> > org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
>> > > > at
>> > > >
>> > >
>> >
>> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
>> > > > at
>> > > >
>> > > >
>> > >
>> >
>> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
>> > > > at
>> > > org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
>> > > > at
>> > org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
>> > > > at
>> > > org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
>> > > > at
>> > > >
>> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
>> > > > at
>> > > >
>> > org.apache.catalina.core.StandardService.start(StandardService.java:516)
>> > > > at
>> > > >
>> org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
>> > > > at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
>> > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> > > > at
>> > > >
>> > > >
>> > >
>> >
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> > > > at
>> > > >
>> > > >
>> > >
>> >
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> > > > at java.lang.reflect.Method.invoke(Method.java:585)
>> > > > at
>> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
>> > > > at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
>> > > >
>> > > > My GuiceModule is this (note that OAuthDataStore is declared):
>> > > >
>> > > > public class GuiceModule extends SocialApiGuiceModule {
>> > > >
>> > > > protected void configure(){
>> > > > super.configure();
>> > > >
>> > > >
>> > >
>> >
>> bind(String.class).annotatedWith(Names.named("shindig.canonical.json.db"))
>> > > > .toInstance("sampledata/canonicaldb.json");
>> > > >
>> > > >
>> >
>> bind(PersonService.class).to(org.self.opensocial.PesonServiceImpl.class);
>> > > >
>> > > > bind(OAuthDataStore.class).to(SampleOAuthDataStore.class);
>> > > > }
>> > > >
>> > > > }
>> > > >
>> > > > and here's the web.xml that loads all modules:
>> > > >
>> > > > <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> > > > xmlns="http://java.sun.com/xml/ns/javaee"
>> > > > xmlns:web="
>> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
>> > > > xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
>> > > > http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
>> > > > id="Shindig"
>> > > > version="2.5">
>> > > > <!-- configuration -->
>> > > > <!-- If you have your own Guice module(s), put them here as a
>> > > > colon-separated list. -->
>> > > > <context-param>
>> > > > <param-name>guice-modules</param-name>
>> > > > <param-value>
>> > > > org.apache.shindig.common.PropertiesModule:
>> > > > org.apache.shindig.gadgets.oauth.OAuthModule:
>> > > > org.self.guice.modules.GuiceModule
>> > > > </param-value>
>> > > > </context-param>
>> > > >
>> > > > <filter>
>> > > > <filter-name>authFilter</filter-name>
>> > > >
>> > > >
>> > > >
>> > >
>> >
>> <filter-class>org.apache.shindig.auth.AuthenticationServletFilter</filter-class>
>> > > > </filter>
>> > > >
>> > > > <filter-mapping>
>> > > > <filter-name>authFilter</filter-name>
>> > > > <url-pattern>/social/*</url-pattern>
>> > > > </filter-mapping>
>> > > >
>> > > > <listener>
>> > > >
>> > > >
>> > > >
>> > >
>> >
>> <listener-class>org.apache.shindig.common.servlet.GuiceServletContextListener</listener-class>
>> > > > </listener>
>> > > >
>> > > > <!-- Serve social REST api -->
>> > > > <servlet>
>> > > > <servlet-name>socialRestapiServlet</servlet-name>
>> > > > <servlet-class>
>> > > > org.apache.shindig.protocol.DataServiceServlet
>> > > > </servlet-class>
>> > > > <init-param>
>> > > > <param-name>handlers</param-name>
>> > > > <param-value>org.apache.shindig.social.handlers</param-value>
>> > > > </init-param>
>> > > > </servlet>
>> > > >
>> > > > <!-- Serve social RPC api -->
>> > > > <servlet>
>> > > > <servlet-name>socialJsonRpcServlet</servlet-name>
>> > > > <servlet-class>
>> > > > org.apache.shindig.protocol.JsonRpcServlet
>> > > > </servlet-class>
>> > > > <init-param>
>> > > > <param-name>handlers</param-name>
>> > > > <param-value>org.apache.shindig.social.handlers</param-value>
>> > > > </init-param>
>> > > > </servlet>
>> > > >
>> > > > <servlet-mapping>
>> > > > <servlet-name>socialRestapiServlet</servlet-name>
>> > > > <url-pattern>/social/rest/*</url-pattern>
>> > > > </servlet-mapping>
>> > > >
>> > > > <servlet-mapping>
>> > > > <servlet-name>socialJsonRpcServlet</servlet-name>
>> > > > <url-pattern>/social/rpc/*</url-pattern>
>> > > > </servlet-mapping>
>> > > > </web-app>
>> > > >
>> > > >
>> > > > Any ideas why this happens? If you need further info on my
>> > > > configuration/code please ask!
>> > > >
>> > > > Thanks in advance
>> > > > --
>> > > > Fernandez, Pablo.
>> > > >
>> > >
>> >
>> >
>> >
>> > --
>> > Fernandez, Pablo.
>> >
>>
>
>
>
> --
> Fernandez, Pablo.
>
--
Fernandez, Pablo.
Re: OAuthDataStore Guice Injection Problem
Posted by Hafiz A Haq <ha...@gmail.com>.
Hi Pablo,
I would appreciate if you could share how you solved this issue.
Thanks and Regards,
Hafiz
2009/7/2 pablo fernandez <fe...@gmail.com>
> Guys,
>
> Thanks for your insight I finally solved the issue.
>
> Regards
> Pablo
>
> On Tue, Jun 30, 2009 at 9:41 AM, pablo fernandez <
> fernandezpablo85@gmail.com
> > wrote:
>
> > Paul,
> >
> > I've set a breakpoint and I can positively say that GuiceModule gets
> > injected.
> >
> > Viggo,
> >
> > I've read your post, but for laboral reasons I need to learn shindig in
> > order to join a team that will integrate a product with opensocial (via
> > shindig), Im deffinetly checking socialsite for insight though.
> >
> > Thanks for the replies, any idea is appreciated
> >
> >
> > On Tue, Jun 30, 2009 at 8:51 AM, Paul Lindner <li...@inuus.com> wrote:
> >
> >> Are you sure that org.self.guice.modules.GuiceModule is getting
> injected?
> >> Perhaps add some debugging code to GuiceModule.configure() to insure
> that
> >> your bindings are being created?
> >>
> >> On Mon, Jun 29, 2009 at 7:12 PM, pablo fernandez <
> >> fernandezpablo85@gmail.com
> >> > wrote:
> >>
> >> > Paul,
> >> >
> >> > I did that, just modifiying the module to implement PersonService by
> my
> >> > own,
> >> > this is the module I used:
> >> >
> >> > package org.self.guice.modules;
> >> >
> >> > public class SampleModule extends SocialApiGuiceModule {
> >> >
> >> > @Override
> >> > protected void configure() {
> >> > super.configure();
> >> >
> >> > bind(String.class).annotatedWith(Names.named("
> >> > shindig.canonical.json.db"))
> >> > .toInstance("sampledata/canonicaldb.json");
> >> > bind(ActivityService.class).to(JsonDbOpensocialService.class);
> >> > bind(AppDataService.class).to(JsonDbOpensocialService.class);
> >> > bind(PersonService.class).to(PersonServiceImpl.class);
> >> >
> >> > bind(OAuthDataStore.class).to(SampleOAuthDataStore.class);
> >> >
> >> > // We do this so that jsecurity realms can get access to the
> >> > jsondbservice singleton
> >> > requestStaticInjection(SampleRealm.class);
> >> > }
> >> >
> >> > @Override
> >> > protected Set<Object> getHandlers() {
> >> > ImmutableSet.Builder<Object> handlers = ImmutableSet.builder();
> >> > handlers.addAll(super.getHandlers());
> >> > handlers.add(SampleContainerHandler.class);
> >> > return handlers.build();
> >> > }
> >> >
> >> > }
> >> >
> >> > The error is the same as before.
> >> >
> >> > What am I doing wrong?
> >> >
> >> > On Mon, Jun 29, 2009 at 2:06 PM, Paul Lindner <li...@inuus.com>
> >> wrote:
> >> >
> >> > > I'd make a copy of SampleModule.java and use that instead of the
> >> method
> >> > > outlined below (where you extend SocialApiGuiceModule..)
> >> > >
> >> > > On Mon, Jun 29, 2009 at 6:55 AM, pablo fernandez <
> >> > > fernandezpablo85@gmail.com
> >> > > > wrote:
> >> > >
> >> > > > Hi,
> >> > > >
> >> > > > I'm developing a shinding database backed site. I downloaded
> shindig
> >> > for
> >> > > > Java recently, and tried to modify the code in order to make it
> work
> >> > with
> >> > > a
> >> > > > different data store.
> >> > > >
> >> > > > I started small, implementing just PersonService, but I always get
> >> this
> >> > > > exception:
> >> > > >
> >> > > > com.google.inject.CreationException: Guice configuration errors:
> >> > > >
> >> > > > 1) Error at
> >> > > >
> >> > > >
> >> > >
> >> >
> >>
> org.apache.shindig.social.core.oauth.OAuthAuthenticationHandler.<init>(OAuthAuthenticationHandler.java:64):
> >> > > > Error while injecting at
> >> > > >
> >> > > >
> >> > >
> >> >
> >>
> org.apache.shindig.social.core.oauth.AuthenticationHandlerProvider.<init>(AuthenticationHandlerProvider.java:36):
> >> > > > Binding to
> org.apache.shindig.social.opensocial.oauth.OAuthDataStore
> >> > not
> >> > > > found. No bindings to that type were found.
> >> > > >
> >> > > > 1 error[s]
> >> > > > at
> >> com.google.inject.BinderImpl.createInjector(BinderImpl.java:277)
> >> > > > at com.google.inject.Guice.createInjector(Guice.java:79)
> >> > > > at
> >> > > >
> >> > > >
> >> > >
> >> >
> >>
> org.apache.shindig.common.servlet.GuiceServletContextListener.contextInitialized(GuiceServletContextListener.java:64)
> >> > > > at
> >> > > >
> >> > > >
> >> > >
> >> >
> >>
> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
> >> > > > at
> >> > > >
> >> >
> >>
> org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
> >> > > > at
> >> > > >
> >> > > >
> >> > >
> >> >
> >>
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
> >> > > > at
> >> > > >
> >> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
> >> > > > at
> >> > >
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
> >> > > > at
> >> > >
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:850)
> >> > > > at
> >> > > >
> >> org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:724)
> >> > > > at
> >> > > >
> >> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:493)
> >> > > > at
> >> > org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
> >> > > > at
> >> > > >
> >> > >
> >> >
> >>
> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
> >> > > > at
> >> > > >
> >> > > >
> >> > >
> >> >
> >>
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
> >> > > > at
> >> > >
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
> >> > > > at
> >> > org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
> >> > > > at
> >> > >
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> >> > > > at
> >> > > >
> >> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
> >> > > > at
> >> > > >
> >> >
> org.apache.catalina.core.StandardService.start(StandardService.java:516)
> >> > > > at
> >> > > >
> >> org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
> >> > > > at
> org.apache.catalina.startup.Catalina.start(Catalina.java:583)
> >> > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >> > > > at
> >> > > >
> >> > > >
> >> > >
> >> >
> >>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >> > > > at
> >> > > >
> >> > > >
> >> > >
> >> >
> >>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> > > > at java.lang.reflect.Method.invoke(Method.java:585)
> >> > > > at
> >> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
> >> > > > at
> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
> >> > > >
> >> > > > My GuiceModule is this (note that OAuthDataStore is declared):
> >> > > >
> >> > > > public class GuiceModule extends SocialApiGuiceModule {
> >> > > >
> >> > > > protected void configure(){
> >> > > > super.configure();
> >> > > >
> >> > > >
> >> > >
> >> >
> >>
> bind(String.class).annotatedWith(Names.named("shindig.canonical.json.db"))
> >> > > > .toInstance("sampledata/canonicaldb.json");
> >> > > >
> >> > > >
> >> >
> >>
> bind(PersonService.class).to(org.self.opensocial.PesonServiceImpl.class);
> >> > > >
> >> > > > bind(OAuthDataStore.class).to(SampleOAuthDataStore.class);
> >> > > > }
> >> > > >
> >> > > > }
> >> > > >
> >> > > > and here's the web.xml that loads all modules:
> >> > > >
> >> > > > <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >> > > > xmlns="http://java.sun.com/xml/ns/javaee"
> >> > > > xmlns:web="
> >> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
> >> > > > xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
> >> > > > http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
> >> > > > id="Shindig"
> >> > > > version="2.5">
> >> > > > <!-- configuration -->
> >> > > > <!-- If you have your own Guice module(s), put them here as a
> >> > > > colon-separated list. -->
> >> > > > <context-param>
> >> > > > <param-name>guice-modules</param-name>
> >> > > > <param-value>
> >> > > > org.apache.shindig.common.PropertiesModule:
> >> > > > org.apache.shindig.gadgets.oauth.OAuthModule:
> >> > > > org.self.guice.modules.GuiceModule
> >> > > > </param-value>
> >> > > > </context-param>
> >> > > >
> >> > > > <filter>
> >> > > > <filter-name>authFilter</filter-name>
> >> > > >
> >> > > >
> >> > > >
> >> > >
> >> >
> >>
> <filter-class>org.apache.shindig.auth.AuthenticationServletFilter</filter-class>
> >> > > > </filter>
> >> > > >
> >> > > > <filter-mapping>
> >> > > > <filter-name>authFilter</filter-name>
> >> > > > <url-pattern>/social/*</url-pattern>
> >> > > > </filter-mapping>
> >> > > >
> >> > > > <listener>
> >> > > >
> >> > > >
> >> > > >
> >> > >
> >> >
> >>
> <listener-class>org.apache.shindig.common.servlet.GuiceServletContextListener</listener-class>
> >> > > > </listener>
> >> > > >
> >> > > > <!-- Serve social REST api -->
> >> > > > <servlet>
> >> > > > <servlet-name>socialRestapiServlet</servlet-name>
> >> > > > <servlet-class>
> >> > > > org.apache.shindig.protocol.DataServiceServlet
> >> > > > </servlet-class>
> >> > > > <init-param>
> >> > > > <param-name>handlers</param-name>
> >> > > > <param-value>org.apache.shindig.social.handlers</param-value>
> >> > > > </init-param>
> >> > > > </servlet>
> >> > > >
> >> > > > <!-- Serve social RPC api -->
> >> > > > <servlet>
> >> > > > <servlet-name>socialJsonRpcServlet</servlet-name>
> >> > > > <servlet-class>
> >> > > > org.apache.shindig.protocol.JsonRpcServlet
> >> > > > </servlet-class>
> >> > > > <init-param>
> >> > > > <param-name>handlers</param-name>
> >> > > > <param-value>org.apache.shindig.social.handlers</param-value>
> >> > > > </init-param>
> >> > > > </servlet>
> >> > > >
> >> > > > <servlet-mapping>
> >> > > > <servlet-name>socialRestapiServlet</servlet-name>
> >> > > > <url-pattern>/social/rest/*</url-pattern>
> >> > > > </servlet-mapping>
> >> > > >
> >> > > > <servlet-mapping>
> >> > > > <servlet-name>socialJsonRpcServlet</servlet-name>
> >> > > > <url-pattern>/social/rpc/*</url-pattern>
> >> > > > </servlet-mapping>
> >> > > > </web-app>
> >> > > >
> >> > > >
> >> > > > Any ideas why this happens? If you need further info on my
> >> > > > configuration/code please ask!
> >> > > >
> >> > > > Thanks in advance
> >> > > > --
> >> > > > Fernandez, Pablo.
> >> > > >
> >> > >
> >> >
> >> >
> >> >
> >> > --
> >> > Fernandez, Pablo.
> >> >
> >>
> >
> >
> >
> > --
> > Fernandez, Pablo.
> >
>
>
>
> --
> Fernandez, Pablo.
>
--
He who asks is a fool for five minutes, but he who does not ask remains a
fool forever.