java.lang.NullPointerException Expected null for key value!

73 views
Skip to first unread message

rayma...@gmail.com

unread,
Jul 17, 2013, 5:11:15 AM7/17/13
to codenameone...@googlegroups.com
Hi everyone, i am working on a codename project that has a login form as the main page and has other forms after logon, i have created a database which contains of user tables and all. Im trying to login using the login credentials in the database. And i get the folowing error message

java.lang.NullPointerException
Expected null for key value!

Fabrice Kabongo

unread,
Jul 17, 2013, 5:14:02 AM7/17/13
to codenameone...@googlegroups.com, rayma...@gmail.com
Can you please send the code you use

rayma...@gmail.com

unread,
Jul 17, 2013, 5:21:55 AM7/17/13
to codenameone...@googlegroups.com, rayma...@gmail.com

My code for the button is as follows

protected void onFrmLogin_BtnLoginAction(Component c, ActionEvent event) {
        NetworkManager.getInstance().start();
        Hashtable pairs = new Hashtable();
        pairs.put("username", findUsername(Display.getInstance().getCurrent()).getText());
        pairs.put("password", findPassword(Display.getInstance().getCurrent()).getText());
        final Form main = (Form) createContainer(getResourceFilePath(), "Main");
      //  final Form SelectAccount = (Form) createContainer(getResourceFilePath(), "FrmSelectAccount");
        Connection request = new Connection("login", pairs) {

            int state = 0;

            @Override
            protected void readResponse(InputStream input) throws IOException {

                JSONParser p = new JSONParser();
                Hashtable userInfo = p.parse(new InputStreamReader(input));
                String singleUser = (String) userInfo.get("result");
               
          //Dialog.show("Not Succesful", "Invalid Credentials", "OK", null);

                if (singleUser.equals("OK")) {
                    user = new User();
                    user.setName(userInfo.get("name").toString());
                    user.setSurname(userInfo.get("surname").toString());
                    //user.setAccountNumber(userInfo.get("account").toString());
                    user.setMobileNumber(userInfo.get("msisdn").toString());
                    //user.setSessionId(userInfo.get("uid").toString());
//                    SelectAccount.show();
                 //   Dialog.show("Success","Logging In", null, "OK");              
}
            }
        };
        NetworkManager.getInstance().addToQueue(request);
        //progress.show();

    }

rayma...@gmail.com

unread,
Jul 17, 2013, 5:22:52 AM7/17/13
to codenameone...@googlegroups.com, rayma...@gmail.com


On Wednesday, July 17, 2013 11:14:02 AM UTC+2, Fabrice Kabongo wrote:
Can you please send the code you use


 My code is as follows

Fabrice Kabongo

unread,
Jul 17, 2013, 6:12:15 AM7/17/13
to codenameone...@googlegroups.com, rayma...@gmail.com

check the JSON you receive from you server maybe there is a index you use but that miss on your json result.
If there is not wrong on you json,

Try to see on your connection class, if you did miss something while using username and password index to populate your connectionRequest object.

if there something wrong please send us all the expection message and try to find out the exactly line that generate the exception.

Shai Almog

unread,
Jul 17, 2013, 12:07:49 PM7/17/13
to codenameone...@googlegroups.com, rayma...@gmail.com
Check out the console on NetBeans/Eclipse it should include the stack for the exception and should include the actual line numbers/methods.
Reply all
Reply to author
Forward
0 new messages