RE: Java Servlet error with tomcat running on Windows Server 2008 R2
I have cleared whitespace or any escaping character in the URL, made sure all image links are validated. But now I get a different error. The error message shows The resource path [file:/C:/tomcat/bin/] is not valid , not sure where is this file:/C:/tomcat/bin/ path coming from, that all my images are accessed via URLs not locally. Something like: http://testing.mycompany.com/app/client_data/logo.png I tested it in Apache Tomcat 8.0.23. Full error message: HTTP Status 500 - javax.xml.transform.TransformerException: org.xml.sax.SAXException: The resource path [file:/C:/tomcat/bin/] is not valid type Exception report message javax.xml.transform.TransformerException: org.xml.sax.SAXException: The resource path [file:/C:/tomcat/bin/] is not valid description The server encountered an internal error that prevented it from fulfilling this request. exception javax.servlet.ServletException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: The resource path [file:/C:/tomcat/bin/] is not valid java.lang.IllegalArgumentException: The resource path [file:/C:/tomcat/bin/] is not valid org.apache.fop.servlet.FopServlet.doGet(FopServlet.java:166) javax.servlet.http.HttpServlet.service(HttpServlet.java:622) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause javax.xml.transform.TransformerException: org.xml.sax.SAXException: The resource path [file:/C:/tomcat/bin/] is not valid java.lang.IllegalArgumentException: The resource path [file:/C:/tomcat/bin/] is not valid com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:755) com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:357) org.apache.fop.servlet.FopServlet.render(FopServlet.java:288) org.apache.fop.servlet.FopServlet.renderXML(FopServlet.java:255) org.apache.fop.servlet.FopServlet.doGet(FopServlet.java:157) javax.servlet.http.HttpServlet.service(HttpServlet.java:622) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) -Original Message- From: David kerber [mailto:dcker...@verizon.net] Sent: Thursday, July 16, 2015 2:30 PM To: Tomcat Users List users@tomcat.apache.org Subject: Re: Java Servlet error with tomcat running on Windows Server 2008 R2 On 7/16/2015 2:01 PM, Chen Yang wrote: Hi all, I'm maintaining a Java servlet which uses for render PDF files. Recently I've been tasked to deploy it to run on windows environment. It works perfectly in our old Linux environment; but I'm having issues in windows with the same setup, I can however get a pdf report when there is no image included, but no luck when there are images included. I just want to mention I have checked firewall, file permissions and networking on the windows sandbox machine. I've been asking around for helps, but without any luck so far. If anyone in the mailing list can shed some light on it, It would be much appreciated! I didn't read all your code, but in moving from *nix to Windows, the first thing I think of is networking. Are your image files on the local machine, or elsewhere on the network? By default, the localsystem user that services run under won't have access to networked files. The other thing to check is if any of your paths have spaces in them, and if so, that they're escaped properly. Cheers, Chen Environment setup: * JRE 1.8.0_45 * Tomcat 8.0.23 * Windows Server 2008 R2 Error Message from Tomcat: HTTP Status 500 - javax.xml.transform.TransformerException: org.xml.sax.SAXException: The resource path [http://testing.mycompany.com/app/client_data/logo.png]http://testing .mycompany.com/app/client_data/logo.png%5d is not valid type Exception report message javax.xml.transform.TransformerException: org.xml.sax.SAXException: The resource path [http://testing.mycompany.com/app/client_data/logo.png]http://testing .mycompany.com/app/client_data/logo.png%5d is not valid description The server encountered an internal error that prevented it from fulfilling this request. Servlet Code package org.apache.fop.servlet; import java.net.*; import java.io.*; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.net.URI; import java.net.URL; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import
Java Servlet error with tomcat running on Windows Server 2008 R2
Hi all, I'm maintaining a Java servlet which uses for render PDF files. Recently I've been tasked to deploy it to run on windows environment. It works perfectly in our old Linux environment; but I'm having issues in windows with the same setup, I can however get a pdf report when there is no image included, but no luck when there are images included. I just want to mention I have checked firewall, file permissions and networking on the windows sandbox machine. I've been asking around for helps, but without any luck so far. If anyone in the mailing list can shed some light on it, It would be much appreciated! Cheers, Chen Environment setup: * JRE 1.8.0_45 * Tomcat 8.0.23 * Windows Server 2008 R2 Error Message from Tomcat: HTTP Status 500 - javax.xml.transform.TransformerException: org.xml.sax.SAXException: The resource path [http://testing.mycompany.com/app/client_data/logo.png]http://testing.mycompany.com/app/client_data/logo.png%5d is not valid type Exception report message javax.xml.transform.TransformerException: org.xml.sax.SAXException: The resource path [http://testing.mycompany.com/app/client_data/logo.png]http://testing.mycompany.com/app/client_data/logo.png%5d is not valid description The server encountered an internal error that prevented it from fulfilling this request. Servlet Code package org.apache.fop.servlet; import java.net.*; import java.io.*; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.net.URI; import java.net.URL; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.URIResolver; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.stream.StreamSource; import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.xmlgraphics.io.Resource; import org.apache.xmlgraphics.io.ResourceResolver; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.FopFactoryBuilder; import org.apache.fop.apps.FopConfParser; import org.apache.fop.apps.MimeConstants; import java.util.Calendar; import java.text.SimpleDateFormat; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.DefaultConfiguration; import org.xml.sax.SAXException; public class FopServlet extends HttpServlet { /** Name of the parameter used for the XSL-FO file */ protected static final String FO_REQUEST_PARAM = fo; /** Name of the parameter used for the XML file */ protected static final String XML_REQUEST_PARAM = xml; /** Name of the parameter used for the XSLT file */ protected static final String XSLT_REQUEST_PARAM = xslt; /** Name of the parameter used for the ROOT URL */ protected static final String ROOT_REQUEST_PARAM = root_url; /** The TransformerFactory used to create Transformer instances */ protected TransformerFactory transFactory = null; /** The FopFactory used to create Fop instances */ protected FopFactory fopFactory = null; /** URIResolver for use by this servlet */ protected URIResolver uriResolver; public void init() throws ServletException { this.uriResolver = new ServletContextURIResolver(getServletContext()); this.transFactory = TransformerFactory.newInstance(); this.transFactory.setURIResolver(this.uriResolver); //Configure FopFactory as desired ResourceResolver resolver = new ResourceResolver() { public OutputStream getOutputStream(URI uri) throws IOException { URL url = getServletContext().getResource(uri.toASCIIString()); return url.openConnection().getOutputStream(); } public Resource getResource(URI uri) throws IOException { return new Resource(getServletContext().getResourceAsStream(uri.toASCIIString())); } }; FopFactoryBuilder builder = new FopFactoryBuilder(new File(.).toURI(), resolver); //configureFopFactory(builder); try { String confFile = C:\Program Files\tomcat\webapps\pdf_servlet\WEB-INF\iss-fop.xconf; builder = new FopConfParser(new File(confFile)).getFopFactoryBuilder(); }catch(SAXException e) { System.out.println(e);
Re: Java Servlet error with tomcat running on Windows Server 2008 R2
On 7/16/2015 2:01 PM, Chen Yang wrote: Hi all, I'm maintaining a Java servlet which uses for render PDF files. Recently I've been tasked to deploy it to run on windows environment. It works perfectly in our old Linux environment; but I'm having issues in windows with the same setup, I can however get a pdf report when there is no image included, but no luck when there are images included. I just want to mention I have checked firewall, file permissions and networking on the windows sandbox machine. I've been asking around for helps, but without any luck so far. If anyone in the mailing list can shed some light on it, It would be much appreciated! I didn't read all your code, but in moving from *nix to Windows, the first thing I think of is networking. Are your image files on the local machine, or elsewhere on the network? By default, the localsystem user that services run under won't have access to networked files. The other thing to check is if any of your paths have spaces in them, and if so, that they're escaped properly. Cheers, Chen Environment setup: * JRE 1.8.0_45 * Tomcat 8.0.23 * Windows Server 2008 R2 Error Message from Tomcat: HTTP Status 500 - javax.xml.transform.TransformerException: org.xml.sax.SAXException: The resource path [http://testing.mycompany.com/app/client_data/logo.png]http://testing.mycompany.com/app/client_data/logo.png%5d is not valid type Exception report message javax.xml.transform.TransformerException: org.xml.sax.SAXException: The resource path [http://testing.mycompany.com/app/client_data/logo.png]http://testing.mycompany.com/app/client_data/logo.png%5d is not valid description The server encountered an internal error that prevented it from fulfilling this request. Servlet Code package org.apache.fop.servlet; import java.net.*; import java.io.*; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.net.URI; import java.net.URL; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.URIResolver; import javax.xml.transform.sax.SAXResult; import javax.xml.transform.stream.StreamSource; import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.xmlgraphics.io.Resource; import org.apache.xmlgraphics.io.ResourceResolver; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; import org.apache.fop.apps.FopFactoryBuilder; import org.apache.fop.apps.FopConfParser; import org.apache.fop.apps.MimeConstants; import java.util.Calendar; import java.text.SimpleDateFormat; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.DefaultConfiguration; import org.xml.sax.SAXException; public class FopServlet extends HttpServlet { /** Name of the parameter used for the XSL-FO file */ protected static final String FO_REQUEST_PARAM = fo; /** Name of the parameter used for the XML file */ protected static final String XML_REQUEST_PARAM = xml; /** Name of the parameter used for the XSLT file */ protected static final String XSLT_REQUEST_PARAM = xslt; /** Name of the parameter used for the ROOT URL */ protected static final String ROOT_REQUEST_PARAM = root_url; /** The TransformerFactory used to create Transformer instances */ protected TransformerFactory transFactory = null; /** The FopFactory used to create Fop instances */ protected FopFactory fopFactory = null; /** URIResolver for use by this servlet */ protected URIResolver uriResolver; public void init() throws ServletException { this.uriResolver = new ServletContextURIResolver(getServletContext()); this.transFactory = TransformerFactory.newInstance(); this.transFactory.setURIResolver(this.uriResolver); //Configure FopFactory as desired ResourceResolver resolver = new ResourceResolver() { public OutputStream getOutputStream(URI uri) throws IOException { URL url = getServletContext().getResource(uri.toASCIIString()); return url.openConnection().getOutputStream(); } public Resource getResource(URI uri) throws IOException { return new