im do j2ee with primefaces and web 2.0目前卡在这里,出现此错误
java.io.NotSerializableException: org.apache.derby.client.am.PreparedStatement40
java.io.ObjectOutputStream.writeObject0(Unknown Source)
java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
java.io.ObjectOutputStream.writeSerialData(Unknown Source)
java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
java.io.ObjectOutputStream.writeObject0(Unknown Source)
java.io.ObjectOutputStream.writeObject(Unknown Source)
java.util.HashMap.writeObject(Unknown Source)
sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
java.io.ObjectOutputStream.writeSerialData(Unknown Source)
java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
java.io.ObjectOutputStream.writeObject0(Unknown Source)
java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
java.io.ObjectOutputStream.writeSerialData(Unknown Source)
java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
java.io.ObjectOutputStream.writeObject0(Unknown Source)
java.io.ObjectOutputStream.writeArray(Unknown Source)
java.io.ObjectOutputStream.writeObject0(Unknown Source)
java.io.ObjectOutputStream.writeObject(Unknown Source)
java.util.HashMap.writeObject(Unknown Source)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
java.io.ObjectOutputStream.writeSerialData(Unknown Source)
java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
java.io.ObjectOutputStream.writeObject0(Unknown Source)
java.io.ObjectOutputStream.writeObject(Unknown Source)
com.sun.faces.renderkit.ClientSideStateHelper.doWriteState(ClientSideStateHelper.java:293)
com.sun.faces.renderkit.ClientSideStateHelper.writeState(ClientSideStateHelper.java:167)
com.sun.faces.renderkit.ResponseStateManagerImpl.writeState(ResponseStateManagerImpl.java:123)
com.sun.faces.application.StateManagerImpl.writeState(StateManagerImpl.java:155)
com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:221)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:397)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
一些谷歌搜索说我需要实现我在此函数中使用的所有类的 Serializable,但我已经这样做了。而且这个错误似乎很普遍,我不太清楚这一点。并且不太了解下面的错误
org.apache.derby.client.am.PreparedStatement40
看起来您正在将 (JDBC) PreparedStatement 存储在正在序列化的对象之一(可能是会话的一部分)中。您应该将其移动到其他地方或将其标记为瞬态(不要忘记它在恢复时会丢失)。
问题是你尝试序列化的对象引用了org.apache.derby.client.am.PreparedStatement40,或者很可能引用了java.sql.Statement,这是类实现的接口。您必须删除该引用才能使其正常工作
线索在这里:
StateManagerImpl.writeState
您可能在某个组件上设置了不适当的值。您可能需要在支持Bean中显式调用setValue
的地方使用EL绑定(根据发布的信息,我的最佳猜测)。
JSF 使用在请求之间持久化的有状态 UI 组件树。树结构和树上设置的任何值都将在渲染响应阶段结束时保存。通常,数据保存在会话或隐藏的表单域中。因此,在组件上设置的任何值都必须是可序列化的。