Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring OSGi类路径资源问题_Osgi_Fuseesb_Jbossfuse - Fatal编程技术网

Spring OSGi类路径资源问题

Spring OSGi类路径资源问题,osgi,fuseesb,jbossfuse,Osgi,Fuseesb,Jbossfuse,我试图在osgi(fuse esb)中部署一个基于spring的bundle。据我所知,maven项目将确保resources文件夹下的任何可用文件都可以在项目类路径中使用。我将该文件保存在resources/META-INF/spring/repo/test.db4o下 以下是spring上下文中的条目 <bean id="objectContainer" class="org.springmodules.db4o.ObjectContainerFactoryBean">

我试图在osgi(fuse esb)中部署一个基于spring的bundle。据我所知,maven项目将确保resources文件夹下的任何可用文件都可以在项目类路径中使用。我将该文件保存在resources/META-INF/spring/repo/test.db4o下

以下是spring上下文中的条目


<bean id="objectContainer" class="org.springmodules.db4o.ObjectContainerFactoryBean">
    <property name="databaseFile" value="classpath:META-INF/spring/repo/test.db4o" />
</bean>
我尝试了不同的组合,但OSGi似乎无法识别此文件。任何指示都将不胜感激


-谢谢,我终于找到问题了。ObjectContainerFactoryBean依赖OSGiResourceBundle将资源作为文件对象加载。尽管OSGiResourceBundle公开了一个名为getFile()的方法,但它在OSGi环境中并没有按预期工作。它总是需要一个文件协议,而作为URI返回的资源有一个协议“bundle”。因此,抛出异常。解决方法是使用inputstream或getUrl。因为我没有ObjectContainerFactoryBean的源代码,所以我必须扩展这个类来提供我自己的实现,它将文件作为inputstream加载。

test.db4o文件在哪个包中?您必须将它们放在同一个包中。它在同一个包中。您是否尝试过
类路径:/META-INF/spring/repo/test.db4o
(路径以斜线开头)@Claszen。。。我尝试了所有可能的组合。由于某种原因,它似乎不起作用。我甚至明确提到了pom中包含资源下的文件。{maven resources}、{maven dependencies}、repo/taxonomy.db4o=target/classes/repo/taxonomy.db4o您是否将文件放在src/**test**/resources(将不属于打包工件)或src/**main**/resources(将属于打包工件)中

java.io.FileNotFoundException: OSGi resource[classpath:META-INF/spring/repo/test.db4o|bnd.id=258|bnd.sym=taxonomydaoimplbundle] cannot be resolved to absolute file path because it does not reside in the file system: bundle://258.0:1/META-INF/spring/repo/test.db4o