【问题标题】:Spring unable to locate OSGi namespace handlerSpring 无法定位 OSGi 命名空间处理程序
【发布时间】:2012-04-27 02:49:18
【问题描述】:

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

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]

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

<?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 文件中,我正在这样做:

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]"

我做错了什么???

【问题讨论】:

  • 我不明白为什么这个问题被否决了......
  • 我也是。没有人给我回应,我仍然没有解决方案:(
  • @HoucemBerraana,这个问题是一年前发布的。你解决问题了吗?如果是这样,你能分享一下你是怎么做到的吗?哪些 jar(s) 包含 springframework.org/schema/osgi 所需的 NamespaceResolver?
  • 是的,我正在开发 POC,完全忘记了我做了什么。我记得这是一个导入问题。
  • 啊,不用担心,我想通了。我需要三个可用的 jar:spring-osgi-core、spring-osgi-extender 和 spring-osgi-io(所有这些都是 org.springframework.osgi maven 组中的工件)

标签: java spring osgi eclipse-virgo spring-dm


【解决方案1】:

尝试将其更改为:

xsi:schemaLocation=
http://www.springframework.org/schema/osgi/spring-osgi.xsd"

到:

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

这个错误说明你的osgi schemaLocation是错误的。

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 这并不能解决问题。我多次遇到这个问题,它总是与缺少罐子有关。但这一次我不明白我做错了什么。
    【解决方案3】:

    如果你使用maven你需要添加依赖

    <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

    【讨论】:

      猜你喜欢
      • 2013-02-25
      • 2012-12-17
      • 1970-01-01
      • 1970-01-01
      • 2014-11-10
      • 2018-09-23
      • 1970-01-01
      • 1970-01-01
      • 2013-06-05
      相关资源
      最近更新 更多