tamdinh / microemu

Automatically exported from code.google.com/p/microemu
0 stars 0 forks source link

my application crash after trying to write smth in RecordStore #43

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Start my application in the emulator (jar not-web based)
2.I can use it, on a screen where there is a lot of loadings application
freezes, no error messages, juste freeze. But i think that is normal... ?
3.If i generate a web-based version, at the start of the application i got
an error in console : 

Exception in thread "event-thread" java.lang.NullPointerException
    at java.io.DataOutputStream.writeUTF(Unknown Source)
    at java.io.DataOutputStream.writeUTF(Unknown Source)
    at g.a(Unknown Source)
    at mt.MTPOS.saveConf(Unknown Source)
    at al.commandAction(Unknown Source)
    at ad.keyPressed(Unknown Source)
    at javax.microedition.lcdui.Display$KeyEvent.run(Display.java:152)
    at org.microemu.device.ui.EventDispatcher.post(EventDispatcher.java:162)
    at org.microemu.device.ui.EventDispatcher.run(EventDispatcher.java:97)
    at java.lang.Thread.run(Unknown Source)
basic: Starting applet teardown
java.lang.NullPointerException
    at java.io.DataOutputStream.writeUTF(Unknown Source)
    at java.io.DataOutputStream.writeUTF(Unknown Source)
    at g.a(Unknown Source)
    at mt.MTPOS.saveConf(Unknown Source)
    at mt.MTPOS.exitMTPOS(Unknown Source)
    at mt.MTPOS.destroyApp(Unknown Source)
    at javax.microedition.midlet.MIDlet$MIDletAccessor.destroyApp(MIDlet.java:58)
    at org.microemu.applet.Main.destroy(Main.java:287)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown
Source)
    at java.lang.Thread.run(Unknown Source)

At this level, i'm just saving somth in the recordstore...

What is the expected output? What do you see instead?

Application does not crash ;)

What version of the product are you using? On what operating system?

tried with microemulator-2.0.4 & microemulator-3.0.0-SNAPSHOT

Thanks in advance, and many thanks for your great job & community !

Original issue reported on code.google.com by Guillaum...@gmail.com on 22 Apr 2010 at 7:59

GoogleCodeExporter commented 8 years ago
Do you have access to the source code of MIDlet? The most important is to know 
what
exactly method g.a is doing.

Original comment by bar...@gmail.com on 22 Apr 2010 at 8:09

GoogleCodeExporter commented 8 years ago
Yes i have access, i'm the main developper of it. I Actually don't know what is 
that
'g' object and that a method (smth obfuscated ?)

My application load and ask for the user language. After selection i put it in 
the
Config (a table in my record store) and update it.

Here is the code of saveConf() :

    public static void saveConf() {
        try {

            MTPOS.debug("1");
            Config.mappingRS = RecordStore.openRecordStore(ConfigRSName, true);
            config.id = 1;
            MTPOS.debug("2");
            if (curAct != null) {
                config.actID = curAct.id;
            } else {
                config.actID = -1;
            }
            MTPOS.debug("3");
            if (curAvail != null) {
                config.availId = curAvail.id;
            } else {
                config.availId = -1;
            }
            if (curShop != null) {
                config.shopID = curShop.id;
            } else {
                config.shopID = -1;
            }
            MTPOS.debug("4");
            //#ifdef Presence
            if (curAddressPlanning != null) {
                config.addressPlanningId = curAddressPlanning.id;
            } else {
                config.addressPlanningId = -1;
            }
            //#endif
            config.language = Lng.getCurrentLanguage();
            config.version = version;
            if (config.getRecordID() == -1) {
                MTPOS.debug("5");
                config.bruteInsert();
                MTPOS.debug("6");
            } else {
                config.update();
            }
            Config.mappingRS.closeRecordStore();
        } catch (RecordStoreException ex) {
            handleError("Problem with MTsyncConf record store.", ex);
            return;
        } catch (IOException ex) {
            handleError("Problem with MTsyncConf record store.", ex);
            return;
        }
    }

MTPOS.debug(String str) is a method that just make Sysout str with actual 
datetime.

Original comment by Guillaum...@gmail.com on 22 Apr 2010 at 12:22

GoogleCodeExporter commented 8 years ago
And there is nothing printed in the console... Sysout isn't forwarded to java 
console ?

Original comment by Guillaum...@gmail.com on 22 Apr 2010 at 12:29

GoogleCodeExporter commented 8 years ago
Still the key question is what is happening in the g.a() method and why
DataOutputStream.writeUTF argument is null.

Exception in thread "event-thread" java.lang.NullPointerException
    at java.io.DataOutputStream.writeUTF(Unknown Source)
    at java.io.DataOutputStream.writeUTF(Unknown Source)
    at g.a(Unknown Source)

Original comment by bar...@gmail.com on 28 Apr 2010 at 8:56

GoogleCodeExporter commented 8 years ago
I Actually don't know what is that 'g' object and that 'a' method (smth 
obfuscated ?)

Original comment by Guillaum...@gmail.com on 28 Apr 2010 at 3:42

GoogleCodeExporter commented 8 years ago
please, i really need your help and this is getting quite urgent. What can i do 
?

Original comment by Guillaum...@gmail.com on 29 Apr 2010 at 8:04

GoogleCodeExporter commented 8 years ago
Ok i found my problem. A problem with getAppProperty("MIDlet-Version");

Everything works.

I also found the #44 bug reported.

Original comment by Guillaum...@gmail.com on 29 Apr 2010 at 9:50

GoogleCodeExporter commented 8 years ago
Very good

Original comment by bar...@gmail.com on 29 Apr 2010 at 10:24