You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Chen Yang <cy...@hrsg.ca> on 2015/10/02 16:42:50 UTC

The resource path [...] is not valid

Hi all,

I'm transforming xml into pdf files, but getting this strange error in my log. (tomcat 8.0.26)

The resource path [file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/] is not valid

Here is my code

//Setup sources
StreamSource xmlSrc = new StreamSource(new URL(rootUrl + "/output/xml/" + xml).openStream());
StreamSource xsltSrc = new StreamSource(new URL(rootUrl + "/output/xslt/" + xslt).openStream());

//Setup the XSL transformation
Transformer transformer = this.transFactory.newTransformer(xsltSrc);      //error out
transformer.setURIResolver(this.uriResolver);

XML & XSLT file are not stored locally, so I don't understand why it's looking at the tomcat folder?


Cheers,
Chen

RE: The resource path [...] is not valid

Posted by "Terence M. Bandoian" <te...@tmbsw.com>.
On 10/2/2015 10:28 AM, Chen Yang wrote:
> I wonder if it's because of this?
>
> org.apache.fop.servlet.FopServlet$1.getResource(FopServlet.java:116)
>
> 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()));    //line 116
>              }
>          };
>          FopFactoryBuilder builder = new FopFactoryBuilder(new File(".").toURI(), resolver);
>
> root cause
> java.lang.IllegalArgumentException: The resource path [file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/] is not valid
> 	org.apache.catalina.webresources.StandardRoot.validate(StandardRoot.java:250)
> 	org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:212)
> 	org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:206)
> 	org.apache.fop.servlet.FopServlet$1.getResource(FopServlet.java:116)
> 	org.apache.fop.apps.io.InternalResourceResolver.getResource(InternalResourceResolver.java:92)
> 	org.apache.fop.apps.io.InternalResourceResolver.getResource(InternalResourceResolver.java:78)
> 	org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:411)
> 	org.apache.fop.apps.FOUserAgent$1.resolveURI(FOUserAgent.java:160)
> 	org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.newSource(AbstractImageSessionContext.java:92)
> 	org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.needSource(AbstractImageSessionContext.java:191)
> 	org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCache.java:123)
> 	org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.java:123)
> 	org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:81)
> 	org.apache.fop.fo.FObj.processNode(FObj.java:129)
> 	org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:291)
> 	org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:179)
> 	com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.closeStartTag(Unknown Source)
> 	com.sun.org.apache.xml.internal.serializer.ToSAXHandler.flushPending(Unknown Source)
> 	com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.endElement(Unknown Source)
> 	com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.endElement(Unknown Source)
> 	GregorSamsa.insert_cover_page_template()
> 	GregorSamsa.template$dot$0()
> 	GregorSamsa.applyTemplates()
> 	GregorSamsa.transform()
> 	com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(Unknown Source)
> 	com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
> 	com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
> 	org.apache.fop.servlet.FopServlet.render(FopServlet.java:397)
> 	org.apache.fop.servlet.FopServlet.renderXML(FopServlet.java:342)
> 	org.apache.fop.servlet.FopServlet.doGet(FopServlet.java:150)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
> 	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
>
>
>
> -----Original Message-----
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Sent: Friday, October 02, 2015 11:05 AM
> To: Tomcat Users List<us...@tomcat.apache.org>
> Subject: Re: The resource path [...] is not valid
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Chen,
>
> On 10/2/15 10:42 AM, Chen Yang wrote:
>> >I'm transforming xml into pdf files, but getting this strange error in
>> >my log. (tomcat 8.0.26)
>> >
>> >The resource path
>> >[file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/
> ]
>> >is not valid
>> >
>> >Here is my code
>> >
>> >//Setup sources StreamSource xmlSrc = new StreamSource(new URL(rootUrl
>> >+ "/output/xml/" + xml).openStream()); StreamSource xsltSrc = new
>> >StreamSource(new URL(rootUrl + "/output/xslt/" + xslt).openStream());
> What's the value of "rootUrl"?
>
>> >//Setup the XSL transformation Transformer transformer =
>> >this.transFactory.newTransformer(xsltSrc);      //error out
>> >transformer.setURIResolver(this.uriResolver);
>> >
>> >XML & XSLT file are not stored locally, so I don't understand why it's
>> >looking at the tomcat folder?
> What's the stack trace?
>
> - -chris


