我正在尝试确定我的会话的大小,我想跟踪,因为我开始进行开发更改。我的应用程序运行正常,没有序列化错误 - 除非我尝试获取会话大小。
在Wicket 1.4中,我记得我没有问题,但现在我做不到。如果我在PageBase
构造函数中获得会话大小,则会收到相同的错误。
谁能看到我做错了什么?
public class PageBase extends WebPage
{
private static final long serialVersionUID = 1L;
...
@Override
protected void onAfterRender()
{
super.onAfterRender();
Session ssnSession = Session.get();
long loSize = ssnSession.getSizeInBytes(); <-- Exception is raised here
...
}
...
}
11-Jul-2012 19:30:11 org.apache.wicket.util.lang.WicketObjects$SerializingObjectSizeOfStrategy sizeOf
WARNING: Unable to determine object size: [...].MySession@d2f5f1
java.io.NotSerializableException: java.lang.Object
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at org.apache.wicket.util.lang.WicketObjects$SerializingObjectSizeOfStrategy.sizeOf(WicketObjects.java:124)
at org.apache.wicket.util.lang.WicketObjects.sizeof(WicketObjects.java:416)
at org.apache.wicket.Session.getSizeInBytes(Session.java:439)
at [...].PageBase.onAfterRender(PageBase.java:212)
at org.apache.wicket.Component.afterRender(Component.java:962)
at org.apache.wicket.Component.render(Component.java:2326)
at org.apache.wicket.Page.renderPage(Page.java:1035)
at org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:105)
...
答案 0 :(得分:0)
我已设法使用
修复我的问题dev_appserver.cmd --jvm_flag=-Dsun.io.serialization.extendedDebugInfo=true
突出显示有问题的数据成员。在我使用的WebSession
个实例中
private final Object m_objLockItemPaidStatus = new Object();
锁定synchronized
块中的处理。我已将此更改为使用
/**
* This class is the simplest possible class which can be used as an object
* to lock processing in a <code>synchronized</code> block
* and which can also be serialised.
* (This class extends <code>java.lang.Object</code> solely to implement the
* <code>java.io.Serializable</code> interface.)
*/
public static class LockObject extends Object implements Serializable
{
private static final long serialVersionUID = 1L;
public LockObject()
{
super();
}
}
相反,为了确保我的WebSession
个实例可以序列化(因此我也可以使用WebSession#getSizeInBytes()
找到它们的大致尺寸。)
有一件事我觉得很奇怪,因为我希望Wicket在我的Google App Engine for Java(GAE / J)环境中序列化我的WebSession
个实例,为什么使用GAE / J开发已经没有找到它网络服务器?