Google Appengine Deploy Error - com.google.inject.OutOfScopeException - google-app-engine

I'm trying to deploy appengine, but I'm seeing this error in the logs:
Uncaught exception from servlet
com.google.inject.ProvisionException: Unable to provision, see the following errors:
1) Error in custom provider, com.google.inject.OutOfScopeException: Cannot access scoped [sc.analysis.metrics.Metrics]. Either we are not currently inside an HTTP Servlet request, or you may have forgotten to apply com.google.inject.servlet.GuiceFilter as a servlet filter for this request.
at sc.analysis.metrics.MetricsModule.configure(MetricsModule.java:13)
while locating sc.analysis.metrics.Metrics
at sc.geo.management.geo.api.GeoAdminAPIv2.<init>(GeoAdminAPIv2.java:124)
while locating sc.geo.management.geo.api.GeoAdminAPIv2
1 error
at com.google.inject.internal.InternalProvisionException.toProvisionException(InternalProvisionException.java:226)
at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1053)
at com.google.inject.spi.ProviderLookup$1.get(ProviderLookup.java:111)
at com.google.api.server.spi.guice.ServiceMap.get(ServiceMap.java:68)
at com.google.api.server.spi.guice.GuiceEndpointsServlet.createService(GuiceEndpointsServlet.java:36)
at com.google.api.server.spi.EndpointsServlet.createSystemService(EndpointsServlet.java:136)
at com.google.api.server.spi.EndpointsServlet.init(EndpointsServlet.java:57)
at com.google.inject.servlet.ServletDefinition.init(ServletDefinition.java:121)
at com.google.inject.servlet.ManagedServletPipeline.init(ManagedServletPipeline.java:82)
at com.google.inject.servlet.ManagedFilterPipeline.initPipeline(ManagedFilterPipeline.java:103)
at com.google.inject.servlet.GuiceFilter.init(GuiceFilter.java:220)
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:140)
at org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$0(ServletHandler.java:731)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:742)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:755)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:379)
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1449)
at com.google.apphosting.runtime.jetty94.AppEngineWebAppContext.startWebapp(AppEngineWebAppContext.java:274)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1414)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:916)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:288)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:524)
at com.google.apphosting.runtime.jetty94.AppEngineWebAppContext.doStart(AppEngineWebAppContext.java:218)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
at com.google.apphosting.runtime.jetty94.AppVersionHandlerFactory.doCreateHandler(AppVersionHandlerFactory.java:178)
at com.google.apphosting.runtime.jetty94.AppVersionHandlerFactory.createHandler(AppVersionHandlerFactory.java:112)
at com.google.apphosting.runtime.jetty94.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:82)
at com.google.apphosting.runtime.jetty94.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:167)
at com.google.apphosting.runtime.RequestRunner.dispatchServletRequest(RequestRunner.java:264)
at com.google.apphosting.runtime.RequestRunner.dispatchRequest(RequestRunner.java:229)
at com.google.apphosting.runtime.RequestRunner.run(RequestRunner.java:194)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:273)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.google.inject.OutOfScopeException: Cannot access scoped [sc.analysis.metrics.Metrics]. Either we are not currently inside an HTTP Servlet request, or you may have forgotten to apply com.google.inject.servlet.GuiceFilter as a servlet filter for this request.
at com.google.inject.servlet.GuiceFilter.getContext(GuiceFilter.java:165)
at com.google.inject.servlet.GuiceFilter.getOriginalRequest(GuiceFilter.java:147)
at com.google.inject.servlet.ServletScopes$1$1.get(ServletScopes.java:107)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:39)
at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1050)
at sc.analysis.metrics.StaticMetricsHolder.get(StaticMetricsHolder.java:27)
at sc.analysis.metrics.StaticMetricsHolder.get(StaticMetricsHolder.java:19)
at sc.util.ScDatastore.findEntity(ScDatastore.java:765)
at sc.util.ScDatastore.findEntity(ScDatastore.java:747)
at sc.util.Datastore.findEntity(Datastore.java:289)
at picaboo.entity.util.RegistryEntities.findRegistryEntity(RegistryEntities.java:98)
at picaboo.entity.util.RegistryEntities.findRegistryEntity(RegistryEntities.java:94)
at picaboo.entity.util.RegistryEntities.findOrCreateRegistryEntity(RegistryEntities.java:116)
at sc.registry.RegistrySetting.getEntity(RegistrySetting.java:125)
at sc.registry.RegistrySetting.getUncachedValue(RegistrySetting.java:207)
at sc.registry.RegistrySetting.fetchLatestValue(RegistrySetting.java:186)
at sc.registry.RegistrySetting.updateIfNecessary(RegistrySetting.java:151)
at sc.registry.RegistrySetting.getValue(RegistrySetting.java:196)
at sc.registry.RegistrySetting.getValue(RegistrySetting.java:35)
at sc.registry.ConvertedSetting.reloadIfNecessary(ConvertedSetting.java:62)
at sc.registry.ConvertedSetting.getValue(ConvertedSetting.java:34)
at sc.geo.management.geo.api.AdminApiIngestion.<init>(AdminApiIngestion.java:62)
at sc.geo.management.geo.api.AdminApiIngestion.<init>(AdminApiIngestion.java:47)
at sc.geo.management.geo.api.GeoAdminAPI.<init>(GeoAdminAPI.java:327)
at sc.geo.management.geo.api.GeoAdminAPIv2.<init>(GeoAdminAPIv2.java:124)
at sc.geo.management.geo.api.GeoAdminAPIv2$$FastClassByGuice$$855da3d.newInstance(<generated>)
at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1050)
... 33 more
This error is thrown when the servlet starts.
It's always the Metrics Module, but the Metrics Module looks correct in terms of injection:
package sc.analysis.metrics;
import com.google.inject.AbstractModule;
import com.google.inject.Singleton;
import com.google.inject.servlet.RequestScoped;
public class MetricsModule extends AbstractModule {
#Override
protected void configure() {
bind(Metrics.class).to(MetricsImpl.class).in(RequestScoped.class);
bind(GlobalMetrics.class).to(GlobalMetricsImpl.class).in(Singleton.class);
requestStaticInjection(StaticMetricsHolder.class);
requestStaticInjection(StaticGlobalMetricsHolder.class);
requestStaticInjection(ScopeSafeMetricsHolder.class);
}
}
None of the other injections seem to have issues; is there sommething I'm missing? I don't know much about guice to be honest, but the code that calls the Metrics (GeoAdminAPI) uses a provider:
public class GeoAdminAPIv2 extends GeoAdminAPI {
#Inject
GeoAdminAPIv2(...,
final Provider<Metrics> metrics,
...)

Related

Camel route with Spring Batch: No JobLauncher

I'm deploying a Spring Batch job triggered by a Camel route. Here is the Spring Batch config:
#Configuration
#EnableBatchProcessing
public class JobConfig
{
...
#Bean(name = "personJob")
public Job personJob(JobCompletionNotificationListener personListener, Step personStep)
{
return jobBuilderFactory
.get(...)
.incrementer(new RunIdIncrementer())
.listener(...)
.flow(...)
.end()
.build();
}
...
The Camel route looks like this:
#ApplicationScoped
public class MyRouteBuilder extends RouteBuilder
{
#Override
public void configure() throws Exception
{
from("file://...")
...
.to("spring-batch:personJob?jobLauncherRef=jobLauncher");
}
Running the route above raises the following exception:
[ERROR] Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: spring-batch://personJob?jobLauncherRef=jobLauncher due to: No JobLauncher named jobLauncher found in the registry.
[ERROR] Caused by: java.lang.IllegalStateException: No JobLauncher named jobLauncher found in the registry."}}}}
However, the documentation clearly states:
The #EnableBatchProcessing works similarly to the other #Enable*
annotations in the Spring family. In this case, #EnableBatchProcessing
provides a base configuration for building batch jobs. Within this
base configuration, an instance of StepScope is created in addition to
a number of beans made available to be autowired:
JobRepository: bean name "jobRepository"
JobLauncher: bean name "jobLauncher"
...
So, there should be a bean named "jobLauncher" of the type JobLauncher. Why isn't it found in the registry ?
Many thanks in advance,
Seymour

RESTEasy - Stacktrace in logs when throwing WebApplicationException

I am using Resteasy 2.3.3, bundled with JBoss-AS-7.1.3. I'm trying to
throw a new WebAppliationException, and the output (to the client) seems
fine, but I'm left with an unwanted stack trace in my log. I have a few
other Exceptions mapped, and I was wondering if the mapping was somehow
causing an issue ­ trying to wrap this Exception.
Simple example:
public class SimpleService {
#GET
#Path("stuff")
public String getStuff(final #QueryParam("param1") String param1,
#QueryParam("param2") String param2) throws ActionException {
if (param1==null && param2==null) {
throw new WebApplicationException();
}
I get the following exception:
[WARN] org.jboss.resteasy.core.SynchronousDispatcher#error - failed to execute: javax.ws.rs.WebApplicationException
Any ideas what this error might mean? How I could get rid of the messages?
I stumbled across another class in the javadoc - NoLogWebApplicationException, and it says:
WebApplicationExceptions are logged by RESTEasy. Use this exception
when you don't want your exception logged
https://docs.jboss.org/resteasy/docs/2.3.3.Final/javadocs/org/jboss/resteasy/spi/NoLogWebApplicationException.html

Camel CXF throwing AssertionBuilderRegistryImpl exception

cannot figure out what is going on with this - trying to set up a route to just see cxf connect to a soap web service (I don't care about the actual data and don't expect the data to actually 'work', but it keeps throwing an exception I don't understand:
I wonder if I'm configuring it correctly.
I was thinking it might be a missing jar, but strated causing dependency conflicts when I tried to bring in other Jars
I'm using a maven dependency "camel-cxf" to load in all my jar configuration
"Reason: org.apache.cxf.bus.extension.ExtensionException: Could not load extension class org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl."
The exact error is
"Failed to create Producer for endpoint: Endpoint[cxf://http://wsf.cdyne.com/WeatherWS/Weather.asmx?dataFormat=MESSAGE&portName=WeatherSoap&serviceClass=prototypes.CxfExample%24GetWeatherInformationSoapIn&serviceName=Weather&wsdlURL=http%3A%2F%2Fwsf.cdyne.com%2FWeatherWS%2FWeather.asmx%3FWSDL]. Reason: org.apache.cxf.bus.extension.ExtensionException: Could not load extension class org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl."
The code I'm using to cause this is
camel.addComponent( "cxf", new CxfComponent() );
camel.addRoutes( new RouteBuilder() {
#Override
public void configure() throws Exception {
from( "timer://sometimer?delay=1s")
.to( "cxf://http://wsf.cdyne.com/WeatherWS/Weather.asmx"
+"?wsdlURL=http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"
+"&dataFormat=MESSAGE"
+"&serviceClass=prototypes.CxfExample$GetWeatherInformationSoapIn"
+"&serviceName=Weather"
+"&portName=WeatherSoap"
);
}
});
camel.start();
Thread.sleep( 10000 );
camel.stop();
I think I have 'solved' it -
mvn:camel-cfx dependency is not enough
you need mvn:neethi dependency too
the AssertationBuildImpl class extends from a class that is not included in the jar-set for mvn:camel-cfx, which makes AssertationBuildImpl appear listed as a known class in the ide, but doesn't get class-loaded at runtime
this was a horrendous problem to track down, by analysing source-code of third-parties

GWT RequestFactory occasionally Illegal Argument Exception

I'm giving the first steps with the GWT Request Factory and I'm having an occasionally exception. What I find strange is that it doesn't happen in every server request...just sometimes.
The exception is:
> Caused by: java.lang.IllegalArgumentException: Something other than a Java object was returned from JSNI method
> '#com.google.web.bindery.autobean.gwt.client.impl.JsniCreatorMap::invoke(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/Object;Ljava/lang/Object;)':
> JS value of type boolean, expected java.lang.Object
I get an error when I call:
> Request<List<ConcertProxy>> findAll();
Which is implemented like this:
public static List<Concert> findAll()
{
Objectify ofy = ObjectifyService.begin();
List<Concert> concerts = ofy.query(Concert.class).limit(100).order("-id").list();/* this dumps to memory */
return concerts;
}
Nothing to do with RequestFactory, this is a Chrome DevMode Plugin bug. Google recommends using Firefox (or IE) for DevMode: http://code.google.com/p/google-web-toolkit/issues/detail?id=5778#c65

Catch-All global exception handler in App Engine for Python

Is it possible to create a catch-all global exception handler in Google App Engine using Python?
Basically, I want to catch all un-caught exceptions and gracefully handle it, while sending an email with the traceback to me.
Currently, for all uncaught errors, the users see a stacktrace with a snippet of code in it. This is undesirable.
Yes it is possible.
You can do it using the ereporter package that allows to receive exception reports from your application by email.
Ereporter will report two kind of exceptions:
exceptions logged with logging.exception('Your handled exception')
any uncaught exceptions
To catch all the exceptions, I would create a custom BaseHandler class overriding the handle_exception() method; all your request handlers should inherit from this Base class.
Have a look to Custom Error Responses too.
Here is a simple example of BaseHandler class:
class BaseHandler(webapp.RequestHandler):
def handle_exception(self, exception, debug_mode):
if debug_mode:
webapp.RequestHandler.handle_exception(self, exception, debug_mode)
else:
logging.exception(exception)
self.error(500)
self.response.out.write(template.render('templdir/error.html', {}))
You might want to call the original handle_exception by calling the following in your BaseHandler:
webapp.RequestHandler.handle_exception(self, exception, debug_mode)
Here it is in context.
from google.appengine.ext import webapp
import sys
import traceback
class BaseHandler(webapp.RequestHandler):
def handle_exception(self, exception, debug_mode):
from main import emaildevs
emaildevs('An error occurred on example.com', ''.join(traceback.format_exception(*sys.exc_info())))
webapp.RequestHandler.handle_exception(self, exception, debug_mode)
try:
call
except:
sendemail
http://docs.python.org/tutorial/errors.html

Resources