0

I am facing below mentioned error when calling the GWT rpc method to retrieve some data. Every thing is working pretty fine on Windows but rpc calls are throwing this exception on ubuntu. Application is deployed on Tomcat. I have see tried all work arounds for serialization but nothing works.. Please help !!!

SEVERE: Exception while dispatching incoming RPC call com.google.gwt.user.client.rpc.SerializationException: Type 'javax.persistence.NoResultException' 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 = javax.persistence.NoResultException: No entity found for queryat com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:667)

The code snippet from my SettingsDAO.java

public SettingsDTO findSettingsByName(String name) {
    TypedQuery<SettingsDTO> query = getEntityManager().createQuery("SELECT u FROM SettingsDTO u WHERE u.name = :name", SettingsDTO.class);
    return query.setParameter("name", name).getSingleResult();
}

code snippet from GWT Service Implementaion.

@Transactional(readOnly=true)
public Integer getRemainingAttempts(String username) {
    SettingsDTO settings = settingsDAO.findSettingsByName("STD");
    int maxLogin = settings.getNloginAttempts();
    UserDTO user = userDAO.findUserByName(username);
    int locked = user.getLocked();
    if (locked == -1) {
        return locked;
    } else if (locked >= maxLogin) {
        return 0;
    } else {
        return (maxLogin-locked);
    }
}
Ali Baba
  • 113
  • 2
  • 10

1 Answers1

0

I think the Exception is misleading.

Every Class, which should be serialized, must be included in the serialization-policy. I assume, that you are using a different user for your tests, than with linux.

Now you get a NoResultException and this cannot be serialized, because the GWT-compiler does not know, that it should be serialized (because it is not defined in any interface).

You can do two things:

  1. Catching this exception (as mentioned in the other answer)
  2. Throwing the exception in your interface

    public Integer getRemainingAttempts(String username) throws NoResultException {

Now the compiler gets the information, that this class should be serialized.

Christian Kuetbach
  • 15,850
  • 5
  • 43
  • 79
  • Hi Christian, user is same for both environments..Every configuration is exactly same.. – Ali Baba Jun 02 '14 at 15:42
  • I have just deleted my answer because it did not provide a solution for the question. Also, this one is more complete. I am not worried about the exception, because in SO are well 'documented'. The thing is, why in Linux and not in Windows? I am still curious :) – apanizo Jun 02 '14 at 17:10
  • I will post solution after fixing it.. Thanx for ur curiosity.. This is also pinching me why windows not linux :) – Ali Baba Jun 02 '14 at 17:27