aspose file tools*
The moose likes Spring and the fly likes Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring "views.properties" file field "stylesheetLocation" needs to point outside of project/WAR-file" Watch "Spring "views.properties" file field "stylesheetLocation" needs to point outside of project/WAR-file" New topic
Author

Spring "views.properties" file field "stylesheetLocation" needs to point outside of project/WAR-file

Charles Roos
Greenhorn

Joined: Dec 14, 2012
Posts: 5
I have a bean "ResourceBundleViewResolver" that connects to file "views.properties".
The Bean and the file is described generally there:
http://static.springsource.org/spring/docs/2.0.x/reference/view.html

I generate XML data in code at runtime but XSL-file locates inside project there:
F:\eclipse_workspace\TKIS\WebContent\WEB-INF\xsl\decisionsIType.xsl

I'm successfully generating Pdf-files from Xml using XSL-files if my file "views.properties" has such folder path in variable "stylesheetLocation":



I want my project to read xsl-file "F:\TEMP\xsl\" instead (which locates outside the project/WAR), so i copied the xsl file to there:
F:\TEMP\xsl\decisionOfSupervisionFee.xsl

But I'm getting error if my file "views.properties" has such folder path in variable "stylesheetLocation":

decisionIType.(class) = ee.vet.tkis.domain.pdf.DecisionITypeView
decisionIType.contentType = application/pdf;charset=UTF-8
decisionIType.stylesheetLocation = F:\\TEMP\\xsl\\decisionsIType.xsl

The error is such:

SEVERE: Servlet.service() for servlet [toidukontroll] in context with path [/TKIS] threw exception [Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'decisionIType': Initialization of bean failed; nested exception is org.springframework.context.ApplicationContextException: Can't load XSLT stylesheet from ServletContext resource [/F:/TEMP/xsl/decisionsIType.xsl]; nested exception is java.io.FileNotFoundException: ServletContext resource [/F:/TEMP/xsl/decisionsIType.xsl] cannot be resolved to URL because it does not exist] with root cause
java.io.FileNotFoundException: ServletContext resource [/F:/TEMP/xsl/decisionsIType.xsl] cannot be resolved to URL because it does not exist
at org.springframework.web.context.support.ServletContextResource.getURL(ServletContextResource.java:129)
at org.springframework.web.servlet.view.xslt.AbstractXsltView.getStylesheetSource(AbstractXsltView.java:577)
at org.springframework.web.servlet.view.xslt.AbstractXsltView.getTemplates(AbstractXsltView.java:542)




Why i get this error?
My overall goal is to compile .WAR file so that folder containing XSL-files is outside the WAR-file, let's say i want the XSL files directory be folder "F:\\TEMP\\xsl
". How can i achieve that?
Maybe "views.properties" file does not allow full path with drive letter to attribute "stylesheetLocation"?

Charles Roos
Greenhorn

Joined: Dec 14, 2012
Posts: 5
I got solution, the full path should be with "file:///" prefix so:

Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1649
    
    7

Welcome to Java Ranch! Thanks for posting back with the solution.


[How To Ask Questions][Read before you PM me]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring "views.properties" file field "stylesheetLocation" needs to point outside of project/WAR-file