BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 09-15-2008, 05:55 AM   #1
ali1983
New Member
 
Join Date: Sep 2008
Model: 8703e
PIN: N/A
Carrier: AT&T
Posts: 2
Default JVM Error 104 uncaught Exception

Please Login to Remove!

Hello:-
I am using BlackBerry 8703e Simulator to run my application. I am using default JDE Example of HTTPS. Please and I am getting the
"JVM Error 104 uncaught Exception". And when I click on continue on blackberry screen I get following error
"Ungaught Exception Java.lang.error".
Please tell me what is the problem with this code. I am sending sample code.

HTTPFetch.java
Code:
/**
 * HTTPFetch.java
 * Copyright (C) 2001-2004 Research In Motion Limited. All rights reserved.
 */

package com.rim.samples.docs.httpfetch;

import java.io.IOException;
import java.io.InputStream;

import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;

import net.rim.device.api.i18n.ResourceBundle;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.container.MainScreen;

import com.rim.samples.docs.baseapp.BaseApp;

public class HTTPFetch extends BaseApp implements HTTPFetchResource {
    // Constants.
    private static final String SAMPLE_PAGE = "http://localhost/testpage/sample.txt";
    private static final String[] HTTP_PROTOCOL = {"http://", "http:\\"};
    
    // Members.
    private MainScreen _mainScreen;
    private RichTextField _content;
    
    /**
    * Send and receive data over the network on a
    * separate thread from the main thread of your application.
    */
    ConnectionThread _connectionThread = new ConnectionThread();
    
    //statics 
    private static ResourceBundle _resources = ResourceBundle.getBundle(
    HTTPFetchResource.BUNDLE_ID, HTTPFetchResource.BUNDLE_NAME);
    
    public static void main(String[] args) {
        HTTPFetch theApp = new HTTPFetch();
        theApp.enterEventDispatcher();
    }
    /**
    * The ConnectionThread class manages the HTTP connection.
    * Fetch operations are not queued, but if a second fetch request 
    * is made while a previous request is still active,
    * the second request stalls until the previous request completes.
    */
    private class ConnectionThread extends Thread {
        private static final int TIMEOUT = 500; //ms
        
        private String _theUrl;
        
        /* The volatile keyword indicates that because the data is shared, 
        * the value of each variable must always be read and written from memory,
        * instead of cached by the VM. This technique is equivalent to wrapping 
        * the shared data in a synchronized block, but produces less overhead. 
        */
        private volatile boolean _start = false;
        private volatile boolean _stop = false;
        
        /**
        * Retrieve the URL. The synchronized keyword ensures that only one 
        * thread at a time can call this method on a ConnectionThread object.
        */
        public synchronized String getUrl() {
            return _theUrl;
        }
        
        /**
        * Fetch a page. This method is invoked on the connection thread by 
        * fetchPage(), which is invoked in the application constructor when
        * the user selects the Fetch menu item.
        */
        public void fetch(String url) {
            _start = true;
            _theUrl = url;
        }
        
        /**
         *  Close the thread. Invoked when the application exits.
         */
        public void stop() {
            _stop = true;
        }
        
        /**
        * Open an input stream and extract data. Invoked when the thread
        * is started.
        */
        public void run() {
            for(;;) {
                // Thread control.
                while( !_start && !_stop) {
                    // No connections are open for fetch requests, 
                    // but the thread has not been stopped.
                    try {
                        sleep(TIMEOUT);
                    } catch (InterruptedException e) {
                        System.err.println(e.toString());
                    }
                }
                // Exit condition.
                if ( _stop ) {
                    return;
                }
                /* Ensure that fetch requests are not missed
                 * while received data is processed.
                 */
                synchronized(this) {
                    // Open the connection and extract the data.
                    StreamConnection s = null;
                    try {
                        s = (StreamConnection)Connector.open(getUrl());
                        InputStream input = s.openInputStream();
                        // Extract data in 256 byte chunks.
                        byte[] data = new byte[256];
                        int len = 0;
                        StringBuffer raw = new StringBuffer();
                        while ( -1 != (len = input.read(data)) ) {
                            raw.append(new String(data, 0, len));
                        } 
                        String text = raw.toString();
                        
                        updateContent(text);
                        
                        input.close();
                        s.close();
                    } catch (IOException e) {
                        System.err.println(e.toString());
                        // Display the text on the screen.
                        updateContent(e.toString());
                    }
                    // Reset the start state.
                    _start = false;
                }
            }
        }
    }
    // Constructor.
    public HTTPFetch() {
        _mainScreen = new MainScreen();
        _mainScreen.setTitle(new LabelField( 
        _resources.getString(APPLICATION_TITLE), LabelField.ELLIPSIS 
        | LabelField.USE_ALL_WIDTH));
        _mainScreen.add(new SeparatorField());
        _content = new RichTextField(
        _resources.getString(HTTPDEMO_CONTENT_DEFAULT));
        _mainScreen.add(_content);
        _mainScreen.addKeyListener(this);
        _mainScreen.addTrackwheelListener(this);
        
        // Start the helper thread.
        _connectionThread.start();
        pushScreen(_mainScreen);
        fetchPage(SAMPLE_PAGE);
    }
    
