gwt openpa serialization problem

115 views
Skip to first unread message

YinYanSI

unread,
Oct 2, 2012, 9:04:22 AM10/2/12
to google-we...@googlegroups.com
I have gwt app with openjpa 2.0

gwt compiler compile OK 
Compiling module skladisce.SkladisceGWT
   Compiling 6 permutations
      Compiling permutation 0...
      Compiling permutation 1...
      Compiling permutation 2...
      Compiling permutation 3...
      Compiling permutation 4...
      Compiling permutation 5...
   Compile of permutations succeeded
Linking into /home/MyUser/IBM/rationalsdp/workspace/SkladisceWeb/WebContent/skladiscegwt
   Link succeeded
   Compilation succeeded -- 129.166s

but runtime error happend.


Why do I get error serialization? What does 'org.apache.openjpa.kernel.DelegatingResultList'  has with serialization ???

my ERROR:

com.ibm.ws.webcontainer.webapp.WebApp log SRVE0296E: [SkladisceWebEAR#SkladisceWeb.war][/SkladisceWeb][Servlet.LOG]:.Exception while dispatching incoming RPC call:.com.google.gwt.user.client.rpc.SerializationException: Type 'org.apache.openjpa.kernel.DelegatingResultList' 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 = [skladisce.shared.entities.LoksObrat@4eb44eb4, skladisce.shared.entities.LoksObrat@76dc76dc, skladisce.shared.entities.LoksObrat@77dd77dd, skladisce.shared.entities.LoksObrat@78e278e2, skladisce.shared.entities.LoksObrat@79f879f8, skladisce.shared.entities.LoksObrat@7afc7afc, skladisce.shared.entities.LoksObrat@bc00bc, skladisce.shared.entities.LoksObrat@1f001f0]


MY gwt.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='skladiscegwt'>

  <inherits name='com.google.gwt.user.User'/>
  <inherits name='com.google.gwt.user.theme.clean.Clean'/>
  <inherits name="com.google.gwt.logging.Logging"/>

  <source path="skladisce.shared.entities"></source>
  <source path="org.apache.openjpa.kernel.DelegatingResultList"></source>

  
 
  <entry-point class='skladisce.client.SkladisceGWT'/>
 
  <source path='client'/>
  <source path='shared'/>

  <set-property name="gwt.logging.logLevel" value="INFO"/>
  <set-property name="gwt.logging.enabled" value="FALSE"/>
  <set-property name="gwt.logging.consoleHandler" value="ENABLED"/> 

</module>
--------------------

@SuppressWarnings("serial")
public class SkladisceServiceImpl extends RemoteServiceServlet implements SkladisceService {

public List<LoksObrat> getAllObrat(String version) throws MajorMinorException {
log.trace("> getAllObrat");

if(!version.equals(AppInfo.VERSION))
throw new MajorMinorException();

LoksObratManager loksObratManager = new LoksObratManager(emf);
// listLoksObrat = loksObratManager.findAllToLokpVrsta();
log.trace("< getAllObrat");
return loksObratManager.findAll();
}
--------------------------------------------

@SuppressWarnings("unchecked")
@JPAManager(targetEntity = skladisce.shared.entities.LoksObrat.class)
public class LoksObratManager {

@Action(Action.ACTION_TYPE.FIND)
public List<LoksObrat> findAll() {
List<LoksObrat> list = null;
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("LoksObrat.findAll");
list = query.getResultList();
//for (LoksObrat loksObrat : list) {
// loksObrat.getLokpObratStrms();
//}
} finally {
em.close();
}
System.out.println( "Bogdan tag: "+list.toString() );
return list;
}
---------------------------------

My entiry class is:
@Entity
@Table(name="LOKS_OBRAT", schema="SKL")
@NamedQueries({@NamedQuery(name="LoksObrat.findAll", query="SELECT lo FROM LoksObrat lo")})
public class LoksObrat implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="ID_OBRAT")
private int idObrat;

@Column(name="DATURA_ZAD_SPR")
private Timestamp daturaZadSpr;

private String krnaziv;

private String opis;

@Column(name="OSEBA_ZAD_SPR")
private String osebaZadSpr;

private String sifra;

    @Temporal( TemporalType.DATE)
@Column(name="VELJA_DO")
private Date veljaDo;

    @Temporal( TemporalType.DATE)
@Column(name="VELJA_OD")
private Date veljaOd;

@Column(name="VRSTNI_RED")
private short vrstniRed;

//bi-directional many-to-one association to LokpObratStrm
@OneToMany(mappedBy="loksObrat", fetch = EAGER)
private List<LokpObratStrm> lokpObratStrms;

    public LoksObrat() {
    }

public int getIdObrat() {
return this.idObrat;
}

public void setIdObrat(int idObrat) {
this.idObrat = idObrat;
}

public Timestamp getDaturaZadSpr() {
return this.daturaZadSpr;
}

public void setDaturaZadSpr(Timestamp daturaZadSpr) {
this.daturaZadSpr = daturaZadSpr;
}

public String getKrnaziv() {
return this.krnaziv;
}

public void setKrnaziv(String krnaziv) {
this.krnaziv = krnaziv;
}

public String getOpis() {
return this.opis;
}

public void setOpis(String opis) {
this.opis = opis;
}

public String getOsebaZadSpr() {
return this.osebaZadSpr;
}

public void setOsebaZadSpr(String osebaZadSpr) {
this.osebaZadSpr = osebaZadSpr;
}

public String getSifra() {
return this.sifra;
}

public void setSifra(String sifra) {
this.sifra = sifra;
}

public Date getVeljaDo() {
return this.veljaDo;
}

public void setVeljaDo(Date veljaDo) {
this.veljaDo = veljaDo;
}

public Date getVeljaOd() {
return this.veljaOd;
}

public void setVeljaOd(Date veljaOd) {
this.veljaOd = veljaOd;
}

public short getVrstniRed() {
return this.vrstniRed;
}

public void setVrstniRed(short vrstniRed) {
this.vrstniRed = vrstniRed;
}

public List<LokpObratStrm> getLokpObratStrms() {
return this.lokpObratStrms;
}

public void setLokpObratStrms(List<LokpObratStrm> lokpObratStrms) {
this.lokpObratStrms = lokpObratStrms;
}
}
-------------------------

Jens

unread,
Oct 2, 2012, 9:47:58 AM10/2/12
to google-we...@googlegroups.com
Your entity is serializable and you want to send it from server to client. Most JPA providers enhance entity classes to support features like lazy loading, so although you have used a java.util.List in your entity code it could very well become an org.apache.openjpa.kernel.DelegatingResultList after the class has been enhanced by your JPA provider. You should check this in the OpenJPA documentation.

If this class does not implement serializable or is not visible to the GWT compiler it does not end up in your serialization policy file (thats the <hash>.rpc file). The server checks against this file during serialization and gives you the above error.

A common way to solve this is to use DTO classes. GWT's RequestFactory for example does something similar by using Autobeans on the client side and let the server classes be pure server classes.

-- J.
Reply all
Reply to author
Forward
0 new messages