Is it possible to use spring inside war bundle on felix? I use spring 3.0.5 with felix on glassfish 3.1
I tried to enter component-scan
tag inside OSGI war bundle in felix, and I'm getting the below exception.
I saw that a similar bug was solved for Equinox, and what about felix? Is there a workaround or solution to this problem?
P.S: the same exception is thrown if I define path with * in web.xml contextConfigLocation
, for example:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:META-INF/spring/*.xml</param-value>
</context-param>
Exception:
2012-02-08 18:30:23,194 [pool-28-thread-1] (PathMatchingResourcePatternResolver.java:532) WARN - Cannot search for matching files underneath URL [bundle://275.0:2/examples/services/] because it does not correspond to a directory in the file system
java.io.FileNotFoundException: URL [bundle://275.0:2/examples/services/] cannot be resolved to absolute file path because it does not reside in the file system: bundle://275.0:2/examples/services/
at org.springframework.util.ResourceUtils.getFile(Res ourceUtils.java:204)
at org.springframework.core.io.AbstractFileResolvingR esource.getFile(AbstractFileResolvingResource.java :52)
at org.springframework.core.io.UrlResource.getFile(Ur lResource.java:168)
at org.springframework.core.io.support.PathMatchingRe sourcePatternResolver.doFindPathMatchingFileResour ces(PathMatchingResourcePatternResolver.java:528)
...
2012-02-08 18:30:23,194 [pool-28-thread-1] (PathMatchingResourcePatternResolver.java:353) DEBUG - Resolved location pattern [classpath*:examples/services/**/*.class] to resources []
applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx">
<context:annotation-config/>
<tx:annotation-driven />
<context:component-scan base-package="examples.services" />
</beans>
thank you for any tip
There are 2 workarounds I found to solve it. Still I'll be glad to hear a real solution for felix.
The workarounds are:
public static URL resolve(URL url) throws IOException
and return the url of content from this folder, for example:
String path = url.getPath();
String str;
if(path.contains("com")){
str = path.substring(path.indexOf("com"));
}
return new URL("file:\\c:\\temp_classes\\"+str);