    // Retrieve web content. 
    private void fetchPage(String url) {
        // Perform basic validation (set characters to lowercase and add http:// or https://).
        String lcase = url.toLowerCase();
        boolean validHeader = false;
        int i = 0;
        for (i = HTTP_PROTOCOL.length - 1; i >= 0; --i) {
            if ( -1 != lcase.indexOf(HTTP_PROTOCOL[i]) ) {
                validHeader = true;
                break;
            }
        }
        if ( !validHeader ) {
             // Prepend the protocol specifier if it is missing.
            url = HTTP_PROTOCOL[0] + url;
        }
        
        // Create a new thread for connection operations.
        _connectionThread.fetch(url);
    }
    // Display the content.
    private void updateContent(final String text) {
        /* This technique creates several short-lived objects but avoids
        * the threading issues involved in creating a static Runnable and 
        * setting the text.
        */
        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() {
                _content.setText(text);
            }
        });
    }
    // Close the connection thread when the user closes the application.
    protected void onExit() {
        _connectionThread.stop();
    }
}
HTTPFetchResource.java(Interface)
Code:
package com.rim.samples.docs.httpfetch;

public interface HTTPFetchResource {
    // Hash of: "com.rim.samples.docs.httpfetch.HTTPFetch".
    long BUNDLE_ID = 0xd0dff0654b2ce75fL;
    String BUNDLE_NAME = "com.rim.samples.docs.httpfetch.HTTPFetch";

    int HTTPDEMO_ALERT_REQUESTINPROGRESS = 0;
    int APPLICATION_TITLE = 1;
    int HTTPDEMO_CONTENT_DEFAULT = 2;
}

BaseApp.java
Code:
/*
 * BaseApp.java
 * Copyright (C) 2001-2004 Research In Motion Limited. All rights reserved.
 */

package com.rim.samples.docs.baseapp;

import net.rim.device.api.i18n.ResourceBundle;
import net.rim.device.api.system.Characters;
import net.rim.device.api.system.KeyListener;
import net.rim.device.api.system.TrackwheelListener;
import net.rim.device.api.ui.ContextMenu;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Menu;

public abstract class BaseApp extends UiApplication implements BaseAppResource, KeyListener, TrackwheelListener {
    private MenuItem _closeItem;
    private static ResourceBundle _resources = 
    ResourceBundle.getBundle(BUNDLE_ID, BUNDLE_NAME);
    /* Constructor for the abstract base class. */
    public BaseApp() {
        _closeItem = new MenuItem(_resources, MENUITEM_CLOSE, 200000, 10) {
            public void run() {
                onExit();
                System.exit(0);
            }
        };
    }
    /* Override this method to add custom menu items. */
    protected void makeMenu( Menu menu, int instance) {
        Field focus = UiApplication.getUiApplication(). 
        getActiveScreen().getLeafFieldWithFocus();
        if(focus != null) {
            ContextMenu contextMenu = focus.getContextMenu();
            if( !contextMenu.isEmpty()) {
                menu.add(contextMenu);
                menu.addSeparator();
            }
        }
        menu.add(_closeItem);
    }
    /* Invoked when the trackwheel is clicked. */
    public boolean trackwheelClick( int status, int time ) {
        Menu menu = new Menu();
        makeMenu( menu, 0);
        menu.show();
        return true;
    }
    /* Invoked when the trackwheel is released. */
    public boolean trackwheelUnclick( int status, int time ) {
        return false;
    }
    /* Invoked when the trackwheel is rolled. */
    public boolean trackwheelRoll(int amount, int status, int time) {
        return false;
    }
    public boolean keyChar(char key, int status, int time) {
        /* Intercept the ESC key and exit the application. */
        boolean retval = false;
        switch (key) {
            case Characters.ESCAPE:
            onExit();
            System.exit(0);
            retval = true;
            break;
        }
        return retval;
    }
    /* Implementation of KeyListener.keyDown(). */
    public boolean keyDown(int keycode, int time) {
        return false;
    }
    /* Implementation of KeyListener.keyRepeat(). */
    public boolean keyRepeat(int keycode, int time) {
        return false;
    }
    /* Implementation of KeyListener.keyStatus(). */
    public boolean keyStatus(int keycode, int time) {
        return false;
    }
    /* Implementation of KeyListener.keyUp(). */
    public boolean keyUp(int keycode, int time) {
        return false;
    }
    protected abstract void onExit();
}
BaseAppResource.java(Interface)
Code:
package com.rim.samples.docs.baseapp;

