lugte098
lugte098

Reputation: 2309

No declaration can be found for element 'osgi:reference'

I am running on Apache ServiceMix 6.1.0.

I have the following dependencies in pom.xml of the foo project:

<dependencies>
    <dependency>
        <groupId>com.proj.bar</groupId>
        <artifactId>foo</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>3.2.14.RELEASE</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-parent</artifactId>
        <version>2.15.3</version>
        <type>pom</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.compendium</artifactId>
        <version>4.2.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>2.15.3</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

I have the following in my spring core-context.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:osgi="http://www.springframework.org/schema/osgi"
   xmlns:camel="http://camel.apache.org/schema/spring"
   xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
   http://camel.apache.org/schema/spring
   http://camel.apache.org/schema/spring/camel-spring.xsd
   http://www.springframework.org/schema/osgi-compendium
   http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd">

    <!-- OSGI SERVICE REGISTER -->
    <osgi:service id="configService" interface="com.proj.bar.foo.service.interfaces.IConfigService" ref="configServiceBean">
        <service-properties>
            <entry key="osgi.jndi.service.name" value="ConfigService" />
        </service-properties>
    </osgi:service>
</beans>

I have the following in my spring foo-context.xml

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:osgi="http://www.springframework.org/schema/osgi"
   xmlns:camel="http://camel.apache.org/schema/spring"
   xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
   http://camel.apache.org/schema/spring
   http://camel.apache.org/schema/spring/camel-spring.xsd
   http://www.springframework.org/schema/osgi-compendium
   http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd">

    <!-- SERVICE REFERENCES -->
    <osgi:reference id="configService"
                interface="com.proj.bar.foo.service.interfaces.IConfigService"
                filter="(osgi.jndi.service.name=ConfigService)"/>
</beans>

I am getting the following Exception:

2015-12-16 11:24:20,550 | ERROR | ExtenderThread-8 | ContextLoaderListener            | 94 - org.springframework.osgi.extender - 1.2.1 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=foo, config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 16 in XML document from URL [bundle://248.29:0/META-INF/spring/foo-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'osgi:reference'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:397)[87:org.apache.servicemix.bundles.spring-beans:3.2.14.RELEASE_1]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)[87:org.apache.servicemix.bundles.spring-beans:3.2.14.RELEASE_1]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)[87:org.apache.servicemix.bundles.spring-beans:3.2.14.RELEASE_1]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)[87:org.apache.servicemix.bundles.spring-beans:3.2.14.RELEASE_1]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)[87:org.apache.servicemix.bundles.spring-beans:3.2.14.RELEASE_1]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)[87:org.apache.servicemix.bundles.spring-beans:3.2.14.RELEASE_1]
at org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:164)[93:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:136)[93:org.springframework.osgi.core:1.2.1]
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)[89:org.apache.servicemix.bundles.spring-context:3.2.14.RELEASE_1]
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:539)[89:org.apache.servicemix.bundles.spring-context:3.2.14.RELEASE_1]
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$800(AbstractDelegatedExecutionApplicationContext.java:69)[93:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$3.run(AbstractDelegatedExecutionApplicationContext.java:269)[93:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[93:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.startRefresh(AbstractDelegatedExecutionApplicationContext.java:247)[93:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:214)[94:org.springframework.osgi.extender:1.2.1]
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:169)[94:org.springframework.osgi.extender:1.2.1]
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:175)[93:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:716)[94:org.springframework.osgi.extender:1.2.1]
at java.lang.Thread.run(Thread.java:744)[:1.7.0_45]
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'osgi:reference'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)[:]
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)[:]
at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown Source)[:]
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)[:]
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)[:]
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)[:]
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)[:]
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)[:]
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)[:]
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)[:]
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)[:]
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)[87:org.apache.servicemix.bundles.spring-beans:3.2.14.RELEASE_1]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:389)[87:org.apache.servicemix.bundles.spring-beans:3.2.14.RELEASE_1]
... 18 more

I am completely at a loss of what i can do to fix this. It seems to be working fine in my core project, but i am not doing anything different. It seems like it doesn't recognize the osgi:reference tag, but the namespace definitions should be correct.

Does anyone know what might cause this?

Thnx in advance!

Upvotes: 0

Views: 908

Answers (1)

bgossit
bgossit

Reputation: 1086

Your xsi:schemaLocation is missing a reference to osgi, it only has osgi-compendium.

You also need to add this:

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

Upvotes: 1

Related Questions