GWT RCP - 序列化异常

发布于 2024-11-05 13:52:15 字数 13259 浏览 0 评论 0原文

从头开始一个新项目,转换为JPA,我的持久性提供程序是EclipseLink,添加了必要的库(eclipselink.jar,eclipselink.jar,javax.persistence,mysql-connector-java-5.1)。测试连接,ping 正常。然后新建一个包 New > JPA>表中的实体 >选择所有实体和密钥生成器>身份。

GestorIpca.java

            GestorIpcaService.util.getInstance().getLista(new AsyncCallback<ArrayList<Docente>>() {

                @Override
                public void onFailure(Throwable caught) {
                    Window.alert("Erro na Ligacao efectuada");
                    caught.getStackTrace();
                }

                @Override
                public void onSuccess(ArrayList<Docente> result) {
                    Window.alert("Ligacao efectuada com sucesso:" + result.size());
                }
            });    

GestorIpcaService

@RemoteServiceRelativePath("greet")
public interface GestorIpcaService extends RemoteService {
    String greetServer(String name) throws IllegalArgumentException;

    public static class util{
        public static GestorIpcaServiceAsync instance;
        public static GestorIpcaServiceAsync getInstance(){
            if(instance == null){
                instance = GWT.create(GestorIpcaService.class);
            }
        return instance;
        }
    }
    public ArrayList<Docente> getLista() throws IllegalArgumentException;
}    

GestorIpcaServiceAsync

public interface GestorIpcaServiceAsync {
        void greetServer(String input, AsyncCallback<String> callback)
                throws IllegalArgumentException;

        void getLista(AsyncCallback<ArrayList<Docente>> callback);
    }

GestorIpcaServiceImpl

@SuppressWarnings("serial")
public class GestorIpcaServiceImpl extends RemoteServiceServlet implements
        GestorIpcaService {

    public ArrayList<Docente> getLista() throws IllegalArgumentException  {
        //Criamos um EntityManager
        EntityManager em = JpaUtil.getEntityManagerFactory().createEntityManager();
        //Criamos a consulta
        String consulta = "SELECT r from Docente r";
        //Executamos a consulta
        Query q = em.createQuery(consulta);
        ArrayList<Docente> lista = new ArrayList<Docente>(q.getResultList());
        return lista;
    }
/*  public static void main(String args[]){
        GestorIpcaServiceImpl serviceImpl = new GestorIpcaServiceImpl();
        for (Docente docente : serviceImpl.getLista()){
            System.out.println("nome: " + docente.getNome());
        }
    }
    */   

在此文件中,我尝试运行为 > Java 应用程序和控制台中向我显示了 2 条记录。 包 com.GestorIpca.factory

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class JpaUtil {
    private static final EntityManagerFactory emf;
    //Método estático
    static{
        //BLoco try
        try
        {
            //Criação de EntityManagerFactory
            emf = Persistence.createEntityManagerFactory("GestorIpca");
        }catch (Throwable e){
            //Controlar as excepções
            System.err.println("A criação de SessionFactory falhou" + e);
            e.printStackTrace();
            throw new ExceptionInInitializerError(e);
        }
    }

    public static EntityManagerFactory getEntityManagerFactory(){
        return emf;
    }
}    

我的 persistence.xml 是自动创建的。放在META-INF里面

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="GestorIpca">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

    <class>com.GestorIpca.shared.Ano</class>
    <class>com.GestorIpca.shared.Categoria</class>
    <class>com.GestorIpca.shared.Curso</class>
    <class>com.GestorIpca.shared.Disciplina</class>
    <class>com.GestorIpca.shared.Disponibilidade</class>
    <class>com.GestorIpca.shared.Docente</class>
    <class>com.GestorIpca.shared.Sala</class>
    <class>com.GestorIpca.shared.Semestre</class>
    <class>com.GestorIpca.shared.TipoCurso</class>
    <class>com.GestorIpca.shared.Turma</class>
    <class>com.GestorIpca.shared.User</class>
        <properties>
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/timetable"/>
            <property name="javax.persistence.jdbc.user" value="root"/>
            <property name="javax.persistence.jdbc.password" value="k771u3"/>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
        </properties>
    </persistence-unit>
</persistence>

最后一步>运行为>网页应用程序 误差>无法连接到数据库并在 Eclipse 控制台中打印堆栈跟踪

[EL Info]: 2011-05-09 10:03:08.78--ServerSession(8068087)--EclipseLink, version: Eclipse Persistence Services - 2.2.0.v20110202-r8913
[EL Info]: 2011-05-09 10:03:09.297--ServerSession(8068087)--file:/C:/Users/Martinho/WorkSpace/GestorIpca/war/WEB-INF/classes/_GestorIpca login successful
Starting Jetty on port 8888
   [WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: java.lang.reflect.InvocationTargetException
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:764)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:727)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:616)
    at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:152)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:534)
    at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:616)
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:474)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:571)
    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:487)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:324)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
