XSLT Transform Access is Denied

I don’t think this is necessarily a Lucee issue but might be a Java / Windows issue. We are running Lucee 4.x on Windows with Tomcat. I have a set of web services that uses an .XSLT to transform XML from one format to another. The issue is under high load I think Java is locking our .xslt file during the transformation and subsequent requests are failing due to an “Access is Denied” error. I’m pulling my hair out on this one. During some of my testing, I can get the error 2 times out of every 250 calls in a one minute test.

I traced through the Lucee code and I noticed it does not request a lock on the bufferedinputstream it creates…but I think java.io.bufferedinputstream locks the file it is reading be default…or Windows is locking the file on it’s own?

I’m about to turn on antiResourceLocking in Tomcat but that sounds like a poor solution. Here is the trace I’m analyzing.

D:\xxx\xxx\xxx\xxx\utils (Access is denied)
	at java.io.FileInputStream.open0(Native Method):-2
	at java.io.FileInputStream.open(FileInputStream.java:195):195
	at java.io.FileInputStream.<init>(FileInputStream.java:138):138
	at lucee.commons.io.res.type.file.FileResource.getInputStream(FileResource.java:195):195
	at lucee.commons.io.IOUtil.getReader(IOUtil.java:541):541
	at lucee.commons.io.IOUtil.toString(IOUtil.java:766):766
	at lucee.runtime.text.xml.XMLUtil.toInputSource(XMLUtil.java:1120):1120
	at lucee.runtime.text.xml.XMLUtil.toInputSource(XMLUtil.java:1167):1167
	at lucee.runtime.text.xml.XMLUtil.toInputSource(XMLUtil.java:1155):1155
	at lucee.runtime.functions.xml.XmlTransform.call(XmlTransform.java:46):46

This is the Lucee code I believe is throwing the exception

	public InputStream getInputStream() throws IOException {
		try {
			//return new BufferedInputStream(new ResourceInputStream(this,new FileInputStream(this)));
			return new BufferedInputStream(new FileInputStream(this));
		catch(IOException ioe) {
			throw ioe;

I was able to figure this out. This is a three part problem.

  1. I’m having random connection issues to a web service I am calling from my service.
  2. Lucee is not throwing an exception when it can’t connect to my host.
  3. This is causing my code to send an empty string to the Lucee xmlTransform function. Lucee thinks an empty string is a valid file path and tries to create a file input source. This of course breaks and causes the Access is Denied error I am seeing.
public static InputSource toInputSource(PageContext pc, String xml, boolean canBePath) throws IOException, ExpressionException {
                              // xml text
                              if(!canBePath || xml.startsWith("<"))        {
                                             return new InputSource(new StringReader(xml));
                              // xml link
                              Resource res = ResourceUtil.toResourceExisting(pc, xml);
                              return toInputSource(pc, res);