• Post Reply Bookmark Topic Watch Topic
  • New Topic


Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi, I am facing a problem with security. I am trying to write an XML file through an (java)EJB bean .Compiling is no problem.It is giving an access control exception at run time.The code and exception details are as follows.hope you can please help me out.
filePath = "c:\\j2sdkee1.2.1\\public_html\\";
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance ();
DocumentBuilder builder = factory.newDocumentBuilder ();
TransformerFactory tFactory = TransformerFactory.newInstance ();
Transformer transformer = tFactory.newTransformer ();
ByteArrayInputStream byt = new ByteArrayInputStream (contractLineStr.toString().getBytes ());
Document document = builder.parse (byt);
DOMSource source = new DOMSource (document);
File file = new File (filePath);
if (file.exists ())
file.delete ();
StreamResult result = new StreamResult (new FileOutputStream(filePath));
transformer.transform (source, result);

The Exception i am getting is
access denied (java.io.FilePermission c:\j2sdkee1.2.1\public_html\CO301214.xml write)

madhu g
Frank Carver
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"madhu g",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in again with a new name which meets the requirements.
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!