public interface BaseAppResource {
    // Hash of: "com.rim.samples.docs.baseapp.BaseApp".
    long BUNDLE_ID = 0xb2bbab4764b0c17eL;
    String BUNDLE_NAME = "com.rim.samples.docs.baseapp.BaseApp";

    int MENUITEM_CLOSE = 0;
}
I am using BlackBerry Plugin for Eclipse. And using 8703e as my simulator.

Bye
Muhammad Ali
[email address]
Offline  
Old 09-15-2008, 11:49 AM   #2
Ivanov
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Default

Try to locate the line throwing the exception by stepping throug the calls.
Offline  
Old 09-16-2008, 05:16 AM   #3
ali1983
New Member
 
Join Date: Sep 2008
Model: 8703e
PIN: N/A
Carrier: AT&T
Posts: 2
Default JVM Error 104 uncaught Exception

Thanks for the reply. But the problem is that I have done it so. But befire reaching the main method it throws the exception.

Now how u can make calls out of any method.

Bye
Offline  
Old 09-16-2008, 07:43 AM   #4
Ivanov
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Default

Are you sure that it's your application that is throwing that exception? It would not make sense since your main() and so your application is not started at all...
__________________
Blessed is the end user who expects nothing, for he/she will not be disappointed. (Franklin's Rule)
Offline  
Old 09-17-2008, 09:24 PM   #5
stepanz
New Member
 
Join Date: Sep 2008
Model: 8310
PIN: N/A
Carrier: AT&T
Posts: 1
Default

Hi,

I have the same issue. I have 8310 Blackberry and my application is very simple. I am calling a web service and application works fine if I run it in mobile phone emulator (NetBeans IDE 6.1 and Sun Java(TM) Wireless Toolkit 2.5.2 for CLDC) but if I run the application in Blackberry emulator (BlackBerry JDE 4.5) I am getting error message 'JVM Error 104 Uncought: JAXRPCException'. I deployed the application on real device and if I try to run it I am getting error message 'Class java.rmi.RemoteException not found'. What did I do wrong?

Thanks,
Zoran
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


IBM Correctable Ribbon Cassette Black 1299300 NOS Original OEM picture

IBM Correctable Ribbon Cassette Black 1299300 NOS Original OEM

$2.99



Genuine OEM IBM Wheelwriter Printwheel - Script 001-008 1353778 picture

Genuine OEM IBM Wheelwriter Printwheel - Script 001-008 1353778

$45.64



IBM CASH DRAWER KEY'S #9960 SET OF 2 KEYS. AFTERMARKET KEY'S SAME AS OEM 33G3360 picture

IBM CASH DRAWER KEY'S #9960 SET OF 2 KEYS. AFTERMARKET KEY'S SAME AS OEM 33G3360

$18.00



IBM CASH DRAWER KEY'S #9952 SET OF 2 KEYS. AFTERMARKET KEY'S SAME AS OEM 33G3352 picture

IBM CASH DRAWER KEY'S #9952 SET OF 2 KEYS. AFTERMARKET KEY'S SAME AS OEM 33G3352

$18.00



2 New OEM Toshiba SR5000,SR5020,SR4110 Staple-2500 Cartridge 318332 1pc. picture

2 New OEM Toshiba SR5000,SR5020,SR4110 Staple-2500 Cartridge 318332 1pc.

$120.00



Lot Of 5 Vintage OEM IBM 1337765 Easystrike Lift-Off Tape Cassette. picture

Lot Of 5 Vintage OEM IBM 1337765 Easystrike Lift-Off Tape Cassette.

$25.00







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.