1

In servlet 3, web-fragments are jars deployed under WAR's WEB-INF/libs. The resources of web-fragments will be merged and be traded as they are resources of WAR. But that's not suitable for every situation.

For example when I want to get some resources under web-fragment's WEB-INF directory, i cannot read them directly, because no matter it's in a jar or a war, the resources under WEB-INF is simply not accessable by URL. Even worse, the typical way to read such resource, with the help of ServletContext doesn't work for web-fragments, because they are jars, not a real directory structure.

Finally I found a solution, to read them with ClassLoader, anyway I still need the exact resource name, I cannot do something like give me all xml files under the directory WEB-INF/myconfig/ The only way I think is to scan all web-fragement jars, build a directory structure in memory. However I still don't know how to get the jar names of all web-fragments. If I cannot get them, I must scan all jars under WEB-INF/libs. Is there any better solution?

Thanks

cn1h
  • 1,188
  • 4
  • 16
  • 24
  • Did you ever find a solution for this? Currently I'm facing the same problem, that I cannot get Filepaths with ServletContext.getRealPath("/WEB-INF/file") – Ginkgochris Dec 02 '13 at 12:08

0 Answers0