title: getting IllegalArgumentException when trying to create key for entity
body: <p>I'm working on Google App Engine and I'm stuck at a point. I'm trying to create a key for my entity. Here is the code:</p>
  
  <pre><code>Element child = (Element) itr.next();
                  String name = "";
                  if(child.getQualifiedName().equals("name")){
                      name += child.getText();
                  }
                  Key drugKey = KeyFactory.createKey("DrugTarget", name);
  </code></pre>
  
  <p>I'm 100% sure that child.getText() doesn't return null. I tested it already. I have another piece of code that creating Key works perfectly. Both seem similar to each other.</p>
  
  <pre><code>String drug = req.getParameter("drugname");
  Key drugKey = KeyFactory.createKey("DrugTarget", drug);
  </code></pre>
  
  <p>I really did'nt understand why it gives error. First piece of code is belonged to a Java Class and I call this class in a Java Servlet Class. The second one is belonged to a Java Servlet Class. But I think the problem is different. Could you please help? Thanks.</p>
  
  <p>Edited Part:</p>
  
  <pre><code>if(child.getQualifiedName().equals("name")){
                      if(child.getText() != null){
                      name = child.getText();
                      }
                      else{
                          name = "asd";
                      }
                  }
  </code></pre>
  
  <p>I put this into my code, still getting null error. child.getText() does not return null and name is not equal to "asd".</p>
  
  <p>Forgot to add Error Message:</p>
  
  <pre><code>Uncaught exception from servlet
  java.lang.IllegalArgumentException: name cannot be null or empty
  at com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java:73)
  at com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java:60)
  at guestbook.saxParser2.getDrug(saxParser2.java:42)
  at guestbook.SignGuestbookServlet.doPost(SignGuestbookServlet.java:77)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
  at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
  at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:102)
  at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
  at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
  at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
  at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
  at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
  at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
  at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
  at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
  at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
  at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
  at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:266)
  at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
  at org.mortbay.jetty.Server.handle(Server.java:326)
  at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
  at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
  at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
  at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
  at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
  at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:447)
  at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:454)
  at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:461)
  at com.google.tracing.TraceContext.runInContext(TraceContext.java:703)
  at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:338)
  at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:330)
  at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:458)
  at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
  at java.lang.Thread.run(Thread.java:679)
  </code></pre>