首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring找不到OSGi命名空间处理程序

Spring找不到OSGi命名空间处理程序
EN

Stack Overflow用户
提问于 2012-04-15 22:24:23
回答 3查看 4.7K关注 0票数 18

我有一个在eclipse virgo OSGi平台上运行的spring MVC项目。当我尝试使用<osgi:reference>标签导入OSGi服务时,我得到以下异常:

代码语言:javascript
复制
Servlet /Web threw load() exception org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/osgi]

这是我的应用程序上下文文件:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">


<annotation-driven />


<resources mapping="/resources/**" location="/resources/" />


<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".jsp" />
</beans:bean>

<context:component-scan base-package="com.apptivit.web" />

<osgi:reference id="entityService" interface="com.apptivit.db.service.AbstractEntityService"/>  
</beans:beans>

最后,在我的MANIFEST.MF文件中,我这样做:

代码语言:javascript
复制
Manifest-Version: 1.0
Export-Package: com.apptivit.web;uses:="org.springframework.stereotype
 ,org.springframework.ui,org.springframework.web.bind.annotation"
Tool: Bundlor 1.0.0.RELEASE
Import-Package: com.apptivit.db.service,
 org.apache.log4j,
 org.slf4j,
 org.springframework.context;version="[3.0.5.RELEASE,3.0.5.RELEASE]",
 org.springframework.stereotype,
 org.springframework.ui,
 org.springframework.web.bind.annotation,
 org.springframework.web.context,
 org.springframework.web.servlet,
 org.springframework.web.servlet.view
Bundle-SymbolicName: webs
Bundle-Version: 0.0.1
Bundle-Name: WebSample
Bundle-Vendor: ApptivIT
Import-Bundle: org.springframework.osgi.core;version="[1.2.1,1.2.1]",
 org.springframework.beans;version="[3.0.5.RELEASE,3.0.5.RELEASE]",
 org.springframework.core;version="[3.0.5.RELEASE,3.0.5.RELEASE]"

我做错了什么?

EN

回答 3

Stack Overflow用户

发布于 2017-05-10 10:36:59

尝试将其更改为:

代码语言:javascript
复制
xsi:schemaLocation=
http://www.springframework.org/schema/osgi/spring-osgi.xsd"

至:

代码语言:javascript
复制
xsi:schemaLocation=
http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd

该错误显示您的osgi schemaLocation是错误的。

票数 1
EN

Stack Overflow用户

发布于 2012-04-19 01:26:28

我怀疑您是否需要导入org.springframework.osgi.core,因此尝试删除该导入。

票数 0
EN

Stack Overflow用户

发布于 2019-05-25 20:37:37

如果使用maven,则需要添加依赖项。

代码语言:javascript
复制
<dependency>
    <groupId>org.springframework.osgi</groupId>
    <artifactId>spring-osgi-core</artifactId>
    <version>1.2.1</version>
</dependency>

由于您使用的是版本OSGi jar版本1.2.1,因此模式位置中的模式路径需要进行如下更改

http://www.springframework.org/schema/osgi

http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10162853

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档