×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    15

    java.lang.securityexception error

    hi everybody. i have developed a mobile application in netbeans 6 ide. It works well in j2me emulator of netbeans 6. but when i install my application to my mobile phone (nokia 6230i), there is an error. The error text is below:
    "security java/lang/SecurityException MIDlet Manager Error : Illegal attempt to construct hello.Midlet@...

    why this error occurs consistently, and how can i solve this problem?

  2. #2
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: java.lang.securityexception error

    Sorry for hijacking your thread, but I ran into the same problem, got this error in the emulator too... I didn't want to open a new thread with the same title

    I have followed the Network Demo of the Sun JavaTM Wireless Toolkit for CLDC and created a simple HelloWorld generally not doing more than this:

    Code:
    public class HelloMIDlet extends MIDlet implements Runnable, CommandListener {
    
        private boolean midletPaused = false;
        SocketConnection ClientSocket;
        ServerSocketConnection ServerSocket;
    
        public void run() {
            try {
                ServerSocket = (ServerSocketConnection) Connector.open("socket://localhost:8080");
                
                while (true) {
                    try {
                        ClientSocket = (SocketConnection) ServerSocket.acceptAndOpen();
     ......
    
                    } catch (Exception e) {
    
                    }
                }
     
            } catch (Exception ex) {
            }
    
        }
        public HelloMIDlet() {
            Thread t = new Thread(this);
            t.start();
    
        }
    I gave my application the same permissions as found in the manifes.mf of the sample. But with the call to Connector.open() I alway run into the java.lang.securityexception...

    Anybody able to give me a pointer?

    Regards

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    15

    Re: java.lang.securityexception error

    can anyone helps me?
    why occurs this error? is this problem relevant with mobile phone or netbeans?

  4. #4
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: java.lang.securityexception error

    Hello fuatsungur & neil.young,

    fuatsungur: tell us more about your application, and if possible, please show at least some of the code.

    neil.young: please open next time a new thread. fuatsungur's having the problem with a device, and your issue has to do with an emulator.

    The issue could be here with
    ServerSocket = (ServerSocketConnection) Connector.open("socket://localhost:8080");

    where the port=8080. Accessing ports 80, 8080 and 443 with an unsigned MIDlet produces security exception, so try with some other numbers than these to see whether it makes the difference.

    Regards,
    r2j7

  5. #5
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: java.lang.securityexception error

    Hi r2j7,

    thanks for your answer

    neil.young: please open next time a new thread. fuatsungur's having the problem with a device, and your issue has to do with an emulator.

    The issue could be here with
    ServerSocket = (ServerSocketConnection) Connector.open("socket://localhost:8080");
    Unfortunately it is also device related. Using 8080 I get a "java.lang.securityexception". Your explanation might be OK. I switched to port 5000 and configured the access point, but this didn't help either.

    The error on the device is now: java.io.IOException. SymbianOSError -34.

    Seems, one cannot use "socket://localhost:5000" Specifying "socket://:5000" works.

    The simplest things do not work with that stupid J2ME...

  6. #6
    Registered User
    Join Date
    Oct 2007
    Posts
    15

    Re: java.lang.securityexception error

    hi, which partiton do you want to see, i dont know but i'll show a little code.

    i've now 2 class. i am using one of them as a gui that it is Query.class. code of this class is written below:

    public class Query extends MIDlet implements CommandListener {
    private Midlet mm = new Midlet();
    private boolean midletPaused = false;
    private boolean isExist;
    private int iLineIndex;
    private String linesStations[]=null;
    //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">
    private List BulunulanDurak;
    private List DurakYonListesi;
    private Form HatFormu;
    private TextField textField;
    private WaitScreen waitScreen;
    private Command okCommand2;
    private Command exitCommand;
    private Command okCommand;
    private Command okCommand1;
    private SimpleCancellableTask task;
    //</editor-fold>

    /**
    * The Query constructor.
    */
    public Query() {
    mm.getReference(this);
    }

    --
    also i am using Midlet.class that has many functions to do task. I construct Midlet.class in Query.class, and code of this written above.

    as i mentioned earlier, the emulator of netbeans 6.0 runs this mobile application but my phone couldnt run it due to exceptions that are mentioned earlier as a securityexception.

    thanks for responses.

  7. #7
    Registered User
    Join Date
    Oct 2007
    Posts
    15

    Re: java.lang.securityexception error

    i forget the mention content of the Midlet.getReference method.
    this method includes anything. as a matter of fact, i see a code on the net and i change that code to my application.

  8. #8
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: java.lang.securityexception error

    Hello fuatsungur,

    ..which partiton do you want to see..
    I'll try to be more specific regarding the code: what do you do in your code? For example, do you do the same as neil.young, i.e. trying to make a socket connect (and possibly accessing ports 80, 8080 and 443)?

    Regards,
    r2j7
    [URL="http://library.forum.nokia.com/java"][B] >>> Java Developer's Library <<<[/B][/URL]
    [URL="https://www.developer.nokia.com/Resources/Support/Technical_support.xhtml"] [B]>>> Technical Support for Java ME development <<<[/B][/URL]
    [URL="https://publish.ovi.com/info/"][B]>>> Nokia Publish: reach millions of Nokia users worldwide through Nokia Store <<<[/B][/URL]

  9. #9
    Registered User
    Join Date
    Oct 2007
    Posts
    15

    Re: java.lang.securityexception error

    i am using only two class.
    the query class has many forms, lists. i use this class as a gui.
    the midlet class, it is used for some services. for example, this class read a text file, parse it, and it assigned parsed data to an array e.t.c.

    i cant put all of codes of files because that has more than 250 300 rows.

    ***

    this is important part of query.class
    Code:
    package hello;
    import javax.microedition.io.Connector;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.wireless.messaging.MessageConnection;
    import javax.wireless.messaging.TextMessage;
    import org.netbeans.microedition.lcdui.WaitScreen;
    import org.netbeans.microedition.util.SimpleCancellableTask;
    
    /**
     * @author Administrator
     */
    public class Query extends MIDlet implements CommandListener {
        private Midlet mm = new Midlet();
        private boolean midletPaused = false;
        private boolean isExist;
        private int iLineIndex;
        private String lineCode,directionStation,currentStation;
        private String linesStations[]=null;
        private String recipientNumber;
        //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">                      
        private List BulunulanDurak;
        private List DurakYonListesi;
        private Form HatFormu;
        private TextField textField;
        private TextField textField1;
        private WaitScreen waitScreen;
        private Form form;
        private StringItem stringItem;
        private Command okCommand2;
        private Command exitCommand;
        private Command okCommand;
        private Command okCommand1;
        private Command okCommand3;
        private SimpleCancellableTask task;
        //</editor-fold>                    
    
        /**
         * The Query constructor.
         */
        public Query() {
            mm.getReference(this);
        }
    ...
    ...
        public WaitScreen getWaitScreen() {
            if (waitScreen == null) {                                 
                // write pre-init user code here
                waitScreen = new WaitScreen(getDisplay());                                    
                waitScreen.setTitle("waitScreen");
                waitScreen.setCommandListener(this);
                waitScreen.setTask(getTask());                                  
                // write post-init user code here
                //stringItem = new StringItem("EHUEH","PUHAUH",Item.BUTTON);
                mm.startApp();
                //isExist = mm.isExist(textField.getString());
                //if ( isExist ) stringItem.setText("Evet, var");
                //else stringItem.setText("Hayir bole bisi yok");
           
                // a.txt dosyasinda hatlar ve bu hatlarin barindirdiklari
                // stationlar mevcut. Midlet clasinda yer alan readFile metodu a.txt dosyasini acar
                // okur ve her satirini bir vector elementine atar.
                mm.readFile("a.txt");
                
                // okunan rowlari parse etmemiz gerekiyor o yuzden parseRows metodunu cagiriyoruz.
                mm.parseRows();
                
                // ilk screendeki linecode ve recipient number  fieldlerini degiskenlere aktariyoruz.
                lineCode = textField.getString();
                recipientNumber = textField1.getString();
                
                // ilk screende girilen hattin text dosyamizda hangi indexte bulundugunu cekiyoruz.
                iLineIndex = mm.isExistLine(lineCode);
            }                         
            return waitScreen;
        }
    and the midlet class =>

    Code:
    package hello;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.util.Vector;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    
    /**
     * @author Administrator
     */
    public class Midlet extends MIDlet {
        // bu midlet mobile application icin bir cok fonksiyon icerir.
        private String lines[];
        private String stations[][];
        private Vector rows;
        
        public Midlet() 
        {
            System.out.println(">> constructor calisti Midlet");
        }
        
        public void getReference(Query q)
        {}
        
        public void startApp() {
            rows = new Vector();
        }
    
        public void pauseApp() {
        }
    
        public void destroyApp(boolean unconditional) {
            
        }

    ---
    this works on emulator of netbeans 6 but cannot work on 6230i due to java.lang.exception error.

    can you understand my problem?

  10. #10
    Registered User
    Join Date
    Oct 2007
    Posts
    15

    Re: java.lang.securityexception error

    i am bored. i've not solved this problem yet. My application must be ready now but i am still looking for any response for my post. This question is very hard? or is there any place that is cannot understandable?
    pls help me.

  11. #11
    Registered User
    Join Date
    Oct 2007
    Posts
    15

    Re: java.lang.securityexception error

    i've downloaded nokia sdk for s40 series. and it has an emulator. in that emulator, i run my j2me application. this java.security.exception error occurred as same as previous. what is the problem?

    this is screenshot of error on emulator :
    http://img217.imageshack.us/my.php?image=aaagy8.jpg

    ---
    i am running my application using this way:
    firstly, i go to the applications on my phone. then click my j2me application. Then, this is important, there are 2 class names displayed on the screen:

    Query
    Midlet

    then, i click Query class then i've gotten that error. if i click Midlet, there is no error. It says, it is running in background.

    ---

    and i tried the remove "mm = new Midlet()" code fragmant in the query.class then my j2me application works but after there would be an null pointer exception, it must be occur because there are many methods that are in midlet class would be run .

    so, this error occurs when i code => "mm = new Midlet();"
    not "Midlet mm;"

    why why why
    Last edited by fuatsungur; 2008-02-12 at 18:35.

  12. #12
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: java.lang.securityexception error

    Ok, I have to admit that I did not read all the posts in this thread, but it seems that both of the problems mentioned here are because you try to create another MIDlet in your MIDlet. Only AMS can create a MIDlet you cannot create a MIDlet in your code.

    neil.young, you have to use a non-MIDlet class for creating new threads.

    Hartti

  13. #13
    Registered User
    Join Date
    Oct 2007
    Posts
    15

    Re: java.lang.securityexception error

    thank you sir. it works now. but i dont understand why this is occur?
    thank you

  14. #14
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: java.lang.securityexception error

    I already mentioned this in my previous reply
    Only AMS can create a MIDlet you cannot create a MIDlet in your code.
    This is how things have been specified in MIDP specification.

    Hartti

  15. #15
    Registered User
    Join Date
    Feb 2008
    Posts
    2

    java.lang.securityexception error

    Quote Originally Posted by hartti View Post
    Ok, I have to admit that I did not read all the posts in this thread, but it seems that both of the problems mentioned here are because you try to create another MIDlet in your MIDlet. Only AMS can create a MIDlet you cannot create a MIDlet in your code.

    neil.young, you have to use a non-MIDlet class for creating new threads.

    Hartti


    Hello Sir,

    I also implement email application for mobile using IMAP and SMTP protocol.
    It's works fine on J2ME wireless toolkit.And also some mobiles e.g.Sony Ericsson(P,k series).

    But when i try to run on another mobiles(Sony Ericsson w300i)it gives "SecurityException Error".


    I have used following code to connect IMAP..
    Here ssl is false.

    public void open(String host, int port, boolean ssl) throws IOException {
    String protocol = (ssl ? "ssocket" : "socket");
    socket = (StreamConnection)Connector.open(protocol + "://" + host + ":" + port, Connector.READ_WRITE, true);
    input = socket.openInputStream();
    output = socket.openOutputStream();
    }


    pls help me .........
    I became crazy about that.....because i am new in j2me.
    Plz...

    Thanks
    Ramj

Similar Threads

  1. XMl Parser Implementation for Symbian
    By ittiam in forum Symbian
    Replies: 26
    Last Post: 2009-09-16, 05:26
  2. i cant build helloworld project
    By akhin in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2008-12-22, 12:38
  3. Help with lnk2019 lnk1120 error
    By yuenfatt in forum Symbian
    Replies: 8
    Last Post: 2007-08-24, 08:21
  4. My BuilderX (with S60 SDK 2.1.NET MS version) cannot build ARMI UREL
    By danielvidonyi@hotmail.com in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2006-05-04, 21:30
  5. User break point error in Grid
    By ag24master in forum Symbian User Interface
    Replies: 0
    Last Post: 2003-08-07, 08:20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×