ArrayList throws google storage search exception (with gwt, java)

I am using the Google Web Toolkit with java and google datastore as a database. The entity class has an arraylist and when I try to get data from the database, I get an exception:

The type 'org.datanucleus.sco.backed.ArrayList' was not included in the type set that can be serialized by this SerializationPolicy object or its class, may not load. For security reasons, this type will not be serialized.

I am using JPA.

Entity Code:

 package com.ver2.DY.client;

 import java.io.Serializable;
 import java.util.ArrayList;

 import javax.jdo.annotations.IdGeneratorStrategy;
 import javax.jdo.annotations.PersistenceCapable;
 import javax.jdo.annotations.Persistent;
 import javax.jdo.annotations.PrimaryKey;

 import com.google.gwt.user.client.rpc.IsSerializable;

 @PersistenceCapable
 public class ChatInfo implements Serializable, IsSerializable{
  @PrimaryKey
  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  private Long topicId;

  @Persistent
  private String chatTopic;

  @Persistent
  private ArrayList<String> messages = new ArrayList<String>();

  @Persistent
  private boolean isFirstPost;

  public ChatInfo()
  {

  }


  public Long getTopicId() {    
   return topicId;
  }
  public void setTopicId(Long topicId) {
   this.topicId = topicId;
  }
  public String getChatTopic() {
   return chatTopic;
  }
  public void setChatTopic(String chatTopic) {
   this.chatTopic = chatTopic;
  }
  public ArrayList<String> getMessages() {
   return messages;
  }
  public void addMessage(String newMsg) {
    messages.add(newMsg);
  }

  public boolean isFirstPost() {
   return isFirstPost;
  }
  public void setFirstPost(boolean isFirstPost) {
   this.isFirstPost = isFirstPost;
  }

 }

Method in db class:

@Transactional
  public ChatInfo[] getAllChat() {
   PersistenceManager pm = PMF.get().getPersistenceManager();
   List<ChatInfo> chats = null;
   ChatInfo[] infos = null;
   String query = "select from " + ChatInfo.class.getName();
   try{
    chats = (List<ChatInfo>) pm.newQuery(query).execute();


   infos = new ChatInfo[chats.size()];
   for(int i=0;i<chats.size();i++)
   {
    infos[i] = new ChatInfo();
    infos[i] = (ChatInfo) chats.get(i);
   }
   }
   finally{
    pm.close();
   }
   return infos;

  }

This is a bit strange, because before I could insert and extract data, but now it throws an exception. While searching the web I could find that I need to convert an Arraylist from some type of DataNucleus to java util, but not sure how to do it.

+3
2

, GWT RPC ( , ).

org.datanucleas.sco.backed.ArrayList .

GWT JPA.

+2

. , java.util.ArrayList, org.datanucleus.sco.backed.ArrayList. , RPC, , , .

, -, ArrayList , RPC, . , .

+1

Source: https://habr.com/ru/post/1742212/


All Articles