gpt4 book ai didi

java - 应用程序序列化错误,java.io.NotSerializedException :

转载 作者:行者123 更新时间:2023-11-30 01:54:25 24 4
gpt4 key购买 nike

我正在尝试使用 Google Cloud Platform(Eclipse 中的插件)在 Google Cloud Platform 中运行 Vaadin 项目。运行后我得到这个异常:

WARNING: Error in serialization of the application: Class 
rand.TestProject.AutoCrudView$1 must implement serialization.
2019-03-02 15:54:06.159:WARN:oejs.session:qtp1757676444-19:
java.io.NotSerializableException: java.lang.ref.WeakReference
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at java.util.LinkedList.writeObject(Unknown Source)
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 java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)

这是 AutoCrudView 类:

    @SuppressWarnings("serial")
public class AutoCrudView extends Window implements Serializable{
private static final long serialVersionUID = 1L;

public AutoCrudView(String PERSISTENCE_UNIT) {
final HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
Tree navTree = new Tree();
navTree.addListener(new Property.ValueChangeListener() {
/**
*
*/
private static final long serialVersionUID = 1L;

@Override
public void valueChange(ValueChangeEvent event) {
@SuppressWarnings("rawtypes")
BasicCrudView cv = (BasicCrudView) event.getProperty()
.getValue();
cv.refreshContainer();
horizontalSplitPanel.setSecondComponent(cv);
}
});
navTree.setSelectable(true);
navTree.setNullSelectionAllowed(false);
navTree.setImmediate(true);

horizontalSplitPanel.setSplitPosition(200,
HorizontalSplitPanel.UNITS_PIXELS);
horizontalSplitPanel.addComponent(navTree);
setContent(horizontalSplitPanel);

// add a basic crud view for all entities known by the JPA
// implementation, most often this is not desired and developers
// should just list those entities they want to have editors for
Metamodel metamodel = JPAContainerFactory
.createEntityManagerForPersistenceUnit(PERSISTENCE_UNIT)
.getEntityManagerFactory().getMetamodel();
Set<EntityType<?>> entities = metamodel.getEntities();
for (EntityType<?> entityType : entities) {
Class<?> javaType = entityType.getJavaType();
@SuppressWarnings({ "rawtypes", "unchecked" })
BasicCrudView view = new BasicCrudView(javaType,
PERSISTENCE_UNIT);
navTree.addItem(view);
navTree.setItemCaption(view, view.getCaption());
navTree.setChildrenAllowed(view, false);
if(javaType == Person.class) {
view.setVisibleTableProperties("firstName","lastName", "boss");
view.setVisibleFormProperties("firstName","lastName", "phoneNumber", "street", "city", "zipCode", "boss");
}

}

// select first entity view
navTree.setValue(navTree.getItemIds().iterator().next());
}

}

正如你所看到的,我已经实现了可序列化,但没有成功。这是我从 App Engine 窗口获得的图像: here

最佳答案

您会收到有关匿名内部类(类名末尾的 $1)而不是实际类本身的警告。

所以:去寻找你(不小心)创建了一个内部类实例并尝试保留该实例的地方。

也许是这样

new(...) {

将更改监听器添加到树对象的位置。如果是这样,问题是监听器是否应该是一个应该实现该接口(interface)的不同类。或者,如果您只是通过尝试保留具有此类监听器的内容而犯了错误(不是该框架的专家,我发现保留包括监听器实例在内的 ui 元素很可疑)。

关于java - 应用程序序列化错误,java.io.NotSerializedException :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54959944/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com