title: GWT serialization over RPC
body: <p>I couldn't find a solution for this problem even after going through tons of blogs.</p>
  
  <ol>
  <li>Yes, my model(POJOs) implement Serializable (tried with IsSerializable as well)</li>
  <li><p>I had success earlier with RPCs but i dont know why am i getting this error now:   </p>
  
  <pre><code>com.google.gwt.user.client.rpc.StatusCodeException: 500 The call failed on the server; see server log for details
      at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:209)
      at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
      at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
      at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
      at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
      at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
      at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
      at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
      at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
      at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
      at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
      at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
      at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
      at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
      at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
      at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
      at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
      at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
      at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
      at java.lang.Thread.run(Unknown Source)
  </code></pre></li>
  </ol>
  
  <hr>
  
  <h3>Server Stack Trace:</h3>
  
  <pre><code>Starting Jetty on port 8888
          [WARN] Exception while dispatching incoming RPC call
          com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract com.project.package.gwt.shared.User com.project.package.gwt.client.ProService.loginServer(java.lang.String,java.lang.String)' threw an unexpected exception: java.lang.NullPointerException
      at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385)
      at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)
      at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
      at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
      at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
      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:487)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.Server.handle(Server.java:324)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
      at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
      at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
      Caused by: java.lang.NullPointerException
      at com.project.package.gwt.server.ProServiceImpl.loginServer(ProServiceImpl.java:85)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
      ... 22 more
  </code></pre>
  
  <p>Can`t i serialize Strings over the wire too?</p>
  
  <p>And the null pointer exception is showing because the RPC is not succesfull. I expect an object to be returned if the RPC is successfull</p>
  
  <p>Adding Source code </p>
  
  <pre class="lang-java prettyprint-override"><code>com.project.package.gwt.server.ProServiceImpl.loginServer.java
  
  public User loginServer(String uname, String password) {
  
      System.out.println("Making User Login Call to the server");
      System.out.println("Username is : "+uname+" Password is : "+password);
  
      return loginObj.validateLogin(uname, password);
  }
  </code></pre>
  
  <p>validate login method, which validates an user</p>
  
  <pre><code>public User validateLogin(String username, String password) {
  
      System.out.println("Inside Server/");
      //ApplicationContext ac = new ClassPathXmlApplicationContext("jdbc-context.xml");
      ApplicationContext ac = new ClassPathXmlApplicationContext("jdbc-context.xml");
      DataSource dataSource = (DataSource) ac.getBean("dataSource");
  
      JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
  
      System.out.println("Inside Server/Login Handler");
  
      String result = null;
      String query = "SELECT emp_name FROM emp_name = ? AND emp_password = ?";
  
      try {
          result = jdbcTemplate.queryForObject(query, String.class);
      } catch (EmptyResultDataAccessException e) {
          // TODO: handle exception#
          e.printStackTrace();
      }
  
      if (result == null) {
          System.out.println("The result of the SQL query is null");
      } else {
          System.out.println("The result of the SQL query is " + result);
          user.setUsername(result);
      }
      return user;
  }
  
  }
  </code></pre>
  
  <p>The control is not going inside the validate login method(Inside Server / is not printing) which means my RPC is failing  and hence an NPE </p>