Link to home
Start Free TrialLog in
Avatar of Rohit Bajaj
Rohit BajajFlag for India

asked on

java spring ClassPathResource

Hi,
I am getting the following exception :

java.io.FileNotFoundException: class path resource [xsl/ExtremeSearchRQ.xsl] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/data/ytxdist/SCHEDULER/ExtremeSearch/libs/yatra_extremesearch.jar!/xsl/ExtremeSearchRQ.xsl

The following code throws this exception :
String xslSourceFile = "xsl/ExtremeSearchRQ.xsl";
		String xmlSource = "ExtremeSearchRQ.xml";
		Writer paramWriter = new StringWriter();
		
		Transformer transformer=null;
		ClassPathResource resource = new ClassPathResource(xslSourceFile);
		StreamSource streamSrcFile;
		
		streamSrcFile = new StreamSource(resource.getFile());

Open in new window


The exception is thrown by the resource.getFile() line.

I am running my project with the following line :
java -cp "libs/*:conf" com.yatra.extremesearch.app.ExtremeSearchApp

Here the libs folder contains the yatra_extremesearch.jar file
when i unzip the jar i also see the file xsl/ExtremeSearchRQ.xsl

Still its giving an exception saying fileNot Found

What could be reason for this.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial