PatternMatchingResourcePatternResolver, and jar resources
Hello,
I was merrily using ClassPathResource, until a fellow developer who uses the jar that my code ends up as alerted me to the fact that it doesn't read from jars. So, I switched over to PatternMatchingResourcePatternResolver. My code is:
PathMatchingResourcePatternResolver res = new PathMatchingResourcePatternResolver();
Resource cpr = res.getResource("classpath*:cnwk/deploy/dao/ibatisSQLMapsConfig.xml");
SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(new FileReader(cpr.getFile()));
Unfortunately, the res.getResource fails (I had it reading fine when my classpatch pointed to the classes directory that the xml files end up in, but not when the jar provided the classpath). I've tried a variety of different formats:
classpath*:cnwk/deploy/dao/ibatisSQLMapsConfig.xml
classpath:cnwk/deploy/dao/ibatisSQLMapsConfig.xml
classpath*:/cnwk/deploy/dao/ibatisSQLMapsConfig.xml
classpath:/cnwk/deploy/dao/ibatisSQLMapsConfig.xml
cnwk/deploy/dao/ibatisSQLMapsConfig.xml
/cnwk/deploy/dao/ibatisSQLMapsConfig.xml
None work.
jar -tvf includes:
884 Thu Oct 13 17:25:28 PDT 2005 cnwk/deploy/dao/ibatisSQLMapsConfig.xml
I have even had some exceptions that found the jar:
java.io.FileNotFoundException: class path resource [cnwk/deploy/dao/ibatisSQLMapsConfig.xml] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/home/firminr/projects/cnwkdeploy/dist/cnwk-deploy-2.3.2.jar!/cnwk/deploy/dao/ibatisSQLMapsConfig.xml
So, what am I missing? Did I just ignore a huge swathe of the docs?
Thanks :)