2

I am currently trying to develop an application using netbeans 6.9.1, but when I try to run the program I am getting the following error

Uncaught exception: java.lang.IllegalArgumentException
    at javax.microedition.io.Connector.openPrim(), bci=31
    at javax.microedition.io.Connector.open(), bci=3
    at javax.microedition.io.Connector.open(), bci=3
    at javax.microedition.io.Connector.open(), bci=2
    at RSSParser$1.run(RSSParser.java:32)

this error is coming from this code

public void parse(final String url) {
Thread t = new Thread() {
  public void run() {
    // set up the network connection
    HttpConnection hc = null;

    try {
      hc = (HttpConnection)Connector.open(url);
      parse(hc.openInputStream());
    }
    catch (IOException ioe) {
      mRSSListener.exception(ioe);
    }
    finally {
      try { if (hc != null) hc.close(); }
      catch (IOException ignored) {}
    }
  }
};
t.start();
}

This method is being called from another class here

public void startApp() {
if (mDisplay == null)
  mDisplay = Display.getDisplay(this);

if (mInitialized == false) {
  // Put up the waiting screen.
  Screen waitScreen = new Form("Connecting...");
  mDisplay.setCurrent(waitScreen);
  // Create the title list.
  mTitleList = new List("Headlines", List.IMPLICIT);
  mExitCommand = new Command("Exit", Command.EXIT, 0);
  mDetailsCommand = new Command("Details", Command.SCREEN, 0);
  mTitleList.addCommand(mExitCommand);
  mTitleList.addCommand(mDetailsCommand);
  mTitleList.setCommandListener(this);
  // Start parsing.
  String url = getAppProperty("RSSMIDlet.URL");
  RSSParser parser = new RSSParser();
  parser.setRSSListener(this);
  parser.parse(url);
  mInitialized = true;
}
else
  mDisplay.setCurrent(mTitleList);
}

When I debug it, it is saying the "String url" is null, how do I solve this?

I have also put a url in the string url like so:

String url = getAppProperty("RSSMIDlet.http://wwww.anything.com");
String url = getAppProperty("http://wwww.anything.com");

but this shouldn't matter as the first way has a default url to go to.

Does anybody know what I am doing wrong here?

gnat
  • 6,213
  • 108
  • 53
  • 73
Hip Hip Array
  • 4,665
  • 11
  • 49
  • 80

1 Answers1

0

Does this help?

String url = "http://wwww.anything.com";

If you refer to the article Parsing XML in J2ME, you should be aware it is from 2002 and kxml has advanced since then.

If you are in the unfortunate situation to get the midlet running, this documentation may be of interest you. IMHO, you need to configure the midlet by setting the property name RSSMIDlet.URL to http://wwww.anything.com in the manifest file.

remipod
  • 11,269
  • 1
  • 22
  • 25
  • but how do you set the property name of RSSMIDlet.URL to the url? – Hip Hip Array Jan 17 '12 at 13:45
  • The article "Retrieving MIDlet Attributes" (second link) should help you in detail. It states: [...] The JAR file contains a manifest, /META-INF/MANIFEST.MF, a special file that contains metainformation [...] such as attributes for both AMS and MIDlet. – remipod Jan 17 '12 at 14:49