Caused by: java.lang.reflect.InvocationTargetException
    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.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:746)
    ... 30 more
Caused by: com.google.gwt.user.client.rpc.SerializationException: Type 'org.eclipse.persistence.indirection.IndirectSet' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = {IndirectSet: not instantiated}
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:614)
    at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:152)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:534)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeClass(ServerSerializationStreamWriter.java:704)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:734)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:616)
    at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:152)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:534)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeClass(ServerSerializationStreamWriter.java:704)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:734)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:616)
    at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
    at com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.serialize(Collection_CustomFieldSerializerBase.java:45)
    at com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.serialize(ArrayList_CustomFieldSerializer.java:38)
    ... 35 more
[ERROR] 500 - POST /gestoripca/greet (127.0.0.1) 57 bytes
   Request headers
      Host: 127.0.0.1:8888
      Connection: keep-alive
      Referer: http://127.0.0.1:8888/GestorIpca.html?gwt.codesvr=127.0.0.1:9997
      Content-Length: 132
      Origin: http://127.0.0.1:8888
      X-GWT-Module-Base: http://127.0.0.1:8888/gestoripca/
      X-GWT-Permutation: HostedMode
      User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.30 Safari/534.30
      Content-Type: text/x-gwt-rpc; charset=UTF-8
      Accept: */*
      Accept-Encoding: gzip,deflate,sdch
      Accept-Language: pt-PT,pt;q=0.8,en-US;q=0.6,en;q=0.4
      Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
   Response headers
      Content-Type: text/plain    

注意:我在包 com.GestorIpca.shared 中更改了从表生成的所有类,

public class Ano implements Serializable 

也更改

public class Ano implements IsSerializable    

了我的GestorIpca.gwt.xml< /strong> 并在末尾添加了这行

<extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.*Collection"/>
<extend-configuration-property name="rpc.blacklist" value="-.*List"/>
<extend-configuration-property name="rpc.blacklist" value="-.*Map"/>
<extend-configuration-property name="rpc.blacklist" value="-.*Collection"/>
<extend-configuration-property name="rpc.blacklist" value="+java.util.HashMap"/>
<extend-configuration-property name="rpc.blacklist" value="+java.util.LinkedHashMap"/>
<extend-configuration-property name="rpc.blacklist" value="+java.util.ArrayList"/>

我缺少什么?

Started a new project from scratch, converted to JPA, my persistence provider is EclipseLink, added the necessary libraries (eclipselink.jar, eclipselink.jar, javax.persistence, mysql-connector-java-5.1). Tested the connection, ping ok. Then created a new package New > JPA > Entities from Tables > Selected all Entities and Key generator > Identity.

GestorIpca.java

            GestorIpcaService.util.getInstance().getLista(new AsyncCallback<ArrayList<Docente>>() {

                @Override
                public void onFailure(Throwable caught) {
                    Window.alert("Erro na Ligacao efectuada");
                    caught.getStackTrace();
                }

                @Override
                public void onSuccess(ArrayList<Docente> result) {
                    Window.alert("Ligacao efectuada com sucesso:" + result.size());
                }
            });    

GestorIpcaService

@RemoteServiceRelativePath("greet")
public interface GestorIpcaService extends RemoteService {
    String greetServer(String name) throws IllegalArgumentException;

    public static class util{
        public static GestorIpcaServiceAsync instance;
        public static GestorIpcaServiceAsync getInstance(){
            if(instance == null){
                instance = GWT.create(GestorIpcaService.class);
            }
        return instance;
        }
    }
    public ArrayList<Docente> getLista() throws IllegalArgumentException;
}    

GestorIpcaServiceAsync

public interface GestorIpcaServiceAsync {
        void greetServer(String input, AsyncCallback<String> callback)
                throws IllegalArgumentException;

        void getLista(AsyncCallback<ArrayList<Docente>> callback);
    }

GestorIpcaServiceImpl

@SuppressWarnings("serial")
public class GestorIpcaServiceImpl extends RemoteServiceServlet implements
        GestorIpcaService {

    public ArrayList<Docente> getLista() throws IllegalArgumentException  {
        //Criamos um EntityManager
        EntityManager em = JpaUtil.getEntityManagerFactory().createEntityManager();
        //Criamos a consulta
        String consulta = "SELECT r from Docente r";
        //Executamos a consulta
        Query q = em.createQuery(consulta);
        ArrayList<Docente> lista = new ArrayList<Docente>(q.getResultList());
        return lista;
    }
/*  public static void main(String args[]){
        GestorIpcaServiceImpl serviceImpl = new GestorIpcaServiceImpl();
        for (Docente docente : serviceImpl.getLista()){
            System.out.println("nome: " + docente.getNome());
        }
    }
    */   

