-
Jun 26th, 2006, 08:53 PM
#1
Stupid question: Loading resources - classpath*: - from JAR files
Hi,
Here is a very stupid question I believe. I've just packaged my app into a jar file together with appropriate XML files (beanDefFactory.xml, etc), and XML files can no longer be found. Eg, this line:
BeanFactoryLocator bfl = SingletonBeanFactoryLocator.getInstance("classpath *:**/beanRefFactory.xml");
used to find all beanRefFactory.xml files in the 'unpacked' classpath. But once the XML files are in JAR, the PathMatchingResourcePatternResolver can't seem to be able to find them.
The docs say something about 'In the pattern case, the location has to be resolvable to java.io.File or to a "jar:" URL (leading to a java.net.JarURLConnection)', but I browsed through the source and couldn't find any explicit calls to load resources from the JAR...
I'm pretty sure it's doable and it's just stupid me who is missing something. So, what am I doing wrong?..
Thanks!
PS: I'm using Spring 1.2.8
-
Jun 28th, 2006, 10:02 AM
#2
for the record...
The problem was (as it actually hinted in the documentation) in the url pattern. This:
BeanFactoryLocator bfl = SingletonBeanFactoryLocator.getInstance("classpath *:com/mypackage/**/beanRefFactory.xml");
- works. In other words, when resources are loaded from the JAR, one really should put some sensible prefix in the url pattern, which won't contain wildcards. It really is mentioned in the docs, just a bit confusing, since pattern without prefix works perfectly fine for unpacked resources.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules