1

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!

Maxuel
  • 127
  • 10
  • I'm guessing that xxxServiceService.jar isn't on the WAR classpath. Do you have a Class-Path header in the MANIFEST.MF of the war that points to the jar? – Alasdair Mar 12 '20 at 12:53
  • @Alasdair no, actually the MANIFEST.MF is empty. – Maxuel Mar 12 '20 at 13:05
  • In theory, the EAR/lib directory should be added to the application's class path by default... but it's possible that it isn't - in my experience, the most common reason for that is that your application is declared for a pre-Java EE 5 spec level. If your application contains an application.xml, can you check that file and see what level of J2EE/Java EE it declares in the header? If it's 1.4 or earlier, you need either a new deployment descriptor or a manifest class path (or put the jar in the WAR's WEB-INF/lib instead of the EAR's /lib). – Jarid Mar 12 '20 at 17:16

1 Answers1

0

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.

t3rmian
  • 641
  • 1
  • 7
  • 13