You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by 魏昕路 <ap...@gmail.com> on 2013/07/09 12:52:52 UTC

OSGi and Spring component-scan

Hello,

I'm a new guy to osgi and web app. I'm using Websphere application server
v8.5 Liberty Profile developing a web osgi bundle. So, arise blueprint is
being used by default. In that bundle, I used Spring
(context:component-scan) and got exceptions says
"java.io.FileNotFoundException: URL
[bundleresource://873.fwk-1377360156/com/xxx/xx/] cannot be resolved to
absolute file path because it does not reside in the file system".

I googled and it seems a common problem. But all solution I found is using
Eclipse Gemini blueprint. I'm wondering if there is another solution for
this?

Attached some of my code and config files as below:

Web.xml
<servlet>
<display-name>spring</display-name>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

spring-servlet.xml
<!-- Scans the classpath of this application for @Components to deploy as
beans -->
<context:component-scan base-package="com.xxx.xx" />

When I run application and access it, I got below exceptions in console:
[WARN]18:43:06(PathMatchingResourcePatternResolver.java:530) - Cannot
search for matching files underneath URL
[bundleresource://873.fwk-1377360156/com/xxx/xx/] because it does not
correspond to a directory in the file system
java.io.FileNotFoundException: URL
[bundleresource://873.fwk-1377360156/com/xxx/xx/] cannot be resolved to
absolute file path because it does not reside in the file system:
bundleresource://873.fwk-1377360156/com/xxx/xx/
at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:205)
at
org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:52)
at org.springframework.core.io.UrlResource.getFile(UrlResource.java:169)
at
org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingFileResources(PathMatchingResourcePatternResolver.java:526)
at
org.springframework.web.context.support.ServletContextResourcePatternResolver.doFindPathMatchingFileResources(ServletContextResourcePatternResolver.java:92)
at
org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:347)
at
org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:266)
at
org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1250)
at
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:228)
at
org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)
at
org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)
at
org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
at
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1419)
at
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1409)
at
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
at
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
at
org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
at
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:527)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:441)
at
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
at
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
at
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
at
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
at
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
at
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
at javax.servlet.GenericServlet.init(GenericServlet.java:161)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:322)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.loadOnStartupCheck(ServletWrapper.java:1369)
at
com.ibm.ws.webcontainer.webapp.WebApp.doLoadOnStartupActions(WebApp.java:1091)
at
com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinally(WebApp.java:1059)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:965)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:6038)
at
com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApp(DynamicVirtualHost.java:421)
at
com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.createRunnableHandler(DynamicVirtualHost.java:241)
at
com.ibm.ws.http.internal.VirtualHostImpl.discriminate(VirtualHostImpl.java:182)
at
com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:169)
at
com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:448)
at
com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:382)
at
com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:282)
at
com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:253)
at
com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:174)
at
com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:83)
at
com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:502)
at
com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:550)
at
com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:899)
at
com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:981)
at com.ibm.ws.threading.internal.Worker.executeWork(Worker.java:439)
at com.ibm.ws.threading.internal.Worker.run(Worker.java:421)
at java.lang.Thread.run(Thread.java:770)

Re: OSGi and Spring component-scan

Posted by Graham Charters <gc...@gmail.com>.
Hi, I've just replied to your what I believe is your equivalent post on the
WASdev forum.

https://www.ibm.com/developerworks/community/forums/html/topic?id=fead994c-1d1c-49e8-9eb5-9b5fe2b55c93&ps=25

I hope this helps.

Regards, Graham.


On 9 July 2013 11:52, 魏昕路 <ap...@gmail.com> wrote:

> Hello,
>
> I'm a new guy to osgi and web app. I'm using Websphere application server
> v8.5 Liberty Profile developing a web osgi bundle. So, arise blueprint is
> being used by default. In that bundle, I used Spring
> (context:component-scan) and got exceptions says
> "java.io.FileNotFoundException: URL
> [bundleresource://873.fwk-1377360156/com/xxx/xx/] cannot be resolved to
> absolute file path because it does not reside in the file system".
>
> I googled and it seems a common problem. But all solution I found is using
> Eclipse Gemini blueprint. I'm wondering if there is another solution for
> this?
>
> Attached some of my code and config files as below:
>
> Web.xml
> <servlet>
> <display-name>spring</display-name>
>  <servlet-name>spring</servlet-name>
>
> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
>  <load-on-startup>1</load-on-startup>
> </servlet>
> <servlet-mapping>
>     <servlet-name>spring</servlet-name>
>     <url-pattern>/*</url-pattern>
>  </servlet-mapping>
>
> spring-servlet.xml
> <!-- Scans the classpath of this application for @Components to deploy as
> beans -->
>  <context:component-scan base-package="com.xxx.xx" />
>
> When I run application and access it, I got below exceptions in console:
> [WARN]18:43:06(PathMatchingResourcePatternResolver.java:530) - Cannot
> search for matching files underneath URL
> [bundleresource://873.fwk-1377360156/com/xxx/xx/] because it does not
> correspond to a directory in the file system
> java.io.FileNotFoundException: URL
> [bundleresource://873.fwk-1377360156/com/xxx/xx/] cannot be resolved to
> absolute file path because it does not reside in the file system:
> bundleresource://873.fwk-1377360156/com/xxx/xx/
>  at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:205)
> at
> org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:52)
>  at org.springframework.core.io.UrlResource.getFile(UrlResource.java:169)
> at
> org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingFileResources(PathMatchingResourcePatternResolver.java:526)
>  at
> org.springframework.web.context.support.ServletContextResourcePatternResolver.doFindPathMatchingFileResources(ServletContextResourcePatternResolver.java:92)
>  at
> org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:347)
> at
> org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:266)
>  at
> org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1250)
> at
> org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:228)
>  at
> org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)
> at
> org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)
>  at
> org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
> at
> org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1419)
>  at
> org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1409)
> at
> org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
>  at
> org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
> at
> org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
>  at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
> at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
>  at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
> at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
>  at
> org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
> at
> org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
>  at
> org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
> at
> org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
>  at
> org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
> at
> org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
>  at
> org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:527)
> at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:441)
>  at
> org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
> at
> org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
>  at
> org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
> at
> org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
>  at
> org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
> at
> org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
>  at javax.servlet.GenericServlet.init(GenericServlet.java:161)
> at
> com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:322)
>  at
> com.ibm.ws.webcontainer.servlet.ServletWrapper.loadOnStartupCheck(ServletWrapper.java:1369)
> at
> com.ibm.ws.webcontainer.webapp.WebApp.doLoadOnStartupActions(WebApp.java:1091)
>  at
> com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinally(WebApp.java:1059)
> at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:965)
>  at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:6038)
> at
> com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApp(DynamicVirtualHost.java:421)
>  at
> com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.createRunnableHandler(DynamicVirtualHost.java:241)
> at
> com.ibm.ws.http.internal.VirtualHostImpl.discriminate(VirtualHostImpl.java:182)
>  at
> com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:169)
> at
> com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:448)
>  at
> com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:382)
> at
> com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:282)
>  at
> com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:253)
> at
> com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:174)
>  at
> com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:83)
> at
> com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:502)
>  at
> com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:550)
> at
> com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:899)
>  at
> com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:981)
> at com.ibm.ws.threading.internal.Worker.executeWork(Worker.java:439)
>  at com.ibm.ws.threading.internal.Worker.run(Worker.java:421)
> at java.lang.Thread.run(Thread.java:770)
>