Are you able to execute the transformation stand-alone (not within Tomcat)?

Also, you may want to ask this on the Apache FOP users mailing list:

     https://xmlgraphics.apache.org/fop/maillist.html

-Terence Bandoian


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: The resource path [...] is not valid

Posted by Chen Yang <cy...@hrsg.ca>.
I wonder if it's because of this?

org.apache.fop.servlet.FopServlet$1.getResource(FopServlet.java:116)

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()));    //line 116
            }
        };
        FopFactoryBuilder builder = new FopFactoryBuilder(new File(".").toURI(), resolver);

root cause
java.lang.IllegalArgumentException: The resource path [file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/] is not valid
	org.apache.catalina.webresources.StandardRoot.validate(StandardRoot.java:250)
	org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:212)
	org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:206)
	org.apache.fop.servlet.FopServlet$1.getResource(FopServlet.java:116)
	org.apache.fop.apps.io.InternalResourceResolver.getResource(InternalResourceResolver.java:92)
	org.apache.fop.apps.io.InternalResourceResolver.getResource(InternalResourceResolver.java:78)
	org.apache.fop.apps.FOUserAgent.resolveURI(FOUserAgent.java:411)
	org.apache.fop.apps.FOUserAgent$1.resolveURI(FOUserAgent.java:160)
	org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.newSource(AbstractImageSessionContext.java:92)
	org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.needSource(AbstractImageSessionContext.java:191)
	org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCache.java:123)
	org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.java:123)
	org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:81)
	org.apache.fop.fo.FObj.processNode(FObj.java:129)
	org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:291)
	org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:179)
	com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.closeStartTag(Unknown Source)
	com.sun.org.apache.xml.internal.serializer.ToSAXHandler.flushPending(Unknown Source)
	com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.endElement(Unknown Source)
	com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.endElement(Unknown Source)
	GregorSamsa.insert_cover_page_template()
	GregorSamsa.template$dot$0()
	GregorSamsa.applyTemplates()
	GregorSamsa.transform()
	com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(Unknown Source)
	com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
	com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
	org.apache.fop.servlet.FopServlet.render(FopServlet.java:397)
	org.apache.fop.servlet.FopServlet.renderXML(FopServlet.java:342)
	org.apache.fop.servlet.FopServlet.doGet(FopServlet.java:150)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)



-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Friday, October 02, 2015 11:05 AM
To: Tomcat Users List <us...@tomcat.apache.org>
Subject: Re: The resource path [...] is not valid

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Chen,

On 10/2/15 10:42 AM, Chen Yang wrote:
> I'm transforming xml into pdf files, but getting this strange error in 
> my log. (tomcat 8.0.26)
> 
> The resource path
> [file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/
]
> is not valid
> 
> Here is my code
> 
> //Setup sources StreamSource xmlSrc = new StreamSource(new URL(rootUrl 
> + "/output/xml/" + xml).openStream()); StreamSource xsltSrc = new 
> StreamSource(new URL(rootUrl + "/output/xslt/" + xslt).openStream());

What's the value of "rootUrl"?

> //Setup the XSL transformation Transformer transformer =
> this.transFactory.newTransformer(xsltSrc);      //error out 
> transformer.setURIResolver(this.uriResolver);
> 
> XML & XSLT file are not stored locally, so I don't understand why it's 
> looking at the tomcat folder?

