org.apache.xalan.xslt.XSLProcessorException: File xsl not found
I migrated an application from Weblogic 6.1 to WL 8.1 sp4. The application runs fine in Weblogic 6.1, it uses xml and stylesheets. Application is deployed on WL 8.1, when I open the login page it is not able to found the stylesheet though it is there.
It gives the following error
XSL Error: Could not parse C:/source/Stylesheets/ABC.xsl document!
XSL Error: SAX Exception
org.apache.xalan.xslt.XSLProcessorException: File "C:/source/Stylesheets/ABC.xsl" not found.
at org.apache.xalan.xslt.XSLTEngineImpl.error(XSLTEngineImpl.java:1674)
at org.apache.xalan.xslt.XSLTEngineImpl.processStylesheet(XSLTEngineImpl.java:738)
at org.apache.xalan.xslt.XSLTEngineImpl.process(XSLTEngineImpl.java:572)
at com.XalanXSLT.process(XalanXSLT.java:56)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.jav
a:6718)
I understand it a problem with version of xalan & xerces, please suggest the best possible do we need to change the code.
Sample ABC.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:include href="header.xsl"/>
<xsl:include href="error.xsl"/>
<xsl:variable name="URL">http://<xsl:value-of select="//SERVERNAME"/>:<xsl:value-of select="//PORTNUMBER"/>/<xsl:value-of select="//APPNAME"/></xsl:variable>
<xsl:template match="/">
<HTML>
Sample XML
<?xml version = '1.0'?>
<ROOT>
<SERVERNAME>localhost</SERVERNAME>
<PORTNUMBER>7001</PORTNUMBER>
<APPNAME>ABC</APPNAME>
<LOGIN_FOOTER_1></LOGIN_FOOTER_1>
<LOGIN_FOOTER_2>Please set cache settings to refresh every visit to page.</LOGIN_FOOTER_2>
<LOGIN_FOOTER_3>Release 1.08.0 (29-AUG-2006)</LOGIN_FOOTER_3>
</ROOT>
Thanks
Val
Thanks Vohra and Pawan for the response,
Vohra: C:/source/Stylesheets/ABC.xsl does not generate an error
Here are the details of the issue with steps:
Though I am not sure do I really need to change from XSLTProcessor to Transformer:
1)When I load the home page, SecurityLogin.java servlet is loaded, details of SecurityLogin.java
a)It creates XML in the file
================================
//Create XML for SCR2
StringBuffer xmlSource = new StringBuffer("");
xmlSource.append("<?xml version = '1.0'?>");
xmlSource.append("<ROOT>");
XMLUtil.append(xmlSource,"SERVERNAME",request.getServerName());
XMLUtil.append(xmlSource,"PORTNUMBER",request.getServerPort());
XMLUtil.append(xmlSource,"APPNAME",coatsAppName);
XMLUtil.append(xmlSource,"LOGIN_FOOTER_1",sLoginFooter1);
XMLUtil.append(xmlSource,"LOGIN_FOOTER_2",sLoginFooter2);
XMLUtil.append(xmlSource,"LOGIN_FOOTER_3",releaseMsg.toString());
xmlSource.append("</ROOT>");
XSLTransformer xslt = (XSLTransformer)resourceManager.get(XSL_PROCESSOR_NAME);
where XSL_PROCESSOR_NAME is ::XSLTransformer which is an interface
XSLTransformer.java
public interface XSLTransformer {
public void process(XSLTInputSource xmlSource, XSLTInputSource xslStylesheet,
XSLTResultTarget resultTree) throws org.xml.sax.SAXException ;
public void process(String xmlSource, String xslStylesheet,
javax.servlet.http.HttpServletResponse response)throws org.xml.sax.SAXException, IOException;
public NodeList processXPath(String xpath, Node target) throws org.xml.sax.SAXException;
} //end interface
SecurityLogin servlet calls xslt.process method as below where xslt class name is ::class XalanXSLT
try {
//Create login screen and send
xslt.process(xmlSource.toString(), coatsStylesheetDir+SCR2_XSL, response);
} catch(SAXException e) {
e.printStackTrace();
}
===============================
2)Now, it goes to XalanXSLT.java in process method, where it creates Instance of the XSLT processor, Creates and send page by processing data and XSL stylesheet.
public void process(String xmlSource, String xslStylesheet, javax.servlet.http.HttpServletResponse response)
throws org.xml.sax.SAXException, IOException {
//Create reader for xmlSource
Reader reader = new StringReader(xmlSource);
//Get output stream from the response object.
response.setContentType("text/html");
OutputStream out = response.getOutputStream();
//Create Instance of the XSLT processor
XSLTProcessor processor = org.apache.xalan.xslt.XSLTProcessorFactory.getProcessor();
//Create and send page by processing data and XSL stylesheet.
processor.process(new XSLTInputSource(reader), new XSLTInputSource(xslStylesheet), new XSLTResultTarget(out));
} //end process
3)The above code in application works PERFECTLY fine on Weblogic 6.1 which uses JDK 1.3 and above all code uses xalan.jar and xerces.jar which has the following details:
-Xerces.jar contains Xerces_Ver_1_1_3.info file which means it is version 1.1.3
-Xalan.jar contains XSLTInfo.properties file which states below details
# XSLT Properties
# See also: org.apache.xalan.xslt.XSLProcessorVersion
version=1.0
vendor=Apache Software Foundation
vendor-url=http://xml.apache.org/xalan
4)When I deploy the application as it is without changing anything, in Weblogic 8.1 sp4 which uses jdk142_05, it gives the following error on Weblogic console
SecurityLogin.java, calling xslt.process.....
SecurityLogin.java, StylesheetDir is ::C:/coatssource/source/Stylesheets/
SecurityLogin.java, SCR2 is ::C:/source/Stylesheets/SCR2.xsl
C:/source/Stylesheets/SCR2.xsl; Line 0; Column 0
XSL Error: Could not parse C:/source/Stylesheets/SCR2.xsl document!
XSL Error: SAX Exception
SecurityLogin.java, in Catch xslt.process.....
org.apache.xalan.xslt.XSLProcessorException: File "C:/source/Stylesheets/SCR2.xsl" not found.
at org.apache.xalan.xslt.XSLTEngineImpl.error(XSLTEngineImpl.java:1674)
at org.apache.xalan.xslt.XSLTEngineImpl.processStylesheet(XSLTEngineImpl.java:738)
at org.apache.xalan.xslt.XSLTEngineImpl.process(XSLTEngineImpl.java:572)
at com.XSLT.XalanXSLT.process(XalanXSLT.java:56)
at com.securitylogin.SecurityLogin.displaySCR2(SecurityLogin.java:113)
at com.securitylogin.SecurityLogin.service(SecurityLogin.java:63)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.jav
a:6718)
where the file SCR2.xsl is there at the specified path.
5)I explored the error and it looks like it is a problem with parsing on WL 8.1(can be b'coz. of jdk142_05 or xalan/xerces version)
6)As per the document on bea site ( http://e-docs.bea.com/wls/docs81/xml/xml_apps.html#1082512 ), I feel that I should convert the Code From Using the Xalan API to JAXP 1.1 API
Question: DOES IT REALLY REQUIRED?
7)I tried converting the XSLTProcessor(Xalan 1.X) TO Transformer(JAXP 1.1) as per the above link above and changed the following in XalanXSLT.java process method
FROM
//XSLTProcessor processor = org.apache.xalan.xslt.XSLTProcessorFactory.getProcessor();
//processor.process(new XSLTInputSource(reader),new XSLTInputSource(xslStylesheet), new XSLTResultTarget(out));
TO
try {
Transformer trans;
TransformerFactory factory = TransformerFactory.newInstance();
trans = factory.newTransformer(new StreamSource(xslStylesheet));
trans.transform(new StreamSource(xmlSource), new StreamResult(out));
} catch (Exception ex) {
System.out.println("XalanXSLT, in Catch....");
ex.printStackTrace();
}
so the process method looks like
public void process(String xmlSource, String xslStylesheet, javax.servlet.http.HttpServletResponse response)
throws org.xml.sax.SAXException, IOException {
//Create reader for xmlSource
Reader reader = new StringReader(xmlSource);
//Get output stream from the response object.
response.setContentType("text/html");
OutputStream out = response.getOutputStream();
//Create Instance of the XSLT processor
//XSLTProcessor processor = org.apache.xalan.xslt.XSLTProcessorFactory.getProcessor();
//Create and send page by processing data and XSL stylesheet.
//processor.process(new XSLTInputSource(reader),new XSLTInputSource(xslStylesheet), new XSLTResultTarget(out));
try {
System.out.println("XalanXSLT, process(), xslStylesheet is ::"+xslStylesheet);
System.out.println("XalanXSLT, process(), xmlSource is ::"+xmlSource);
Transformer trans;
TransformerFactory factory = TransformerFactory.newInstance();
trans = factory.newTransformer(new StreamSource(xslStylesheet));
trans.transform(new StreamSource(xmlSource), new StreamResult(out));
} catch (Exception ex) {
System.out.println("XalanXSLT, in Catch....");
ex.printStackTrace();
}
} //end process
where xslStylesheet is SCR2.xsl which looks like, I am attaching the full content
===============SCR2.xsl===================
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:include href="header.xsl"/>
<xsl:include href="error.xsl"/>
<xsl:variable name="URL">http://<xsl:value-of select="//SERVERNAME"/>:<xsl:value-of select="//PORTNUMBER"/>/<xsl:value-of select="//APPNAME"/></xsl:variable>
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>Compound Ordering and Tracking System</TITLE>
<link rel="stylesheet" type="text/css" href="styleCSS.css"></link>
<xsl:call-template name="error message"/>
<SCRIPT language="JavaScript1.1" src="validation.js"></SCRIPT>
</HEAD>
<BODY onload="return window_onload()">
<xsl:call-template name="copyright">
<xsl:with-param name="Created">05/08/2001</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="Logos"/>
User Login
<xsl:variable name="ACCTMGRURL">
<xsl:value-of select="//ACCTMGRURL"/>
</xsl:variable>
<xsl:if test="not($ACCTMGRURL = '')">
<div style="color: red; font-size: larger; font-weight: bold">
Your password has expired. You can change it now with the
<xsl:element name="A">
<xsl:attribute name="href"><xsl:value-of select="//ACCTMGRURL"/></xsl:attribute>
<xsl:attribute name="target">_blank</xsl:attribute>
Authentication
</xsl:element>
<xsl:element name="/A"></xsl:element>
window.
</div>
</xsl:if>
<!-- Login Form -->
<FORM id="login_form" method="post" onsubmit="return validateForm(this)">
<xsl:attribute name="ACTION"><xsl:value-of select="concat($URL,'/login')"/></xsl:attribute>
Enter your user name and password.
<INPUT id="submit_button" name="submit_button" type="submit" value="Submit"/>
<P><CENTER><I><xsl:value-of select="//LOGIN_FOOTER_1"/></I></CENTER></P>
</FORM>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
===============End SCR2.xsl===============
8)Application is built and deployed successfully using Ant on WL8.1.
9)Now when I open the main page which is SecurityLogin.java, it gives the following error on Weblogic console:
in SecuriytLogin.java..........
SecurityLogin.java, calling xslt.process.....
SecurityLogin.java, SCR2 is ::C:/source/Stylesheets/SCR2.xsl
xslt name is ::class com.XSLT.XalanXSLT
in SecuriytLogin.java, CALLING xslt.process...
XalanXSLT, process(), xslStylesheet is ::C:/source/Stylesheets/SCR2.xsl
XalanXSLT, process(), xmlSource is ::<?xml version = '1.0' encoding='UTF-8'?><ROOT>
<SERVERNAME>localhost</SERVERNAME>
<PORTNUMBER>7001</PORTNUMBER>
<APPNAME>app</APPNAME>
<LOGIN_FOOTER_1></LOGIN_FOOTER_1>
<LOGIN_FOOTER_2>Please set cache settings to refresh every visit to page.</LOGIN_FOOTER_2>
<LOGIN_FOOTER_3>Release 1.03.0 (31-AUG-2006)</LOGIN_FOOTER_3></ROOT>
XalanXSLT, in Catch....
javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerConfigurationException:
javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Illegal value: error messa
ge used for QNAME attribute: name
at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:805)
at weblogic.xml.jaxp.WebLogicTransformerFactory.newTransformer(WebLogicTransformerFactory.java:195)
at weblogic.xml.jaxp.RegistryTransformerFactory.newTransformer(RegistryTransformerFactory.java:209)
at com.XSLT.XalanXSLT.process(XalanXSLT.java:70)
at com.securitylogin.SecurityLogin.displaySCR2(SecurityLogin.java:119)
at com.securitylogin.SecurityLogin.service(SecurityLogin.java:64)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.jav
a:6718)
10)Is it a problem with SCR2.xsl format.
11)Here is the PATH and CLASSPATH details:
CLASSPATH=C:\bea\JDK142~1\lib\tools.jar;C:\bea\WEBLOG~1\server\lib\weblogic_sp.jar;C:\bea\WEBLOG~1\server\lib\
weblogic.jar;C:\bea\WEBLOG~1\common\eval\pointbase\lib\pbserver44.jar;C:\bea\WEBLOG~1\common\eval\pointbase\li
b\pbclient44.jar;C:\bea\JDK142~1\jre\lib\rt.jar;C:\bea\WEBLOG~1\server\lib\webservices.jar;
.
PATH=C:\bea\WEBLOG~1\server\bin;C:\bea\JDK142~1\jre\bin;C:\bea\JDK142~1\bin;C:\oracle\ora81\bin;C:\WINNT\syste
m32;C:\WINNT;C:\WINNT\System32\Wbem;C:\WINNT\java\trustlib;C:\Program Files\MKS\IntegrityClient\bin;C:\WINNT\s
ystem32;C:\WINNT;C:\WINNT\System32\Wbem;C:\PROGRA~1\COMMON~1\MDL Shared\ISIS;C:\Program Files\Borland\Delphi5\
Bin;C:\Program Files\Oracle\jre\1.1.7\bin;C:\orant\bin;C:\WINNT\java\trustlib;C:\Softwares\apache-ant-1.6.2\bi
n;C:\bea\WEBLOG~1\server\bin\oci920_8
.