URLClassLoader does not find folders in jar if not ending with '/'?

Posted by IttayD on Stack Overflow See other posts from Stack Overflow or by IttayD
Published on 2010-03-16T16:07:10Z Indexed on 2010/03/16 16:11 UTC
Read the original article Hit count: 289

Filed under:
|
|

A 3rd party library (jersey) is trying to find Java packages by ClassLoader#findResource passing in the package name as file name (replacing dots with slashes). What I see is that if I pass a package name as 'a.b.c' (converted to 'a/b/c') it is not found, but if I pass 'a.b.c.' it is found. This translated directly to URL#inputStream that uses ZipFile which doesn't find the entry a/b/c, but finds the entry a/b/c/

I'm trying to find if this is the intended behavior or is there something wrong with my packaging (maven) or the URLs passed to the classloader (which look like jar:file://C:/.../foo.jar!/)

© Stack Overflow or respective owner

Related posts about java

Related posts about classloader