What's the stack trace?

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJWDp0yAAoJEBzwKT+lPKRYwosQAJEk7lm9azal0bUXbP4ffZiN
Ff+b+CfqM8ZgIaKOjSnS2cLObgaPAYhtuy+1q98cZ3B5VjvYWRADxrZNPvmqYXYp
ZZqJSYpkvoHU6L81E5gU3WtBYakm1M7MWCdkGoPz6ygngsOLA0MeWj20ef22Dnj2
2ygGTBDdokwK7a4fYi2yYq80ZLjvvRvrxAqP+SFhpdydWcrnWMIdxMxgCFc1JoJx
waMp++c1DYBA2UwanTsjlo4+BFE1EhcTGd9p27hLJq0HciNSAB3fYve9cFUExHO/
7b4zoSaWhZ4gsI8MjMUibtV53hOE2hL8z8KQOzONxm/auRAH4j9x6AcpF5AyIo/t
lFXYESzYh85N0VI4U3tDbl5YIgFkgx3ua+TfTV0j/LWJPK5CcNc86PFuip3JRZLN
VblWWmBa5+/KNDgl3DktURjVlrvLJ0wmN6dastBAuEhvU6Y7YKfV898SgDNQQBYH
/TYTZidNi+xIM+62UYfFZOLRXiAO8XP1J6NrbmKRJCFy8z9ro23erXIDJHSgMROH
eoJ1qQ3ureqysdWxLAzTAAlP+kRtldUM5Ii2fIV2uc6tLpazESr0kgxT3K1XhHjc
ZLu2gARzg4Akn/dl2dlm0TgSc+5+f2s+ykbZ7crwrEabYppnBCJCn3T7ucrO4kgC
ksiIdogyhYE+uInftDEa
=+K3y
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: The resource path [...] is not valid

Posted by Chen Yang <cy...@hrsg.ca>.
Hi Christ 


javax.servlet.ServletException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: The resource path [file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/] is not valid
java.lang.IllegalArgumentException: The resource path [file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/] is not valid
	org.apache.fop.servlet.FopServlet.doGet(FopServlet.java:162)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


rootUrl is the site domain or IP. for example http://192.xxx.128.xx  

here is the doGet(), just in case you want to see

public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
        try {
            //Get parameters
            String foParam = request.getParameter(FO_REQUEST_PARAM);
            String xmlParam = request.getParameter(XML_REQUEST_PARAM);
            String xsltParam = request.getParameter(XSLT_REQUEST_PARAM);
			String rootParam = request.getParameter(ROOT_REQUEST_PARAM);

            //Analyze parameters and decide with method to use
            if (foParam != null) {
                renderFO(foParam, response);
            } else if ((xmlParam != null) && (xsltParam != null)) {
					renderXML(xmlParam,xsltParam,rootParam,response);
            } else {
                response.setContentType("text/html");
                PrintWriter out = response.getWriter();
                out.println("<html><head><title>Error</title></head>\n"
                          + "<body><h1>FopServlet Error</h1><h3>No 'fo' "
                          + "request param given.</body></html>");
            }
        } catch (Exception ex) {
            throw new ServletException(ex);
        }
    }

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Friday, October 02, 2015 11:05 AM
To: Tomcat Users List <us...@tomcat.apache.org>
Subject: Re: The resource path [...] is not valid

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Chen,

On 10/2/15 10:42 AM, Chen Yang wrote:
> I'm transforming xml into pdf files, but getting this strange error in 
> my log. (tomcat 8.0.26)
> 
> The resource path
> [file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/
]
> is not valid
> 
> Here is my code
> 
> //Setup sources StreamSource xmlSrc = new StreamSource(new URL(rootUrl 
> + "/output/xml/" + xml).openStream()); StreamSource xsltSrc = new 
> StreamSource(new URL(rootUrl + "/output/xslt/" + xslt).openStream());

What's the value of "rootUrl"?

> //Setup the XSL transformation Transformer transformer =
> this.transFactory.newTransformer(xsltSrc);      //error out 
> transformer.setURIResolver(this.uriResolver);
> 
> XML & XSLT file are not stored locally, so I don't understand why it's 
> looking at the tomcat folder?

