Access to web-inf from deployed jar

255 Views Asked by At

I'm currently facing a problem any time i try to access to WEB-INF/classes folder. Basically if I run the whole project on a local server it works and find the given file, but when i try to access to the same file after all the jar files have been created and deployed it gives my an error - the file doesn't exists

this is the current path on the server :

file:/product/WebSphere85/AppServer/profiles/opntship_node_1/installedApps/opntship/xxxService.ear/lib/xxxServiceService.jar!/xxx.pdf (A file or directory in the path name does not exist.)

this is the path on my local server:

/C:/Users/foo42/IBM/rationalsdp/workspace/TpdPrintServiceService/target/classes/xxx.pdf

this is how I get the file :

getClass().getResource("/"+fullFileName);

fileToBytes(new File(filePath.getFile()));

I tried in many ways to get access to the folder but still, it works locally but not on server :(

any idea how to fix this problem and access to the web-inf folder ?

Thanks in advance!

1

There are 1 best solutions below

0
t3rmian On

We cannot read the entries within an archive (xxxService.ear and xxxServiceService.jar) like it was a plain old File. You may want to try Thread.currentThread().getContextClassLoader().getResourceAsStream(path) instead.