473,785 Members | 2,488 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Uncaught exception java/lang/NullPointerExce ption

1 New Member
Hello,

I got some of these errors listed below after executing an HTTP Post MIDlet on CLDC/MIDP platform, "Nokia S40 DP 2.0 SDK 1.1" and "S40 5th Edition SDK Feature Pack 1" and even for S60's SDK.. the application stops.

However, it does work only on "Sun Java(TM) Wireless Toolkit 2.5.1 for CLDC" with the same errors displayed, but the application was able to execute successfully.

Errors received are:
Using Untrusted simulated domain
Uncaught exception java/lang/NullPointerExce ption.
WARNING: Traffic View: Listing of TCP/UDP Sent traffic is set to off (see Monitor)
WARNING: Traffic View: Listing of TCP/UDP received traffic is set to off (see Monitor)

The codes are pasted below. I have another Java class file but there seem to be no errors in it.

It would be helpful if someone here could point out which part is causing the null exception error. Thanks.

Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2. import javax.microedition.io.*;
  3. import javax.microedition.midlet.*;
  4. import javax.microedition.lcdui.*;
  5.  
  6. // Package used to execute Record Storing
  7. import javax.microedition.rms.RecordStoreException;
  8.  
  9. public class HttpPostMIDlet extends MIDlet implements CommandListener, Runnable {
  10.  
  11.     private static final String kUsername = "Username";
  12.     private static final String kLatitude = "Latitude";
  13.     private static final String kLongitude = "Longitude";
  14.  
  15.     private Form rsForm;
  16.     private Form hpForm;
  17.  
  18.     private Command okRsFrm;
  19.     private rsPreferences rPreferences;
  20.     private TextField mUsername, mLatitude, mLongitude;
  21.  
  22.     public HttpPostMIDlet() {
  23.         try {
  24.             rPreferences = new rsPreferences("preferences");
  25.         }
  26.         catch (RecordStoreException rse) {
  27.             rsForm = new Form("Exception");
  28.             rsForm.append(new StringItem(null, rse.toString()));
  29.             rsForm.addCommand(new Command("Exit", Command.EXIT, 0));
  30.             rsForm.setCommandListener(this);
  31.             return;
  32.         }
  33.  
  34.         // Record Store Form: Input User name, latitude, and longitude.
  35.         rsForm = new Form("Record Store Form");
  36.  
  37.         mUsername = new TextField("Username", rPreferences.get(kUsername), 32, 0);
  38.         mLatitude = new TextField("Latitude", rPreferences.get(kLatitude), 32, 0);
  39.         mLongitude = new TextField("Longitude", rPreferences.get(kLongitude), 32, 0);
  40.  
  41.         rsForm.append(mUsername);
  42.         rsForm.append(mLatitude);
  43.         rsForm.append(mLongitude);
  44.  
  45.         // Exit Command: Allows the mobile phone user to exit the application
  46.         rsForm.addCommand(new Command("Exit", Command.EXIT, 0));
  47.         rsForm.addCommand(getOkRsFrm()); 
  48.         rsForm.setCommandListener(this);
  49.     }
  50.  
  51.     public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
  52.         // Switch current display when called
  53.         Display display = getDisplay();
  54.         if (alert == null) {
  55.             display.setCurrent(nextDisplayable);
  56.         } else {
  57.             display.setCurrent(alert, nextDisplayable);
  58.         }
  59.     }
  60.  
  61.     public Display getDisplay () {
  62.         return Display.getDisplay(this);
  63.     }
  64.  
  65.  
  66.     public void startApp() {
  67.         Display.getDisplay(this).setCurrent(rsForm);
  68.         Thread t = new Thread(this);
  69.         t.start();
  70.     }
  71.  
  72.     public void pauseApp() {
  73.     }
  74.  
  75.     public void destroyApp(boolean unconditional) {
  76.         rPreferences.put(kUsername, mUsername.getString());
  77.         rPreferences.put(kLatitude, mLatitude.getString());
  78.         rPreferences.put(kLongitude, mLongitude.getString());
  79.         try { 
  80.             rPreferences.save();
  81.         }
  82.         catch (RecordStoreException rse) {
  83.         }
  84.     }
  85.  
  86.     public void run() {
  87.         HttpConnection hc = null;
  88.         InputStream in = null;
  89.         OutputStream out = null;
  90.         try {
  91.             String message = "username=" + mUsername.getString() + "%20Latitude=" + mLatitude.getString() + "%20Longitude=" + mLongitude.getString();
  92.             String url = getAppProperty("PostMIDlet-URL");
  93.  
  94.             hc = (HttpConnection)Connector.open(url);
  95.             hc.setRequestMethod(HttpConnection.POST);
  96.             hc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  97.             hc.setRequestProperty("Content-Length", Integer.toString(message.length()));
  98.  
  99.             out = hc.openOutputStream();
  100.             out.write(message.getBytes());
  101.             in = hc.openInputStream();
  102.             int length = (int)hc.getLength();
  103.             byte[] data = new byte[length];
  104.             in.read(data);
  105.             String response = new String(data);
  106.             StringItem stringItem = new StringItem(null, response);
  107.             hpForm.append(stringItem);
  108.             hpForm.setTitle("Send and Retrieve data: Done.");
  109.         }
  110.         catch (IOException ioe) {
  111.             StringItem stringItem = new StringItem(null, ioe.toString());
  112.             hpForm.append(stringItem);
  113.             hpForm.setTitle("Send and Retrieve data: Done.");
  114.         }
  115.         finally {
  116.             try {
  117.                 if (out != null) out.close();
  118.                 if (in != null) in.close();
  119.                 if (hc != null) hc.close();
  120.             }
  121.             catch (IOException ioe) {}
  122.         }
  123.     }
  124.  
  125.     public void commandAction(Command c, Displayable s) {
  126.         if(c.getCommandType() == Command.EXIT) {
  127.             destroyApp(true);
  128.             notifyDestroyed();
  129.         }
  130.         if (s == rsForm) {
  131.             if (c == okRsFrm) {
  132.                 // If Ok command is executed, then show hpForm
  133.                 destroyApp(true);
  134.                 switchDisplayable(null, getHpForm());
  135.             }
  136.         }
  137.     }
  138.  
  139.     public Command getOkRsFrm() {
  140.         if (okRsFrm == null) {
  141.             okRsFrm = new Command("Ok", Command.OK, 0);
  142.         }
  143.         return okRsFrm;
  144.     }
  145.  
  146.     public Form getHpForm() {
  147.         if (hpForm == null) {
  148.             // Http Post Form: Send data to server and returns the result if
  149.             // data is stored successfully on the server's positionData.txt
  150.             hpForm = new Form("HTTP Post Form");
  151.             hpForm.addCommand(new Command("Exit", Command.EXIT, 0));
  152.             hpForm.setCommandListener(this);
  153.             run();
  154.         }
  155.         return hpForm;
  156.     }
  157. }
May 3 '08 #1
2 7476
Dököll
2,364 Recognized Expert Top Contributor
What do the folks @ Nokia have on this... Did a quick search in Google and found you're not the only one ahving this issue...
Dec 21 '08 #2
JosAH
11,448 Recognized Expert MVP
@josephx
It would also be helpful if you had copied the complete stack trace of the error; line numbers and method names can be a big help.

kind regards,

Jos
Dec 22 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
3291
by: Matt Bostock | last post by:
Hi, When I validate this page: http://www.drfunkenstein.net/using http://jigsaw.w3.org/css-validator/, I get the following results: http://jigsaw.w3.org/css-validator/validator?profile=css2&warning=2&uri=http%3A//www.drfunkenstein.net/ Or briefly: "Uncaught error java.lang.Exception: Import loop detected in
0
1597
by: gezkk | last post by:
hi, i m using http proxy service to get proxy and host to applet, its working fine with jdk1.5 but getting java.lang.NullPointerException in jdk1.6 And the following is mseeage contains java console java.lang.NullPointerException at com.atonesoftware.web.applet.transfer.client.http.HTTPTransfer.autoDetectProxy(HTTPTransfer.java:326)
3
2912
by: arasub | last post by:
ep 20, 2007 11:25:57 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.5.0_12\bin;.;C:\WINDOWS\System32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\j2sdk_nb\j2sdk1.4.2\bin;C:\Program...
9
4136
by: ajos | last post by:
hi all, im getting some problems in my javascript validations..... my jsp code--> 8: <head> 9: <title>Budget Master Administration</title> 10: <meta name="GENERATOR" content="Microsoft FrontPage 3.0"> 11: <html:javascript src="bscript.js" method="everything(this)" staticJavascript="false"/> 12: <!-- <SCRIPT LANGUAGE="JavaScript" SRC="bscript.js"></SCRIPT> --> 13: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4
2143
by: vasavimaruthi | last post by:
hi, i got class not found exception of a small jdbc program in windows. the program is like this import java.sql.*; public class Db1 { public static void main(String a) throws Exception { Class.forName("oracle.jdbc.driver.OracleDriver");
1
1789
by: GHKASHYAP | last post by:
Hi this is the exception i am getting when i am trying to run this application: Exception in thread "main" java.lang.NullPointerException thanks in advance.. package com.inventive.StockMarketTrading; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent;
0
1650
by: ycinar | last post by:
hey all, i am working on a Java project using JBuilder.. when i build my code its fine, but when comes to run, it doesnt run and displays the following logs.. i think there is JDK conflict.. actually when i build it, it creates a jar file which is totally fine (i can confirm that because i use that jar file in another project) any idea on how to get around this? maybe i could try to run it from the command line, but dont know how to run...
3
7661
by: ohadr | last post by:
hi, i get Exception in thread "main" java.lang.NullPointerException when i run my application. the exact error is: "Exception in thread "main" java.lang.NullPointerException at sortmergejoin.MergeJoin.Field(MergeJoin.java:204) at sortmergejoin.MergeJoin.SMJoin(MergeJoin.java:84) at sortmergejoin.MergeJoin.<init>(MergeJoin.java:34) at sortmergejoin.Main.main(Main.java:24) Java Result: 1"
1
6757
by: onlinegear | last post by:
HI i am writing this for college i know i have loads of combo boxes with nothing in the i havent got that far yet. but every time i run this is comes up with this erro run: Exception in thread "main" java.lang.NullPointerException at java.awt.Container.addImpl(Container.java:1041) at java.awt.Container.add(Container.java:365) at orderingsystem.OrderingSystem.<init>(OrderingSystem.java:261) at...
0
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.