Looks to me like this is saying your server-side code throws a 
NullPointerException, so you get it on the client-side.

On Saturday, November 2, 2013 9:15:37 PM UTC+1, zhenli...@gmail.com wrote:
>
> I'm now currently extracting out data from my database using rpc but 
> whenever I click the button it does generates a error and my onFailure 
> command is being triggered always.
> Below is my Code for the program.
>
> public class PleaseWork implements EntryPoint {private TextBox textbox2 = new 
> TextBox();private Label Hi = new Label("New 
> label");@SuppressWarnings("deprecation")public void onModuleLoad() {
>     RootPanel rootPanel = RootPanel.get();
>     Button btnNewButton = new Button("New button");
>     btnNewButton.addClickListener(new ClickListener() {
>         public void onClick(Widget event) {
>             HelpConnectionAsync Abra =(HelpConnectionAsync) 
> GWT.create(HelpConnection.class);
>             ServiceDefTarget target = (ServiceDefTarget) Abra;
>             String moduleRelativeURL = GWT.getModuleBaseURL() + 
> "MySQLConnection";
>             target.setServiceEntryPoint(moduleRelativeURL);
>             AsyncCallback callback = new AsyncCallback(){
>             public void onSuccess (Object result){
>                 textbox2.setText((String)result);
>                 Hi.setText("You Pass!");            }
>             public void onFailure(Throwable caught) {
>                 caught.printStackTrace();
>                 Hi.setText("You fail!");            }
>             };
>             Abra.sensors(callback);
>         }
>     });
>     rootPanel.add(btnNewButton, 23, 30);
>     rootPanel.add(textbox2,23, 70);     
>     rootPanel.add(Hi, 23, 130);}
>
> And this is my Serverside code 
> public class MySQLConnection extends RemoteServiceServlet implements 
> HelpConnection {
>       private Connection conn = null;
>       private ResultSet rs = null;
>     private PreparedStatement pstmt = null;
>       
>       public static Connection getConnection() throws Exception {
>           String driver = "com.mysql.jdbc.Driver";
>           String url = "jdbc:mysql://localhost:3306/temperature";
>           String username = "root";
>           String password = "123456";
>           Class.forName(driver);
>           Connection conn = DriverManager.getConnection(url, username, 
> password);
>           return conn;
>         }
>
>       @Override
>       public String[] sensors() throws Exception {
>               String [] user = null;
>               try {
>                     conn = getConnection();
>
>                     rs = pstmt.executeQuery("SELECT ID, times FROM sensor 
> ORDER BY id DESC LIMIT 1;");
>                     // extract data from the ResultSet
>                     while (rs.next()) {
>                       user = new String[] {rs.getString(1),rs.getString(2)};
>                     }
>                   } catch(SQLException e) {
>                     e.printStackTrace();
>                   } finally {
>                     try {
>                       rs.close();
>                       pstmt.close();
>                       conn.close();
>                     } catch (SQLException e) {
>                       e.printStackTrace();
>                     }
>                   }
>                   return user;
>       }
>
> }
>
> While running the application it generates this error message on the console 
> side which is telling me why onFailure Command is always being
>  triggered but i do not understand about it.
> java.lang.NullPointerException
>       at 
> com.google.gwt.user.client.rpc.core.java.lang.NullPointerException_FieldSerializer.instantiate(NullPointerException_FieldSerializer.java:16)
>       at 
> com.google.gwt.user.client.rpc.core.java.lang.NullPointerException_FieldSerializer.create(NullPointerException_FieldSerializer.java:25)
>       at 
> com.google.gwt.user.client.rpc.impl.SerializerBase.instantiate(SerializerBase.java:115)
>       at 
> com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:396)
>       at 
> com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
>       at 
> com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:216)
>       at 
> com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:258)
>       at 
> com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:412)
>       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:338)
>       at 
> com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
>       at 
> com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
>       at 
> com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
>       at 
> com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
>       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:242)
>       at sun.reflect.GeneratedMethodAccessor38.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:293)
>       at 
> com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
>       at 
> com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
>       at java.lang.Thread.run(Unknown Source)
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to