I am actually building a chatroom using GAE the problem is that i am storing the clientid and token in chatrromservlet and accessin them in the sayservlet using datastore key but when I am trying to access the datastore from sayservlet using the key i am getting an exception that the entity with the key is not found.
My chatroomservlet
String clientid = request.getParameter("clientid");
ChannelService channelService = ChannelServiceFactory.getChannelService();
String token = channelService.createChannel(clientid);
channelService.sendMessage(new ChannelMessage(token, "Hello World"));
System.out.println("token is ="+token);
JSONObject job=new JSONObject();
job.put("token",token);
Key userkey=KeyFactory.createKey("users", "user1");
System.out.println("user key in chatroom "+ userkey);
Entity ent=new Entity("user");
ent.setProperty("clientid", clientid);
ent.setProperty("token", token);
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
datastore.put(ent);
System.out.println(ent);
and the say servlet is
String message = request.getParameter("message");
String clientid = request.getParameter("clientid");
System.out.println(message);
Key userkey=KeyFactory.createKey("users", "user1");
Entity entity;
DatastoreService datastore = DatastoreServiceFactory
.getDatastoreService();
entity = datastore.get(userkey);
String token = (String) entity.getProperty("token");
System.out.println("token frm db ="+token);
ChannelService channelService = ChannelServiceFactory.getChannelService();
channelService.sendMessage(new ChannelMessage(token, "Hello World"));
System.out.println("message is ="+message);
System.out.println("cid is ="+clientid);
please help me if there is any mistake while accessing.