What's the stack trace?

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJWDp0yAAoJEBzwKT+lPKRYwosQAJEk7lm9azal0bUXbP4ffZiN
Ff+b+CfqM8ZgIaKOjSnS2cLObgaPAYhtuy+1q98cZ3B5VjvYWRADxrZNPvmqYXYp
ZZqJSYpkvoHU6L81E5gU3WtBYakm1M7MWCdkGoPz6ygngsOLA0MeWj20ef22Dnj2
2ygGTBDdokwK7a4fYi2yYq80ZLjvvRvrxAqP+SFhpdydWcrnWMIdxMxgCFc1JoJx
waMp++c1DYBA2UwanTsjlo4+BFE1EhcTGd9p27hLJq0HciNSAB3fYve9cFUExHO/
7b4zoSaWhZ4gsI8MjMUibtV53hOE2hL8z8KQOzONxm/auRAH4j9x6AcpF5AyIo/t
lFXYESzYh85N0VI4U3tDbl5YIgFkgx3ua+TfTV0j/LWJPK5CcNc86PFuip3JRZLN
VblWWmBa5+/KNDgl3DktURjVlrvLJ0wmN6dastBAuEhvU6Y7YKfV898SgDNQQBYH
/TYTZidNi+xIM+62UYfFZOLRXiAO8XP1J6NrbmKRJCFy8z9ro23erXIDJHSgMROH
eoJ1qQ3ureqysdWxLAzTAAlP+kRtldUM5Ii2fIV2uc6tLpazESr0kgxT3K1XhHjc
ZLu2gARzg4Akn/dl2dlm0TgSc+5+f2s+ykbZ7crwrEabYppnBCJCn3T7ucrO4kgC
ksiIdogyhYE+uInftDEa
=+K3y
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: The resource path [...] is not valid

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Chen,

On 10/2/15 10:42 AM, Chen Yang wrote:
> I'm transforming xml into pdf files, but getting this strange
> error in my log. (tomcat 8.0.26)
> 
> The resource path
> [file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/
]
> is not valid
> 
> Here is my code
> 
> //Setup sources StreamSource xmlSrc = new StreamSource(new
> URL(rootUrl + "/output/xml/" + xml).openStream()); StreamSource
> xsltSrc = new StreamSource(new URL(rootUrl + "/output/xslt/" +
> xslt).openStream());

What's the value of "rootUrl"?

> //Setup the XSL transformation Transformer transformer =
> this.transFactory.newTransformer(xsltSrc);      //error out 
> transformer.setURIResolver(this.uriResolver);
> 
> XML & XSLT file are not stored locally, so I don't understand why 
> it's looking at the tomcat folder?

What's the stack trace?

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJWDp0yAAoJEBzwKT+lPKRYwosQAJEk7lm9azal0bUXbP4ffZiN
Ff+b+CfqM8ZgIaKOjSnS2cLObgaPAYhtuy+1q98cZ3B5VjvYWRADxrZNPvmqYXYp
ZZqJSYpkvoHU6L81E5gU3WtBYakm1M7MWCdkGoPz6ygngsOLA0MeWj20ef22Dnj2
2ygGTBDdokwK7a4fYi2yYq80ZLjvvRvrxAqP+SFhpdydWcrnWMIdxMxgCFc1JoJx
waMp++c1DYBA2UwanTsjlo4+BFE1EhcTGd9p27hLJq0HciNSAB3fYve9cFUExHO/
7b4zoSaWhZ4gsI8MjMUibtV53hOE2hL8z8KQOzONxm/auRAH4j9x6AcpF5AyIo/t
lFXYESzYh85N0VI4U3tDbl5YIgFkgx3ua+TfTV0j/LWJPK5CcNc86PFuip3JRZLN
VblWWmBa5+/KNDgl3DktURjVlrvLJ0wmN6dastBAuEhvU6Y7YKfV898SgDNQQBYH
/TYTZidNi+xIM+62UYfFZOLRXiAO8XP1J6NrbmKRJCFy8z9ro23erXIDJHSgMROH
eoJ1qQ3ureqysdWxLAzTAAlP+kRtldUM5Ii2fIV2uc6tLpazESr0kgxT3K1XhHjc
ZLu2gARzg4Akn/dl2dlm0TgSc+5+f2s+ykbZ7crwrEabYppnBCJCn3T7ucrO4kgC
ksiIdogyhYE+uInftDEa
=+K3y
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org