In this file i tried to run as > Java Application and in Console showed me 2 records.
Package com.GestorIpca.factory

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class JpaUtil {
    private static final EntityManagerFactory emf;
    //Método estático
    static{
        //BLoco try
        try
        {
            //Criação de EntityManagerFactory
            emf = Persistence.createEntityManagerFactory("GestorIpca");
        }catch (Throwable e){
            //Controlar as excepções
            System.err.println("A criação de SessionFactory falhou" + e);
            e.printStackTrace();
            throw new ExceptionInInitializerError(e);
        }
    }

    public static EntityManagerFactory getEntityManagerFactory(){
        return emf;
    }
}    

My persistence.xml was created automatically. Placed inside META-INF

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="GestorIpca">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

    <class>com.GestorIpca.shared.Ano</class>
    <class>com.GestorIpca.shared.Categoria</class>
    <class>com.GestorIpca.shared.Curso</class>
    <class>com.GestorIpca.shared.Disciplina</class>
    <class>com.GestorIpca.shared.Disponibilidade</class>
    <class>com.GestorIpca.shared.Docente</class>
    <class>com.GestorIpca.shared.Sala</class>
    <class>com.GestorIpca.shared.Semestre</class>
    <class>com.GestorIpca.shared.TipoCurso</class>
    <class>com.GestorIpca.shared.Turma</class>
    <class>com.GestorIpca.shared.User</class>
        <properties>
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/timetable"/>
            <property name="javax.persistence.jdbc.user" value="root"/>
            <property name="javax.persistence.jdbc.password" value="k771u3"/>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
        </properties>
    </persistence-unit>
</persistence>

Last step > Run as > Web Application
Error > Could not connect to database and print a stack trace in Eclipse Console

[EL Info]: 2011-05-09 10:03:08.78--ServerSession(8068087)--EclipseLink, version: Eclipse Persistence Services - 2.2.0.v20110202-r8913
[EL Info]: 2011-05-09 10:03:09.297--ServerSession(8068087)--file:/C:/Users/Martinho/WorkSpace/GestorIpca/war/WEB-INF/classes/_GestorIpca login successful
Starting Jetty on port 8888
   [WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: java.lang.reflect.InvocationTargetException
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:764)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:727)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:616)
    at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:152)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:534)
    at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:616)
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:474)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:571)
    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:487)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:324)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
Caused by: java.lang.reflect.InvocationTargetException
    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.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:746)
    ... 30 more
