[jboss-user] [JBoss/Spring Integration] - Re: Spring Component Auto Detection

khoerder do-not-reply at jboss.com
Thu Feb 26 11:21:27 EST 2009


Hi,

the issue remains with JBoss 5.0.1.GA and Spring 2.5.6. No problem with JBoss 4.x.

We have a web application and initialize the spring context with a ContextLoaderListener (referenced in web.xml). The spring-beans-config (in the classpath) uses "context:component-scan".

For a spring DispatcherServlet, an extra config-file must be provided in the /WEB-INF/ directory.

Depending on the type of deployment (exploded vs. war), the stack trace is 

java.io.FileNotFoundException: URL [vfsfile:/C:/dev/jboss-5.0.1.GA/server/default/deploy/exportmanager-server.war/WEB-INF/classes/de/bafa/] cannot be resolved to absolute file path because it does not reside in the file system: vfsfile:/C:/dev/jboss-5.0.1.GA/server/default/deploy/exportmanager-server.war/WEB-INF/classes/de/bafa/
	at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:201)
	at org.springframework.core.io.UrlResource.getFile(UrlResource.java:156)
	at org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingFileResources(PathMatchingResourcePatternResolver.java:517)
	at org.springframework.web.context.support.ServletContextResourcePatternResolver.doFindPathMatchingFileResources(ServletContextResourcePatternResolver.java:80)
	at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:342)
	at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:263)
	at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1018)
	at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:182)
	at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:201)
	at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)
...

or 

2009-02-26 14:09:45,578 DEBUG [org.springframework.core.io.support.PathMatchingResourcePatternResolver] (HDScanner) Cannot search for matching files underneath URL [vfszip:/C:/dev/jboss-5.0.1.GA/server/default/deploy/exportmanager-server.war/WEB-INF/classes/de/bafa/] because it does not correspond to a directory in the file system
java.io.FileNotFoundException: URL [vfszip:/C:/dev/jboss-5.0.1.GA/server/default/deploy/exportmanager-server.war/WEB-INF/classes/de/bafa/] cannot be resolved to absolute file path because it does not reside in the file system: vfszip:/C:/dev/jboss-5.0.1.GA/server/default/deploy/exportmanager-server.war/WEB-INF/classes/de/bafa/
	at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:198)
	at org.springframework.core.io.UrlResource.getFile(UrlResource.java:156)
	at org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingFileResources(PathMatchingResourcePatternResolver.java:517)
	at org.springframework.web.context.support.ServletContextResourcePatternResolver.doFindPathMatchingFileResources(ServletContextResourcePatternResolver.java:80)
	at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:342)
	at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:263)
	at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1019)
	at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:177)
	at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:201)
	at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:85)

The fix provided in Spring 2.5.6 had no effect (see http://jira.springframework.org/browse/SPR-5120).

The code provided in http://anonsvn.jboss.org/repos/jbossas/trunk/spring-int/src/main/org/jboss/spring/io/ solved the problem for the spring-beans-config in the classpath, but then the config-file in /WEB-INF/ was not found anymore.

Temporary fix for our issue:
1. Overwrite the spring-class "XmlWebApplicationContext": 
	
  |        protected ResourcePatternResolver getResourcePatternResolver() {
  | 		return new VFSResourcePatternResolver(this);
  | 	}
  | 
  | 	public Resource getResource(String location) {
  | 		Assert.notNull(location, "Location must not be null");
  | 		if (location.startsWith(CLASSPATH_URL_PREFIX)) {
  | 			return new ClassPathResource(location
  | 					.substring(CLASSPATH_URL_PREFIX.length()), getClassLoader());
  | 		} else {
  | 			try {
  | 				// Try to parse the location as a URL...
  | 				URL url = new URL(location);
  | 				VirtualFile file = VFS.getRoot(url);
  | 				return new VFSResource(file);
  | 			} catch (Exception ex) {
  | 				return new ServletContextResource(getServletContext(), location);
  | 			}
  | 		}
  | 	}
  | 

2. Check out the files from http://anonsvn.jboss.org/repos/jbossas/trunk/spring-int/src/main/org/jboss/spring/io/ and modify class "VFSResourcePatternResolver" in the following way:

  |    public VFSResourcePatternResolver(ResourceLoader resourceLoader)
  |    {
  |       super(resourceLoader);
  |    }
  | 

The point here is to use VFSResourcePatternResolver but wrap the path for the /WEB-INF/-file as a ServletContextResource.

In my opinion, such issues should be fixed in JBoss or Spring, but not by customers using these two wide-spread frameworks! - I'd rather use another application sever than fixing these kind of things for production use, making version upgrades a potential problem. 

Would it be possible to talk to the people developing Spring directly, so that these issues can be solved in on of the next releases (of either JBoss or Spring)?


View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4213429#4213429

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4213429



More information about the jboss-user mailing list