Spring unable to locate OSGi namespace handler
Asked Answered
C

3

18

I have a spring MVC projet that runs on eclipse virgo OSGi platform. When I attempt to import an OSGi service using <osgi:reference> tag I get the following exception :

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]

This is my application context file :

<?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>

And finally in my MANIFEST.MF file I'm doing this :

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

What am I doing wrong ???

Canny answered 15/4, 2012 at 14:24 Comment(9)
I don't understand why this question has been downvoted...Excide
Me too. No one gave me response and I'm still without solution :(Canny
@HoucemBerrayana, the question was posted more then year ago. Did you resolve the problem? If so, can you share how you did it? What jar(s) contain required NamespaceResolver for springframework.org/schema/osgi?Broadcaster
Yes, I was developing a POC and completely forgot what I've done. I remember that it was an import problem.Canny
@HoucemBerrayana, did you figure out what the issue was ? Would love to hear any thoughts you have. Am currently grappling with the same issue.Ailin
@AlexeyTigarev, I don't seem to have an import org.springframework.osgi.core. Do you have such an import which might be causing this issue?Ailin
@AshutoshJindal I forgot that was more than one year ago. Sorry but I remember that there was a solutionCanny
Ah no worries, I figured it out. I needed to have three jars available: spring-osgi-core, spring-osgi-extender and spring-osgi-io (all of these are artifacts in org.springframework.osgi maven group)Ailin
ok. put this as a response and I'll make it the right one ;)Canny
K
1

Try to change it from:

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

to:

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

The error shows your osgi schemaLocation is wrong.

Kristalkristan answered 10/5, 2017 at 2:36 Comment(0)
V
0

I doubt that you need to import org.springframework.osgi.core, so try removing that import.

Vesting answered 18/4, 2012 at 17:26 Comment(1)
That doesn't solve the problem. I have encountered this problem many times and it was always related to missing jars. But this time I don't understand what i'm doing wrong.Canny
R
0

If you are using maven you need to add the dependency

<dependency>
    <groupId>org.springframework.osgi</groupId>
    <artifactId>spring-osgi-core</artifactId>
    <version>1.2.1</version>
</dependency>

Since you are using the version OSGi jar version 1.2.1 the schema path in schema location needs to have changed like

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

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

Ratib answered 25/5, 2019 at 12:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.