In dropdownBox I have list of pages. When I chose one I want to go to that page.
How should I implement it ? I am supposed to add this code but I don't know what should I do onUpdate. I didn't find any method to change the page
new AjaxFormComponentUpdatingBehavior() {
private static final long serialVersionUID = 1L;
#Override
protected void onUpdate(AjaxRequestTarget target) {
}
}
UPDATE:
Exception when I try first response:
29 Jun 2012 10:07:01,772 ERROR [1215661#qtp-28488784-5] org.apache.wicket.DefaultExceptionMapper : Unexpected error occurred
org.apache.wicket.WicketRuntimeException: Method onRequest of interface org.apache.wicket.behavior.IBehaviorListener targeted at cz.isvs.reg.rob.monitor.web.BasePage$1 {event='onchange'} on component [DropDownChoice [Component id = vyjimkyPage]] threw an exception
at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:270)
at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:241)
at org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:255)
at org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:234)
at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:784)
at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:255)
at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:212)
at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:283)
at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:188)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:244)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:260)
... 27 more
Caused by: java.lang.IllegalStateException: Attempt to set model object on null model of component: vyjimkyPage
at org.apache.wicket.Component.setDefaultModelObject(Component.java:3054)
at org.apache.wicket.markup.html.form.FormComponent.setModelObject(FormComponent.java:1498)
at org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:1059)
at org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior.onEvent(AjaxFormComponentUpdatingBehavior.java:154)
at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:184)
at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:369)
... 32 more
You can do something like this
protected void onUpdate(AjaxRequestTarget target){
target.prependJavaScript("window.location.href='"+urlFor(new YourPage())+'");
}
It will change the browser's url and thus redirect.
AbstractSingleSelectChoice components (the parent of DropDownChoice) cannot use the AjaxFormComponentUpdatingBehavior. The class javadoc refers you to the AjaxFormChoiceComponentUpdatingBehavior:
NOTE: This behavior does not work on Choices or Groups use the AjaxFormChoiceComponentUpdatingBehavior for that.
It's also true that you should be using a model if you use a AjaxFormChoiceComponentUpdatingBehavior as it will perform field conversion, validation, and push to the model... Keep in mind that id you don't care about the value, you can simply provide an empty model that you never read later.
Finally, in Wicket, you can do a redirect that will update the browser's url by throwing a RedirectException (a runtime exception that expects a Page class and optional PageParameters) or a RedirectToUrlException which expects a string url:
throw new RedirectToUrlException("http://www.supercoolwebsite.com/supercoolexternalpage");
vs
throw new RedirectException(SuperCoolWicketPage.class);
Related
I've got a question regarding tapestry 5.4. I try to integrate it with tynamo tapestry security and Google App Engine and after some development I started to get these exception when "something" in application is not working. I have written "something" because problem concerns ExceptionPage (as you can see on stacktrace attached below).
Has anybody faced such a problem?
Of course I can post some configuration files, but since I have no idea what can cause this exception of error page, I not posing any at the moment.
HTTP ERROR 500
Problem accessing /. Reason:
org.apache.tapestry5.internal.services.RenderQueueException: Render queue error in SetupRender[core/ExceptionReport:loop_0]: Failure reading parameter 'source' of component core/ExceptionReport:loop_0: access denied ("java.lang.RuntimePermission" "modifyThreadGroup") [at classpath:org/apache/tapestry5/corelib/pages/ExceptionReport.tml, line 110]
Caused by:
org.apache.shiro.subject.ExecutionException: org.apache.tapestry5.internal.services.RenderQueueException: Render queue error in SetupRender[core/ExceptionReport:loop_0]: Failure reading parameter 'source' of component core/ExceptionReport:loop_0: access denied ("java.lang.RuntimePermission" "modifyThreadGroup") [at classpath:org/apache/tapestry5/corelib/pages/ExceptionReport.tml, line 110]
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:385)
at org.tynamo.security.services.impl.SecurityConfiguration.service(SecurityConfiguration.java:54)
at $HttpServletRequestFilter_12a67d391b5c.service(Unknown Source)
at $HttpServletRequestHandler_12a67d391b5f.service(Unknown Source)
at org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:59)
at $HttpServletRequestHandler_12a67d391b5f.service(Unknown Source)
at org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
at $HttpServletRequestFilter_12a67d391b59.service(Unknown Source)
at $HttpServletRequestHandler_12a67d391b5f.service(Unknown Source)
at org.apache.tapestry5.modules.TapestryModule$1.service(TapestryModule.java:804)
at $HttpServletRequestHandler_12a67d391b5f.service(Unknown Source)
at $HttpServletRequestHandler_12a67d391b58.service(Unknown Source)
at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:166)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:127)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:503)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
The problem is not the exceptionpage but the way Google App Engine (GAE) implements its security policy to restrict spawning new threads. The line:
access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
in your stack trace originates from Java Security Manager for a violation of the policy. While Tynamo's tapestry-security does not invoke new threads, apparently it's not allowed to invoke Callable.call() in GAE. See how the SecurityConfiguration invokes the filter chain after binding the currently executing subject.
Callable is just an interface so it's unnecessary for GAE to prohibit an invocation to it but I suspect it was easier for them to do that than try to block executions of various Executor services that may or may not spawn threads.
However, SecurityConfiguration does not need to use Callable at all. SecurityConfiguration was implemented following Shiro's original AbstractShiroFilter, but one could also manually bind the subject to the currently executing thread, like so:
ThreadContext.bind(securityManager);
WebSubject subject = new WebSubject.Builder(securityManager, originalRequest, response).buildWebSubject();
ThreadContext.bind(subject);
try {
// return subject.execute(new Callable<Boolean>() {
// public Boolean call() throws Exception {
if (chain == null) return handler.service(request, response);
else {
boolean handled = chain.getHandler().service(request, response);
return handled || handler.service(request, response);
}
// }
// });
}
finally {
ThreadContext.remove(subject);
ThreadContext.remove();
}
You could override SecurityConfiguration yourself with a version that operates in the same manner as above. If you want to help, try it and let me know if everything else works. You may run into other issues since GAE can be a fairly restrictive environment for full-fledged Java applications.
I have upgraded my GAE server application with the latest GAE SDK 1.9.17 and it stopped work.
I am facing a problem while performing 'entityManager.find(Profile.class, 'some long value representing profile id')'.
Here is a stack trace:
java.lang.ClassCastException: com.google.appengine.api.datastore.Key cannot be cast to java.lang.Integer
at org.datanucleus.store.appengine.DatastoreFieldManager.fetchIntField(DatastoreFieldManager.java:435)
at org.datanucleus.state.AbstractStateManager.replacingIntField(AbstractStateManager.java:1132)
at xxx.Profile.jdoReplaceField(Profile.java)
at xxx.Profile.jdoReplaceFields(Profile.java)
at org.datanucleus.state.JDOStateManagerImpl.replaceFields(JDOStateManagerImpl.java:2772)
at org.datanucleus.state.JDOStateManagerImpl.replaceFields(JDOStateManagerImpl.java:2791)
at org.datanucleus.store.appengine.DatastorePersistenceHandler.fetchObject(DatastorePersistenceHandler.java:519)
at org.datanucleus.state.JDOStateManagerImpl.validate(JDOStateManagerImpl.java:4263)
at org.datanucleus.ObjectManagerImpl.findObject(ObjectManagerImpl.java:2444)
at org.datanucleus.jpa.EntityManagerImpl.find(EntityManagerImpl.java:234)
at org.datanucleus.store.appengine.jpa.DatastoreEntityManager.find(DatastoreEntityManager.java:56)
at xxx.GameAdd$1.run(GameAdd.java:34)
at xxx.GameAdd$1.run(GameAdd.java:29)
at xxx.Action.execute(Action.java:112)
at xxx.GameAdd.doPost(GameAdd.java:28)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:254)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:484)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:438)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:445)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:309)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:301)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:442)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:724)
The entity I find is look like:
#Entity
public class Profile
{
public Key getKey() {return key;}
// Other public methods
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Key key;
// Other data fields
}
The problem started right after I've upgraded the GAE SDK.
Code wasn't changed. I always did searches using 'long' values that represent profile id.
I tried to use KeyFactory.createKey() method to generate a key for find method but it didn't help either.
Example:
Key key = KeyFactory.createKey(Profile.class.getSimpleName(), 12345);
Profile p = entitymanager.find(Profile.class, key);
I would appreciate any advises since my server application is unavailable and can't serve end users.
Thanks in advance!
There is a chance of a problem in your build environment, especially if you have just upgraded to the new version and everything did work before. Try to use another tool to build the application, e.g. ant. You can find directions here. It is fairly easy and quick to make it work and it should give you an indication whether the problem is indeed in the new IntelliJ GAE support.
Key key = KeyFactory.createKey(Profile.class.getSimpleName(), 12345);
12345 is considered an Int...
Try this:
long longVal = 12345;
Key key = KeyFactory.createKey(Profile.class.getSimpleName(), longVal);
===---===
Let me know if that helps you.
I have an appengine module which runs as a background instance (b4, basic scaling) and which iterates over a huge amount of data and processes it.
It runs correctly through when a smaller amount of data is processed, but when data becomes bigger i start to get multiple Exceptions. At the beginning an InvocationTargetException causes a MemcacheServiceException, which gets then caught by the LogAndContinueErrorHandler (see this thread: Backend "Process moved to a different machine" and fails withh error 500).
After around 14 seconds and another 10 similar Errors, the "Process moved to a different machine.". I suggest the reason is that appengine recognizes the errors and assumes that something is wrong with the instance and shuts it down after a while.
As suggested in the other thread, i could ensure, that the move to a different machine keeps the process going, but since it really has an Error because something is too big / to long i better should work on the error.
Here is the error at the beginning of the error cascade, at the end the error stops on com.googlecode.objectify.cache.MemcacheServiceRetryProxy invoke: Error performing memcache operation, retrying: public abstract void
15:49:18.779
com.google.appengine.api.memcache.LogAndContinueErrorHandler handleServiceError: Service error in memcache
com.google.appengine.api.memcache.MemcacheServiceException: Memcache getAll: exception getting multiple keys
at com.google.appengine.api.memcache.MemcacheServiceApiHelper$RpcResponseHandler.handleApiProxyException(MemcacheServiceApiHelper.java:68)
at com.google.appengine.api.memcache.MemcacheServiceApiHelper$1.absorbParentException(MemcacheServiceApiHelper.java:109)
at com.google.appengine.api.utils.FutureWrapper.handleParentException(FutureWrapper.java:51)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:90)
at com.google.appengine.api.memcache.MemcacheServiceImpl.quietGet(MemcacheServiceImpl.java:26)
at com.google.appengine.api.memcache.MemcacheServiceImpl.getAll(MemcacheServiceImpl.java:64)
at com.googlecode.objectify.cache.KeyMemcacheService.getAll(KeyMemcacheService.java:75)
at com.googlecode.objectify.cache.EntityMemcache.cacheGetAll(EntityMemcache.java:346)
at com.googlecode.objectify.cache.EntityMemcache.putAll(EntityMemcache.java:285)
at com.googlecode.objectify.cache.CachingAsyncDatastoreService$3.success(CachingAsyncDatastoreService.java:280)
at com.googlecode.objectify.cache.CachingAsyncDatastoreService$3.success(CachingAsyncDatastoreService.java:269)
at com.googlecode.objectify.cache.TriggerSuccessFuture.trigger(TriggerSuccessFuture.java:38)
at com.googlecode.objectify.cache.TriggerFuture.isDone(TriggerFuture.java:89)
at com.googlecode.objectify.cache.TriggerFuture.get(TriggerFuture.java:104)
at com.googlecode.objectify.impl.ResultAdapter.now(ResultAdapter.java:34)
at com.googlecode.objectify.impl.Round$2.now(Round.java:135)
at com.googlecode.objectify.impl.Round$2.now(Round.java:132)
at com.googlecode.objectify.impl.LoadEngine$1.nowUncached(LoadEngine.java:172)
at com.googlecode.objectify.impl.LoadEngine$1.nowUncached(LoadEngine.java:164)
at com.googlecode.objectify.util.ResultCache.now(ResultCache.java:30)
at com.googlecode.objectify.impl.Round$1.nowUncached(Round.java:73)
at com.googlecode.objectify.util.ResultCache.now(ResultCache.java:30)
at com.googlecode.objectify.LoadResult.now(LoadResult.java:25)
at ch.eaternity.server.DAO.loadEntityNow(DAO.java:383)
at ch.eaternity.server.services.ProductServiceImpl.getProduct(ProductServiceImpl.java:21)
at ch.eaternity.server.CompositeRoot.restoreJavaObject(CompositeRoot.java:237)
at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_$1.run(Method_.java:179)
at java.security.AccessController.doPrivileged(Native Method)
at com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.privilegedInvoke(Method_.java:176)
at com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.invoke_(Method_.java:137)
at com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.invoke(Method_.java:45)
at com.googlecode.objectify.impl.ConcreteEntityMetadata.invokeLifecycleCallbacks(ConcreteEntityMetadata.java:167)
at com.googlecode.objectify.impl.ConcreteEntityMetadata.access$000(ConcreteEntityMetadata.java:24)
at com.googlecode.objectify.impl.ConcreteEntityMetadata$1.run(ConcreteEntityMetadata.java:127)
at com.googlecode.objectify.impl.translate.LoadContext.done(LoadContext.java:70)
at com.googlecode.objectify.impl.LoadEngine$1.postExecuteHook(LoadEngine.java:191)
at com.googlecode.objectify.util.ResultCache.now(ResultCache.java:33)
at com.googlecode.objectify.impl.Round$1.nowUncached(Round.java:73)
at com.googlecode.objectify.util.ResultCache.now(ResultCache.java:30)
at com.googlecode.objectify.util.ResultNowFunction.apply(ResultNowFunction.java:20)
at com.googlecode.objectify.util.ResultNowFunction.apply(ResultNowFunction.java:9)
at com.google.common.collect.Iterators$8.transform(Iterators.java:794)
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
at com.googlecode.objectify.impl.Chunk.next(Chunk.java:27)
at com.googlecode.objectify.impl.Chunk.next(Chunk.java:10)
at com.google.common.collect.Iterators$5.next(Iterators.java:553)
at com.google.common.collect.Iterators$PeekingImpl.peek(Iterators.java:1162)
at com.googlecode.objectify.impl.ChunkingIterator.hasNext(ChunkingIterator.java:52)
at com.google.common.collect.Iterators.addAll(Iterators.java:356)
at com.google.common.collect.Lists.newArrayList(Lists.java:147)
at com.google.common.collect.Lists.newArrayList(Lists.java:129)
at com.googlecode.objectify.util.MakeListResult.translate(MakeListResult.java:21)
at com.googlecode.objectify.util.MakeListResult.translate(MakeListResult.java:11)
at com.googlecode.objectify.util.ResultTranslator.nowUncached(ResultTranslator.java:21)
at com.googlecode.objectify.util.ResultCache.now(ResultCache.java:30)
at com.googlecode.objectify.util.ResultProxy.invoke(ResultProxy.java:32)
at com.sun.proxy.$Proxy23.toArray(Unknown Source)
at java.util.ArrayList.addAll(ArrayList.java:530)
at ch.eaternity.server.DAO.loadCompositeRootsByDateAndKitchenId(DAO.java:1058)
at ch.eaternity.server.services.ReportServiceImpl.loadCompositeRoots(ReportServiceImpl.java:75)
at ch.eaternity.server.services.ReportServiceImpl.loadSupplies(ReportServiceImpl.java:24)
at ch.eaternity.server.reports.GeneralKitchenDataAnalyzer.generateAndSaveConcreteGeneralKitchenData(GeneralKitchenDataAnalyzer.java:45)
at ch.eaternity.server.servlets.ReportGeneratingServlet.kickOffReportDataGeneration(ReportGeneratingServlet.java:75)
at ch.eaternity.server.servlets.ReportGeneratingServlet.doPost(ReportGeneratingServlet.java:46)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at ch.eaternity.server.NamespaceFilter.doFilter(NamespaceFilter.java:36)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.googlecode.objectify.cache.AsyncCacheFilter.doFilter(AsyncCacheFilter.java:59)
at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:49)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:254)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
<continued in next message>
E
15:49:18.779
<continued from previous message>
at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:480)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:438)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:445)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:309)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:301)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:442)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:724)
I
15:49:20.272
com.google.appengine.api.memcache.MemcacheServiceApiHelper$RpcResponseHandler handleApiProxyException: Memcache putAll: Unknown exception setting 0 keys:
W
15:49:20.276
com.googlecode.objectify.cache.MemcacheServiceRetryProxy invoke: Error performing memcache operation, retrying: public abstract void com.google.appengine.api.memcache.MemcacheService.putAll(java.util.Map)
java.lang.reflect.InvocationTargetException
at com.google.appengine.runtime.Request.process-fdcbff8350bb99f7(Request.java)
at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:45)
at com.googlecode.objectify.cache.MemcacheServiceRetryProxy.invoke(MemcacheServiceRetryProxy.java:68)
at com.sun.proxy.$Proxy10.putAll(Unknown Source)
at com.googlecode.objectify.cache.KeyMemcacheService.putAll(KeyMemcacheService.java:80)
at com.googlecode.objectify.cache.EntityMemcache.empty(EntityMemcache.java:312)
at com.googlecode.objectify.cache.EntityMemcache.putAll(EntityMemcache.java:296)
at com.googlecode.objectify.cache.CachingAsyncDatastoreService$3.success(CachingAsyncDatastoreService.java:280)
at com.googlecode.objectify.cache.CachingAsyncDatastoreService$3.success(CachingAsyncDatastoreService.java:269)
at com.googlecode.objectify.cache.TriggerSuccessFuture.trigger(TriggerSuccessFuture.java:38)
at com.googlecode.objectify.cache.TriggerFuture.isDone(TriggerFuture.java:89)
at com.googlecode.objectify.cache.TriggerFuture.get(TriggerFuture.java:104)
at com.googlecode.objectify.impl.ResultAdapter.now(ResultAdapter.java:34)
at com.googlecode.objectify.impl.Round$2.now(Round.java:135)
at com.googlecode.objectify.impl.Round$2.now(Round.java:132)
at com.googlecode.objectify.impl.LoadEngine$1.nowUncached(LoadEngine.java:172)
at com.googlecode.objectify.impl.LoadEngine$1.nowUncached(LoadEngine.java:164)
at com.googlecode.objectify.util.ResultCache.now(ResultCache.java:30)
at com.googlecode.objectify.impl.Round$1.nowUncached(Round.java:73)
at com.googlecode.objectify.util.ResultCache.now(ResultCache.java:30)
at com.googlecode.objectify.LoadResult.now(LoadResult.java:25)
at ch.eaternity.server.DAO.loadEntityNow(DAO.java:383)
at ch.eaternity.server.services.ProductServiceImpl.getProduct(ProductServiceImpl.java:21)
at ch.eaternity.server.CompositeRoot.restoreJavaObject(CompositeRoot.java:237)
at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:45)
at com.googlecode.objectify.impl.ConcreteEntityMetadata.invokeLifecycleCallbacks(ConcreteEntityMetadata.java:167)
at com.googlecode.objectify.impl.ConcreteEntityMetadata.access$000(ConcreteEntityMetadata.java:24)
at com.googlecode.objectify.impl.ConcreteEntityMetadata$1.run(ConcreteEntityMetadata.java:127)
at com.googlecode.objectify.impl.translate.LoadContext.done(LoadContext.java:70)
at com.googlecode.objectify.impl.LoadEngine$1.postExecuteHook(LoadEngine.java:191)
at com.googlecode.objectify.util.ResultCache.now(ResultCache.java:33)
at com.googlecode.objectify.impl.Round$1.nowUncached(Round.java:73)
at com.googlecode.objectify.util.ResultCache.now(ResultCache.java:30)
at com.googlecode.objectify.util.ResultNowFunction.apply(ResultNowFunction.java:20)
at com.googlecode.objectify.util.ResultNowFunction.apply(ResultNowFunction.java:9)
at com.google.common.collect.Iterators$8.transform(Iterators.java:794)
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
at com.googlecode.objectify.impl.Chunk.next(Chunk.java:27)
at com.googlecode.objectify.impl.Chunk.next(Chunk.java:10)
at com.google.common.collect.Iterators$5.next(Iterators.java:553)
at com.google.common.collect.Iterators$PeekingImpl.peek(Iterators.java:1162)
at com.googlecode.objectify.impl.ChunkingIterator.hasNext(ChunkingIterator.java:52)
at com.google.common.collect.Iterators.addAll(Iterators.java:356)
at com.google.common.collect.Lists.newArrayList(Lists.java:147)
at com.google.common.collect.Lists.newArrayList(Lists.java:129)
at com.googlecode.objectify.util.MakeListResult.translate(MakeListResult.java:21)
at com.googlecode.objectify.util.MakeListResult.translate(MakeListResult.java:11)
at com.googlecode.objectify.util.ResultTranslator.nowUncached(ResultTranslator.java:21)
at com.googlecode.objectify.util.ResultCache.now(ResultCache.java:30)
at com.googlecode.objectify.util.ResultProxy.invoke(ResultProxy.java:32)
at com.sun.proxy.$Proxy23.toArray(Unknown Source)
at java.util.ArrayList.addAll(ArrayList.java:530)
at ch.eaternity.server.DAO.loadCompositeRootsByDateAndKitchenId(DAO.java:1058)
at ch.eaternity.server.services.ReportServiceImpl.loadCompositeRoots(ReportServiceImpl.java:75)
at ch.eaternity.server.services.ReportServiceImpl.loadSupplies(ReportServiceImpl.java:24)
at ch.eaternity.server.reports.GeneralKitchenDataAnalyzer.generateAndSaveConcreteGeneralKitchenData(GeneralKitchenDataAnalyzer.java:45)
at ch.eaternity.server.servlets.ReportGeneratingServlet.kickOffReportDataGeneration(ReportGeneratingServlet.java:75)
at ch.eaternity.server.servlets.ReportGeneratingServlet.doPost(ReportGeneratingServlet.java:46)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at ch.eaternity.server.NamespaceFilter.doFilter(NamespaceFilter.java:36)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.googlecode.objectify.cache.AsyncCacheFilter.doFilter(AsyncCacheFilter.java:59)
at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:49)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:438)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:445)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:309)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:301)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:442)
at java.lang.Thread.run(Thread.java:724)
Caused by: com.google.appengine.api.memcache.MemcacheServiceException: Memcache putAll: Unknown exception setting 0 keys
at com.google.appengine.api.memcache.MemcacheServiceApiHelper$RpcResponseHandler.handleApiProxyException(MemcacheServiceApiHelper.java:68)
at com.google.appengine.api.memcache.AsyncMemcacheServiceImpl$RpcResponseHandlerForPut.handleApiProxyException(AsyncMemcacheServiceImpl.java:348)
at com.google.appengine.api.memcache.MemcacheServiceApiHelper$1.absorbParentException(MemcacheServiceApiHelper.java:109)
<continued in next message>
W
15:49:20.276
<continued from previous message>
at com.google.appengine.api.utils.FutureWrapper.handleParentException(FutureWrapper.java:51)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:90)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:88)
at com.google.appengine.api.memcache.MemcacheServiceImpl.quietGet(MemcacheServiceImpl.java:26)
at com.google.appengine.api.memcache.MemcacheServiceImpl.putAll(MemcacheServiceImpl.java:115)
... 91 more
Im not sure weather its related to appengine or objectify, see this thread for comparison:
https://groups.google.com/forum/#!msg/objectify-appengine/GzFmrQNMaI0/1ALIKbEY9agJ
Objectify: 4.0RC2
Appengine: 1.9.9
Update 1
After upgrading to Objectify 4.1.3., no exceptions occur anymore, but at the exactly same point in the iteration the Process moved to a different machine. warning occurs. Why is it moved then to a different machine?
Update 2
In the meantime, i reached couple of times the Memory limit and finally rised the backen instance to B4 which solved the problem for the moment.
java.lang.RuntimeException: java.lang.OutOfMemoryError: Java heap space
Now the error moved a little bit, now i only get this exception around 100 times, until the process gets moved to a different machine.
com.google.appengine.api.memcache.MemcacheServiceException: Memcache getAll: exception getting multiple keys
Update 3
Sometimes the batch process also runs through successfully! I dont understand... I'll try to figure out when its not successfull.
Anyone knowing where the problem could origin from? How to solve it?
Thank you very much!
I don't have a direct answer to your question, but I can shed some light on Objectify's (and GAE's) behavior WRT memcache.
Objectify uses memcache as a read-through cache, so "memcache unavailable" is for all practical purposes the same as "empty result" - Objectify goes and gets the data out of the datastore. GAE's memcache API has a LogAndContinueErrorHandler for exactly this purpose - memecache errors are logged but otherwise ignored.
Unfortunately Google's LogAndContinueErrorHandler had a bug in that some types of memcache errors were neither logged nor ignored. Objectify got some new behavior (the aptly-named MemcacheServiceRetryProxy) which retries memcache API calls a few times and then gives up, returning an empty result. This what you are seeing with 4.0RC2.
Some time later Google fixed the handler not by changing the behavior of LogAndContinueErrorHandler (it was considered likely that some users were relying on exact behavior) but by deprecating that class and adding a ConsistentLogAndContinueErrorHandler which behaves... more consistently. A later version of Objectify switched to use this facility, and now you're seeing that behavior with 4.1.3 - less noisy.
So that's part of the story. Another part of the story is that at some point Objectify was just a little too smugly clever about optimizing calls to memcache, and sometimes would optimize a memcache call down to a zero-length list of keys. The memcache API doesn't like that, which is what might be responsible for Memcache putAll: Unknown exception setting 0 keys. More recent versions of Objectify skip the memcache call if there are no operations.
As for Process moved to a different machine., I have no idea. It might be related, it might not.
Regarding the process moving up on different instance, you can't control it anyhow.A machine may go down anytime and app engine will shift your process to another machine.You task should better be idempotent.
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Exception occurred when flushing data . What is this and why am I getting this?
The following is a snippet from a filter. It gets the client IP , sets the attribute and then chains the request to a servlet.
#Override
public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain)
throws ServletException,IOException {
String IP = request.getRemoteAddr();
request.setAttribute("client IP from the filter", IP);
chain.doFilter(request, response);
}
The following is a snippet from the servlet which has received a filtered request. It gets the IP , stores it as an another attribute and then dispatches the request to index.jsp .
#Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String IP = (String)request.getAttribute("client IP from the filter");
request.setAttribute("Client IP", IP);
RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
rd.forward(request,response);
}
index.jsp , then retrieves the attribute set by the servlet and works upon it.
The servlet is the first thing to run when a website foo.com is first opened. But as I open the website I see this stack trace :
java.lang.IllegalStateException: Exception occurred when flushing data
at com.google.appengine.runtime.Request.process-d6995d0c305e239e(Request.java)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:191)
at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:118)
at org.apache.jasper.runtime.JspFactoryImpl.access$100(JspFactoryImpl.java:40)
at org.apache.jasper.runtime.JspFactoryImpl$PrivilegedReleasePageContext.run(JspFactoryImpl.java:166)
at java.security.AccessController.doPrivileged(AccessController.java:34)
at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:75)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:139)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:327)
at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:126)
at Servlets.FW_FirstSite.doGet(FW_FirstSite.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at Filters.FirstSiteFilter.doFilter(FirstSiteFilter.java:24)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:452)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:458)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:698)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:336)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:328)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:456)
at java.lang.Thread.run(Thread.java:679)
Caused by: java.io.IOException: Stream closed
at org.apache.jasper.runtime.JspWriterImpl.ensureOpen(JspWriterImpl.java:204)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:115)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:188)
... 43 more
Logs suggest that exception occurs at Servlets.FW_FirstSite.doGet(FW_FirstSite.java:27) which is the statement rd.forward(request,response); and at Filters.FirstSiteFilter.doFilter(FirstSiteFilter.java:24) which is the statement chain.doFilter(request, response);.
Why do get these exceptions ?
My guess is that your call to response.getWriter() initiates writing the response to the client when it's being flushed. For that reason, you cannot anymore forward the request, as it has been already been flushed on.
You are allowed to set your response content type multiple times without it mattering, but you shouldn't call a writer unless you're already done with pre-processing.
Note also that calling getOutputStream() has the same effect.
What is the purpose of the following code in the doGet method?
response.setContentType("text/plain");
PrintWriter writer = response.getWriter();
I haven't actually checked the specification, but I doubt that you are allowed to manipulate the servlet's response (neither by setting headers, nor by accessing the OutputStream or Writer) before forwarding the request to another resource.
For a specific requirement in my project, I want to retrieve JSON response from a web service api.
I am tried a java code in a simple Java project which is running fine.
String message = null;
HttpClient httpclient = new DefaultHttpClient();
JSONParser parser = new JSONParser();
String url = "working - url";
HttpResponse response = null;
response = httpclient.execute(new HttpGet(url));
JSONObject json_data = null;
json_data = (JSONObject)parser.parse(EntityUtils.toString(response.getEntity()));
JSONArray results = (JSONArray)json_data.get("result");
for (Object queid : results) {
message = message.concat((String) ((JSONObject)queid).get("id"));
message = message.concat("\t");
message = message.concat((String) ((JSONObject)queid).get("owner"));
message = message.concat("\n");
}
If I try to run this code in a GWT application servlet, I am getting several errors om compilation.
[ERROR] Line 16: No source code is available for type org.apache.http.client.ClientProtocolException; did you forget to inherit a required module?
[ERROR] Line 16: No source code is available for type org.apache.http.ParseException; did you forget to inherit a required module?
[ERROR] Line 16: No source code is available for type org.json.simple.parser.ParseException; did you forget to inherit a required module?
I have added the required jars using the project build path ->add external jars.
But still I am facing the same problem.
I have tried attaching the source to the jars but still the problem is same.
What possibly could be done in this case?
Can I run actual java in the backend of my GWT application
Edit #1:
This code is written in my GWT servlet. I have tried using adding throws clause to the method in my servlet and applying try/catch block as well. But I am still getting these errors.
Edit #2:
I have got following errors in my console log after applying try/catch block.
Mar 10, 2012 1:16:28 PM com.google.appengine.tools.development.ApiProxyLocalImpl log
SEVERE: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.lang.String com.google.detracker.client.DeService.getJSONRespnse()' threw an unexpected exception: java.lang.NoClassDefFoundError: javax.net.ssl.KeyManagerFactory is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:58)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:351)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.NoClassDefFoundError: javax.net.ssl.KeyManagerFactory is a restricted class. Please see the Google App Engine developer's guide for more details.
at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
at org.apache.http.conn.ssl.SSLSocketFactory.createSSLContext(SSLSocketFactory.java:184)
at org.apache.http.conn.ssl.SSLSocketFactory.createDefaultSSLContext(SSLSocketFactory.java:209)
at org.apache.http.conn.ssl.SSLSocketFactory.<init>(SSLSocketFactory.java:333)
at org.apache.http.conn.ssl.SSLSocketFactory.getSocketFactory(SSLSocketFactory.java:165)
at org.apache.http.impl.conn.SchemeRegistryFactory.createDefault(SchemeRegistryFactory.java:45)
at org.apache.http.impl.client.AbstractHttpClient.createClientConnectionManager(AbstractHttpClient.java:294)
at org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:445)
at org.apache.http.impl.client.AbstractHttpClient.createHttpContext(AbstractHttpClient.java:274)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:797)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
at com.google.detracker.server.DeServiceImpl.getJSONRespnse(DeServiceImpl.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
... 34 more
Mar 10, 2012 1:16:28 PM com.google.appengine.tools.development.LocalResourceFileServlet doGet
If you pay attention, The error is about an Exception class. This means your code is returning an exception which you are not handling. type org.apache.http.client.ClientProtocolException
Try surronding your code with try catch block and see what you get in the dev console.
Try {
String message = null;
HttpClient httpclient = new DefaultHttpClient();
JSONParser parser = new JSONParser();
String url = "working - url";
HttpResponse response = null;
response = httpclient.execute(new HttpGet(url));
JSONObject json_data = null;
json_data = (JSONObject)parser.parse(EntityUtils.toString(response.getEntity()));
JSONArray results = (JSONArray)json_data.get("result");
for (Object queid : results) {
message = message.concat((String) ((JSONObject)queid).get("id"));
message = message.concat("\t");
message = message.concat((String) ((JSONObject)queid).get("owner"));
message = message.concat("\n");
}
} catch (Exception e) {
e.printStack();
}
Explanation:
Some more explanation for all those who want it. In your code, you do not handle the exceptions with try catch blocks. Thus, when an exception is raised, the server will send it back to the client but most of the exceptions are NOT serializable, so they cannot be transported back to the client and this is why you get the mentioned error.
use RequestBuilder
http://code.google.com/webtoolkit/doc/latest/tutorial/JSON.html
Yes you can, but the error message suggest you have somewhere in your client side code imported a class that uses those server side external jars.
Edit: Based the answer of Adel Boutros I guess you have added throws to your GWT service interfaces for the classes that generate these errors? You can only throw exceptions that are also available to the client, so catch them on the server and rethrow a new exception that is available in the client.
If those librabries can actually be used in GWT, you have to add lines in your application.gwt.xml file to inherit the modules.
Example with library smartgwt:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Other module inherits -->
<inherits name="com.smartgwt.SmartGwt"/>
<!-- Specify the app entry point class. -->
<entry-point class='blablabla'/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>