Caused by: com.google.gwt.user.client.rpc.SerializationException: Type 'org.eclipse.persistence.indirection.IndirectSet' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = {IndirectSet: not instantiated}
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:614)
    at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:152)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:534)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeClass(ServerSerializationStreamWriter.java:704)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:734)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:616)
    at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:152)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:534)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeClass(ServerSerializationStreamWriter.java:704)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:734)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:616)
    at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
    at com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase.serialize(Collection_CustomFieldSerializerBase.java:45)
    at com.google.gwt.user.client.rpc.core.java.util.ArrayList_CustomFieldSerializer.serialize(ArrayList_CustomFieldSerializer.java:38)
    ... 35 more
[ERROR] 500 - POST /gestoripca/greet (127.0.0.1) 57 bytes
   Request headers
      Host: 127.0.0.1:8888
      Connection: keep-alive
      Referer: http://127.0.0.1:8888/GestorIpca.html?gwt.codesvr=127.0.0.1:9997
      Content-Length: 132
      Origin: http://127.0.0.1:8888
      X-GWT-Module-Base: http://127.0.0.1:8888/gestoripca/
      X-GWT-Permutation: HostedMode
      User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.30 Safari/534.30
      Content-Type: text/x-gwt-rpc; charset=UTF-8
      Accept: */*
      Accept-Encoding: gzip,deflate,sdch
      Accept-Language: pt-PT,pt;q=0.8,en-US;q=0.6,en;q=0.4
      Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
   Response headers
      Content-Type: text/plain    

Note: I changed in package com.GestorIpca.shared all my classes generated from tables

public class Ano implements Serializable 

to

public class Ano implements IsSerializable    

changed also my GestorIpca.gwt.xml and added this lines in end

<extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.*Collection"/>
<extend-configuration-property name="rpc.blacklist" value="-.*List"/>
<extend-configuration-property name="rpc.blacklist" value="-.*Map"/>
<extend-configuration-property name="rpc.blacklist" value="-.*Collection"/>
<extend-configuration-property name="rpc.blacklist" value="+java.util.HashMap"/>
<extend-configuration-property name="rpc.blacklist" value="+java.util.LinkedHashMap"/>
<extend-configuration-property name="rpc.blacklist" value="+java.util.ArrayList"/>

What am i missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

半世晨晓 2024-11-12 13:52:15

我取决于您的实体是如何定义的。也许有 GWT RPC 不喜欢的连接。在这种情况下,我建议创建 DTO 或实施 RequestFactory

I depends on how your entities were defined. Maybe there are connections that GWT RPC doesn´t like. in this case i´d suggest create DTO´s or implement RequestFactory

那支青花 2024-11-12 13:52:15

在不知道您的实体是什么样子的情况下,我会从例外情况中猜测原因可能是您的实体如何通过持久性提供程序得到增强:

这对于 GWT RPC 意味着,当对象准备好通过线路传输时,它实际上与编译器认为要传输的对象不同,因此在尝试反序列化时, GWT RPC机制不再知道类型是什么并且拒绝反序列化它。

引用自:http://code.google.com/intl/ de-DE/webtoolkit/articles/using_gwt_with_hibernate.html

该文章还建议了如何创建 DTO 来解决此问题。

Without knowing what your entities look like I would guess from the exception that the reason is probably how your entities get enhanced by your persistence provider:

What this means for GWT RPC is that by the time the object is ready to be transferred over the wire, it actually isn't the same object that the compiler thought was going to be transferred, so when trying to deserialize, the GWT RPC mechanism no longer knows what the type is and refuses to deserialize it.

Cited from: http://code.google.com/intl/de-DE/webtoolkit/articles/using_gwt_with_hibernate.html

That article also suggests how to create DTOs to solve this problem.

一影成城 2024-11-12 13:52:15

我知道这是一个非常老的问题,但今晚我遇到了这个问题。

GWT 序列化似乎不喜欢 java.util.Set。我几乎觉得它混淆了 java.util.Set 和 org.eclipse.persistence.indirection.IndirectSet。

一旦我将 Set 切换为 ArrayList,错误就消失了。

I know this is a very old question, but I ran into this exact issue tonight.

GWT Serialization doesn't seem to like java.util.Set. I almost feel like it was confusing java.util.Set with org.eclipse.persistence.indirection.IndirectSet.

Once I switched Set to ArrayList, the error went away.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文