Hey all,

I'm trying to add a SystemAccount class to my project by using the
emailAddress of the loginInfo as an ID for my SystemAccount class.
I've added a SystemAccountService and SystemAccountServiceAsync
interfaces that contains the method to addAccount() and getAccount()
which would be stored as persistent JDO objects.  Then on the server
side i have the code for these methods.

The solution GWT compiles no problem, but when i run the application
and go to the entry page it pops up a javascript alert saying 'The
response could not be deserialized" and i can't find out why.

Ill list what i have in my classes

SystemAccount:

import java.io.Serializable;

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

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class SystemAccount implements Serializable  {

        private static final long serialVersionUID = 1L;
        @PrimaryKey
        @Persistent
        private String emailAddress;
        public static final int SYSTEMADMIN = 0;
        public static final int POOLADMIN = 1;
        public static final int POOLUSER = 2;
        @Persistent
        private String nickname;
        @Persistent
        private int accountType;

        public SystemAccount() {
                accountType = POOLUSER;
                nickname = "";
        }

          public String getEmailAddress() {
            return emailAddress;
          }

          public void setEmailAddress(String emailAddress) {
            this.emailAddress = emailAddress;
          }

          public String getNickname() {
            return nickname;
          }

          public void setNickname(String nickname) {
            this.nickname = nickname;
          }

          public int getAccountType() {
            return accountType;
          }

          public void setAccountType(int type) {
            this.accountType = type;
          }

}


SystemAccountService :

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@RemoteServiceRelativePath("systemaccount")
public interface SystemAccountService extends RemoteService {
  public SystemAccount getAccount(String emailAddress);
  public void addAccount(SystemAccount Account);
}

SystemAccountServiceAsync:

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

public interface SystemAccountServiceAsync {
  public void getAccount(String emailAddress,
AsyncCallback<SystemAccount> async);
  public void addAccount(SystemAccount Account, AsyncCallback<Void>
async);
}


SystemAccountServiceImpl:

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;

import cs.ubc.ca.cs310.HockeyPool.client.SystemAccount;
import cs.ubc.ca.cs310.HockeyPool.client.SystemAccountService;

public class SystemAccountServiceImpl extends RemoteServiceServlet
implements
    SystemAccountService {

/**
         *
         */
        private static final long serialVersionUID = 1L;
private static final PersistenceManagerFactory pmFactory =
JDOHelper.getPersistenceManagerFactory("transactions-optional");
public static PersistenceManagerFactory getPersistenceManagerFactory()
{
        return pmFactory;
}

public void addAccount(SystemAccount Account) {
        PersistenceManager pm =
getPersistenceManagerFactory().getPersistenceManager();
        try {
                pm.currentTransaction().begin();
                pm.makePersistent(Account);
                pm.flush();
                pm.currentTransaction().commit();
        } finally {
                pm.close();
        }

}

public SystemAccount getAccount(String emailAddress) {
        PersistenceManager pm =
getPersistenceManagerFactory().getPersistenceManager();

        SystemAccount account = null;
        try {
                pm.currentTransaction().begin();
                account = pm.getObjectById(SystemAccount.class, emailAddress);
        } catch (Exception e) {
                pm.currentTransaction().rollback();
                e.printStackTrace();
        } finally  {
                pm.close();
        }
        return account;
}

}

For getAccount i didn't know how to check if the account actually
exists as a persistent object so i tried to retrieve it and if that
failed then i would just assume that the account doesn't exist yet.
So if somebody could also tell me a better way to do that that would
be great.

But my main issue is getting past the 'the response could not be
deserialized' error

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to