We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › Problems with signed applet and DocumentBuilder
Page Index Toggle Pages: 1
Problems with signed applet and DocumentBuilder (Read 1600 times)
Problems with signed applet and DocumentBuilder
Jun 9th, 2009, 9:17am
 
Hi there

I have an app, which works fine standalone and in processing IDE, but I am trying to export and run it from the index.html.
The app (simplified code included), launches, requests that I trust it (because I signed it) and shows the image as
expected. However when I look in the Java console (as part of my browser) I see the following error messages:

trying dataPath
java.security.AccessControlException: access denied (java.io.FilePermission /null/data/HoCMP.xml read)
trying data/
java.security.AccessControlException: access denied (java.io.FilePermission /data/HoCMP.xml read)
trying absolute Path
java.security.AccessControlException: access denied (java.io.FilePermission /home/AntMan/Processing/Test/Simpler/Simpler/data/HoCMP.xml read)
Hello

Investigating I have found the lines this relates to (see below), which is basically the constructor of the object
which receives the location to the xml file which will be loaded ready to be parsed later on in the app:

   try
   {
     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
     DocumentBuilder db = dbf.newDocumentBuilder();
     myDom = db.parse(fileName);
   }
   catch (java.security.AccessControlException e)
   {
     System.out.println("Found an error!!!!!");
     System.err.println(e.toString());
   }

From what I can find on the internet this would only happen if the app is not signed, which it is?

I am running Fedora 9, viewing the index.html with Opera and the Java console included with Opera.

This is my code:

//Simple.class

PFont font8;
MyParser tp;
boolean failed = false;

void setup()
{
 fill(0);
 smooth();
 size(800,600);
}

void draw()
{
 rect(0,0,800,600);
 
 try
 {
   System.out.println("trying dataPath");
   tp = new MyParser(dataPath("")+"/HoCMP.xml");
 }
 catch (java.security.AccessControlException e)
 {
   System.out.println("dataPath() failed!");
   System.err.println(e.toString());
   failed = true;
 }
 try
 {
   System.out.println("trying data/");
   tp = new MyParser("data/HoCMP.xml");
 }
 catch (java.security.AccessControlException e)
 {
   System.out.println("data/ failed!");
   System.err.println(e.toString());
   failed = true;
 }
 try
 {
   System.out.println("trying absolute Path");
   tp = new MyParser("/home/AntMan/Processing/Test/Simpler/Simpler/data/HoCMP.xml");
 }
 catch (java.security.AccessControlException e)
 {
   System.out.println("Absolute path failed!");
   System.err.println(e.toString());
   failed = true;
 }

 finally
 {
   if (failed)
       System.out.println("Failure occured");
   else System.out.println("No failures!");
 }

 strokeWeight(0.25f);
 font8 = createFont("Serif",28);
 textFont(font8);
 fill(255);
 if (failed)
 {
  text("Some or all failed",370,300);
  System.out.println("Some or all failed");
 }
 else
 {
   text("Hello",370,300);
 System.out.println("Hello");
 }
 noLoop();

}



//MyParser.java

import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.*;
import org.xml.sax.SAXException;
import java.io.File;
import java.io.IOException;
import java.util.Vector;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;

public class MyParser
{
 private Document myDom;
TransformerFactory.newInstance();

 public MyParser(String fileName)
 {

   File xmlFile = new File(fileName);

   try
   {
     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
     DocumentBuilder db = dbf.newDocumentBuilder();
     myDom = db.parse(fileName);
   }
   catch (java.security.AccessControlException e)
   {
     System.out.println("Found an error!!!!!");
     System.err.println(e.toString());
   }
   catch (Exception e)
   {
     System.err.println(e.toString());
   }

 }

}
Re: Problems with signed applet and DocumentBuilder
Reply #1 - Jun 9th, 2009, 9:58am
 
A update, is it anything to do with java.policy? If so, do you have any good links to understand this? I am struggling with this at the moment.
Re: Problems with signed applet and DocumentBuilder
Reply #2 - Jun 9th, 2009, 1:50pm
 
You posted twice the thread (a glitch quite common with this new forum), you should update where you already have an answer... Smiley
Page Index Toggle Pages: 1