GWT with JDO problem

后端 未结 6 1460
抹茶落季
抹茶落季 2020-12-15 01:24

I just start playing with GWT I\'m having a really hard time to make GWT + JAVA + JDO + Google AppEngine working with DataStore. I was trying to follow different tutorial bu

6条回答
  •  北海茫月
    2020-12-15 02:07

    Could it be that you forgot to create the implementation for the RPCCallsService? I can't see it from the list of files that you have.

    You should have a file called RPCCallsServiceImpl.java in RPCCalls/src/com/example/rpccalls/server/, it is the implementation file for the interface RPCCallsService.java.

    It will look something like this:

    import javax.jdo.JDOHelper;
    import javax.jdo.PersistenceManager;
    import javax.jdo.PersistenceManagerFactory;
    import com.google.gwt.user.server.rpc.RemoteServiceServlet;
    import com.example.rpccalls.client.RPCCallsService;
    
    public class RPCCallsServiceImpl extends RemoteServiceServlet implements RPCCallsService {
    
      // Factory to get persistence manager object later
      private static final PersistenceManagerFactory PMF = JDOHelper.getPersistenceManagerFactory("transactional-optional");
    
      public String saveName(Person p) {
        // Data Store need persistence manager object for writing to it 
        PersistenceManager pm = PMF.getPersistenceManager();
    
        // Recommended way to save an object to the data store
        try {
          pm.makePersistent(p);
        } finally {
          pm.close();
        }
    
        // You want it to return string
        return p.getName();
      }
    
    }
    

    Hopefully this help you to solve the problem. Cheers :)

提交回复
热议问题