Error serializing object class - when running Wick

2019-09-08 04:21发布

Issues running Wicket with GAE is:

[INFO] SEVERE: Error serializing object class com.myapp.app.TemplatePage [object=[Page class = com.myapp.app.TemplatePage, id = 10, render count = 1]]
[INFO] java.security.AccessControlException: access denied ("java.io.SerializablePermission" "enableSubclassImplementation")
[INFO]  at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
[INFO]  at java.security.AccessController.checkPermission(AccessController.java:884)
[INFO]  at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
[INFO]  at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:429)
[INFO]  at java.io.ObjectOutputStream.<init>(ObjectOutputStream.java:275)
[INFO]  at org.apache.wicket.serialize.java.JavaSerializer$SerializationCheckerObjectOutputStream.<init>(JavaSerializer.java:250)
[INFO]  at org.apache.wicket.serialize.java.JavaSerializer$SerializationCheckerObjectOutputStream.<init>(JavaSerializer.java:243)
[INFO]  at org.apache.wicket.serialize.java.JavaSerializer.newObjectOutputStream(JavaSerializer.java:176)
[INFO]  at org.apache.wicket.serialize.java.JavaSerializer.serialize(JavaSerializer.java:76)
[INFO]  at org.apache.wicket.pageStore.DefaultPageStore.serializePage(DefaultPageStore.java:376)
[INFO]  at org.apache.wicket.pageStore.DefaultPageStore.storePage(DefaultPageStore.java:150)
[INFO]  at org.apache.wicket.page.PageStoreManager$PersistentRequestAdapter.storeTouchedPages(PageStoreManager.java:412)
[INFO]  at org.apache.wicket.page.RequestAdapter.commitRequest(RequestAdapter.java:181)
[INFO]  at org.apache.wicket.page.AbstractPageManager.commitRequest(AbstractPageManager.java:98)
[INFO]  at org.apache.wicket.page.PageManagerDecorator.commitRequest(PageManagerDecorator.java:73)
[INFO]  at org.apache.wicket.page.PageAccessSynchronizer$2.commitRequest(PageAccessSynchronizer.java:258)
[INFO]  at org.apache.wicket.Application$2.onDetach(Application.java:1665)
[INFO]  at org.apache.wicket.request.cycle.RequestCycleListenerCollection$3.notify(RequestCycleListenerCollection.java:105)
[INFO]  at org.apache.wicket.request.cycle.RequestCycleListenerCollection$3.notify(RequestCycleListenerCollection.java:101)
[INFO]  at org.apache.wicket.util.listener.ListenerCollection$1.notify(ListenerCollection.java:120)
[INFO]  at org.apache.wicket.util.listener.ListenerCollection.reversedNotify(ListenerCollection.java:144)
[INFO]  at org.apache.wicket.util.listener.ListenerCollection.reversedNotifyIgnoringExceptions(ListenerCollection.java:113)
[INFO]  at org.apache.wicket.request.cycle.RequestCycleListenerCollection.onDetach(RequestCycleListenerCollection.java:100)
[INFO]  at org.apache.wicket.request.cycle.RequestCycle.onDetach(RequestCycle.java:640)
[INFO]  at org.apache.wicket.request.cycle.RequestCycle.detach(RequestCycle.java:589)
[INFO]  at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)
[INFO]  at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)
[INFO]  at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)
[INFO]  at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)
[INFO]  at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO]  at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
[INFO]  at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO]  at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:127)
[INFO]  at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO]  at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
[INFO]  at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO]  at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
[INFO]  at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO]  at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
[INFO]  at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO]  at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
[INFO]  at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO]  at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
[INFO]  at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
[INFO]  at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
[INFO]  at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO]  at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
[INFO]  at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
[INFO]  at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
[INFO]  at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
[INFO]  at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
[INFO]  at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
[INFO]  at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[INFO]  at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:491)
[INFO]  at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[INFO]  at org.mortbay.jetty.Server.handle(Server.java:326)
[INFO]  at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
[INFO]  at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
[INFO]  at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
[INFO]  at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
[INFO]  at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
[INFO]  at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
[INFO]  at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

1条回答
做自己的国王
2楼-- · 2019-09-08 05:12

Here is the code I added that fixed this issue:

    // disable ModificationWatcher
    getResourceSettings().setResourcePollFrequency(null);

    // use plain JDK Object(Input|Output)Stream
    ISerializer serializer = new GaeObjectSerializer(getApplicationKey());
    getFrameworkSettings().setSerializer(serializer);

    // save older version of pages in the HttpSession
    final IDataStoreEvictionStrategy evictionStrategy = new PageNumberEvictionStrategy(10);
    setPageManagerProvider(new GaePageManagerProvider(this, evictionStrategy));

    // disable file cleaning because it starts a new thread
    getResourceSettings().setFileCleaner(null);
查看更多
登录 后发表回答