Thanks Adrian,
Although I may not have explained the question properly.
I am not running unit tests. Here's what happens:
Guice starts up, it runs module configuration.
While it is running module configuration, it comes across the
following:
bind(Query.class).annotatedWith(Names.named("PersonQuery"))
.toProvider(new Provider<Query>(){
@Override
public Query get() {
return new Query(Person.kind);
}
});
The problem is that the call: new Query(..) is dependent on
ApiProxy.Environment. BUT, because the Module is not a servlet, the
thread that runs it does not have an instance of ApiProxy.Environment
sent. Hence the error:
1) Error in custom provider, java.lang.NullPointerException: No API
environment is registered for this thread.
while locating com.google.appengine.api.datastore.Query annotated
with @com.google.inject.name.Named(value=PersonQuery)
What I need to do is inside the module, inside public void configure
(), something to the tune of ApiProxy.setEnvironmentForCurrentThread
(<some environment>) . This is production code, I don't know where to
get <some environment> from.
Tristan
On Nov 19, 2:01 pm, Adrian Cole <[email protected]> wrote:
> guice (even trunk) most certainly works in gae. This looks like a
> problem in your unit test. There's setup needed per gae docs.
>
> http://code.google.com/appengine/docs/java/howto/unittesting.html
>
> Cheers,
> Adrian
> jclouds
>
> On Wed, Nov 18, 2009 at 1:07 PM, Tristan <[email protected]> wrote:
> > I should clarify that the problem occurs in local Development Mode. I
> > am yet to put it on GAE itself.
>
> > On Nov 18, 2:58 pm, Tristan <[email protected]> wrote:
> >> On Google App Engine,
>
> >> When attempting to do the following in a Module:
>
> >> bind(Query.class).annotatedWith(Names.named("PersonQuery"))
> >> .toProvider(new Provider<Query>(){
> >> @Override
> >> public Query get() {
> >> return new Query(Person.kind);
> >> }
> >> });
>
> >> I get the following error:
>
> >> 1) Error in custom provider, java.lang.NullPointerException: No API
> >> environment is registered for this thread.
> >> while locating com.google.appengine.api.datastore.Query annotated
> >> with @com.google.inject.name.Named(value=PersonQuery)
>
> >> Is Guice unable to use the Google App Engine API Environment?
>
> >> -Tristan
>
> > --
>
> > 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
> > athttp://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=.