This discussion is archived
14 Replies Latest reply: Jun 21, 2009 9:26 AM by 843851 RSS

AccessControlException when using nanoXML :-(

843851 Newbie
Currently Being Moderated
I am now doing some xml parsing in MHP box with nanoXML. There is exception below:

java.security.AccessControlException: access denied (java.util.PropertyPermission net.n3.nanoxml.XMLParser read)

at java.security.AccessControlContext.checkPermission(Ljava/security/Permission;)V(Unknown Source)

at java.security.AccessController.checkPermission(Ljava/security/Permission;)V(Unknown Source)

at java.lang.SecurityManager.checkPermission(Ljava/security/Permission;)V(Unknown Source)

at java.lang.SecurityManager.checkPropertyAccess(Ljava/lang/String;)V(Unknown Source)

at java.lang.System.getProperty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;(Unknown Source)

at net.n3.nanoxml.XMLParserFactory.createDefaultXMLParser()Lnet/n3/nanoxml/IXMLParser;(XMLParserFactory.java:76)
.........

and it comes from the source of nanoXML in System.getProperty method:



/**

* Creates a default parser.

*

* @see #DEFAULT_CLASS

* @see #CLASS_KEY

*

* @return the non-null parser.

*

* @throws java.lang.ClassNotFoundException

* if the class of the parser or validator could not be found.

* @throws java.lang.InstantiationException

* if the parser could not be created

* @throws java.lang.IllegalAccessException

* if the parser could not be created

*/

public static IXMLParser createDefaultXMLParser()

throws ClassNotFoundException,

InstantiationException,

IllegalAccessException

{

String className = System.getProperty(XMLParserFactory.CLASS_KEY,

XMLParserFactory.DEFAULT_CLASS);

return XMLParserFactory.createXMLParser(className,

new StdXMLBuilder());

}


has anyone ever seen this? I have no idea why this.
Thanks in advance!
  • 1. Re: AccessControlException when using nanoXML :-(
    843851 Newbie
    Currently Being Moderated
    Have you, or anyone else, solved this problem? I am having much the same problem. In my case it shows up when trying to call nanoXML from an applet (it works fine when running as applet from within eclipse).
  • 2. Re: AccessControlException when using nanoXML :-(
    843851 Newbie
    Currently Being Moderated
    Have you, or anyone else, solved this problem? I am having the same problem.....
    Saludos
  • 3. Re: AccessControlException when using nanoXML :-(
    843851 Newbie
    Currently Being Moderated
    Are you running in signed environment.
  • 4. Re: AccessControlException when using nanoXML :-(
    843851 Newbie
    Currently Being Moderated
    Yes I'm using Vidiom Systems Tools "VIsion Workbench" Software. It is a Eclipse Enviroment modified.
    URL url =null;
         try{          
               
             url = new URL("http://localhost:8080/movies_xml2.xml");
             URLConnection connection = url.openConnection();
             IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
             IXMLReader reader = new StdXMLReader(connection.getInputStream());
             parser.setReader(reader);
           
                    // Read file and parse it!
                    IXMLElement xmlDoc = (IXMLElement) parser.parse();
                    
                    // Get the tag called 
                    IXMLElement node = xmlDoc.getFirstChildNamed("datalist");
    
                    System.out.println("");
                    
                    Enumeration books = node.enumerateChildren();       
          
                    while (books.hasMoreElements())
                    {
                        book = (IXMLElement) books.nextElement();
    
                        System.out.println("GeneroID    : " + book.getAttribute("GENREID", ""));
                        System.out.println("MovieID     : " + book.getAttribute("MOVIEID", "unknown"));
                      
                    }
                 
               }
               catch (Exception e)
               {
                    e.printStackTrace();
               }
    Regards and Thanks
  • 5. Re: AccessControlException when using nanoXML :-(
    843851 Newbie
    Currently Being Moderated
    Hi,

    If "yes" is the answer to my question - Are you running in a signed environment? then I have one follow-up question:

    Have you set "properties" value to true in your Permissions file? Let me know.
  • 6. Re: AccessControlException when using nanoXML :-(
    843851 Newbie
    Currently Being Moderated
    I don't understand about signed environment...
    When I create a project in the Application Security Tap there are options unsigned and signed, I have my projects unsigned because when I choose signed appears "Invalid security range for AppID"
    That means a signed environment ?

    I have file .properties, but I don't see my Permissions file.

    Help me. Please

    Content
    #$Uniquely identifies the version of the application signalling.
    version=0
    #$Transport type.
    transport.0=local
    #$Uniquely identifies the application.
    app.0.application_identifier=0x000000010001
    #$Determines whether the application launches at boot time.
    app.0.application_control_code=AUTOSTART
    #$Controls whether application is visible.
    app.0.visibility=VISIBLE
    #$Set-top box resource priority.
    app.0.priority=0xfe
    #$Controls when the application is launched.
    app.0.launch_order=0x0
    #$Application's version.
    app.0.version=0x0
    #$Application's name
    app.0.application_name=Apache
    #$Location of the application.
    app.0.base_directory=bin
    #$The name of the application class the simulator should run.
    app.0.initial_class_name=apache
    #$Additional classpath entries.
    app.0.classpath_extension=
    #$Arguments passed to the application.
    app.0.args.0=
    #$Additional arguments passed to the application.
    app.0.args.1=
    Regards and Thanks
  • 7. Re: AccessControlException when using nanoXML :-(
    843851 Newbie
    Currently Being Moderated
    It seems that you are running in an unsigned environment.

    Let's do simeple experiment, instead of reading the xml file from the URL (i.e. instead of Connection.getInputStrem()) shall you try putting the xml file in the source directory, say for example, com/yourcompany/yourapplicaiton/XMLConfigurationData/movies_xml12.xml and read it via the normal file IO and pass the input stream to IXMLReader, lets see what happens.

    I want to see where exactly the exception is occurring either at Connection...blah blah.. or at parser/reader..

    Thanks.
  • 8. Re: AccessControlException when using nanoXML :-(
    843851 Newbie
    Currently Being Moderated
    Hi, thanks.
    I tried it.
    try
              {
                 IXMLParser     Parser = XMLParserFactory.createDefaultXMLParser();
                    IXMLReader Reader = StdXMLReader.fileReader("movies_xml2.xml");
                    xmlParser.setReader(Reader);
                   IXMLElement xmlDoc = (IXMLElement)Parser.parse();
                   IXMLElement node = xmlDoc.getFirstChildNamed("datalist");
                    System.out.println(node.getContent());
                   }
              catch (Exception e)
              {
                   e.printStackTrace();
              }
              
    And the Exception was:
    java.security.AccessControlException: access denied (java.util.PropertyPermission net.n3.nanoxml.XMLParser read)
         at java.security.AccessControlContext.checkPermission (AccessControlContext.java, line 280)
         at java.security.AccessController.checkPermission (AccessController.java, line 468)
         at java.lang.SecurityManager.checkPermission (SecurityManager.java, line 1045)
         at com.vidiom.impl.security.SecurityManagerImpl.checkPermission (SourceFile, line 106)
         at java.lang.SecurityManager.checkPropertyAccess (SecurityManager.java, line 1169)
         at java.lang.System.getProperty (System.java, line 462)
         at net.n3.nanoxml.XMLParserFactory.createDefaultXMLParser (XMLParserFactory.java, line 76)
    Thanks for help me!
    Regards!

    Edited by: ulimed on May 12, 2009 2:46 PM
  • 9. Re: AccessControlException when using nanoXML :-(
    843851 Newbie
    Currently Being Moderated
    at java.lang.System.getProperty (System.java, line 462)
    at net.n3.nanoxml.XMLParserFactory.createDefaultXMLParser (XMLParserFactory.java, line 76)

    Basically, The exception is happening in the nanoxml source.
    Do you have the source for System.java? It would be easier if we know what is the system property it is trying to read.
    The exception is occurring because you do not have permission to read that particular property.

    If you do not have the source code for the System.java then you could try onething.
    Locate the java.policy file in jre/lib/security directory and back-up the original file. Because we will play with it soon.
    Then add the following lines to the file:
    grant {
    permission java.security.AllPermission;
    }

    Run and let us the results.
  • 10. Re: AccessControlException when using nanoXML :-(
    843851 Newbie
    Currently Being Moderated
    Hi, I saw the java.policy files and has
    grant {
    permission java.security.AllPermission;
    }

    And I reviewed all the security files in Ocap manager properties of the emulator
    I change this
    #OcapSecurity=manager.security.OcapSecurityImpl
    for this
    OcapSecurity=manager.security.NoAccessControl
    And finally work !
    I don't know the consequent that it will brought....

    I really appreciate your help!
    Thank You

    ulimed
  • 11. Re: AccessControlException when using nanoXML :-(
    843851 Newbie
    Currently Being Moderated
    Thats great, excellent.

    To sum up can you give the name of the file you edited and its location please.
    Thanks.
  • 12. Re: AccessControlException when using nanoXML :-(
    843851 Newbie
    Currently Being Moderated
    Use nano xml source code in your project itself because in OCAP1.0 you can not use external jars.
    So download the nano xml source code from

    [http://www.java2s.com/Open-Source/Java-Document/XML-UI/XUI/net.n3.nanoxml.htm|http://www.java2s.com/Open-Source/Java-Document/XML-UI/XUI/net.n3.nanoxml.htm]
  • 13. Re: AccessControlException when using nanoXML :-(
    843851 Newbie
    Currently Being Moderated
    Thank you I appreciate your tip!

    I have a question for anybody, Which is the most recently OCAP version?

    I've heard about the OCAP RI... do you know the advantages respect OCAP 1.0 ?

    Thank you so much...
  • 14. Re: AccessControlException when using nanoXML :-(
    843851 Newbie
    Currently Being Moderated
    OCAP RI is a open source initiative taken by java.net community. Its not a seprate realease of OCAP version. In this individuals can contribute their engineering efforts.