PDA

View Full Version : Locating BeanFactoryDefinitions in OSGI environment


satishterala
Apr 25th, 2008, 01:43 PM
Hello
I am using Spring DM on top equinox to inject dependencies across bundles.
In on of my bundles I am using the spring-integration project to create channel, jms-sources and target adapters.

I use the following xml namespaces and tags to create the channel and the relavant adapters.


<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">

<context:annotation-config/>
<message-bus/>
<annotation-driven/>

<channel id="emailOut"/>

<channel id="emailResponseIn"/>


<jms-target channel="emailOut" jms-template="jmsSenderTemplate"/>

<jms-source channel="emailResponseIn" connection-factory="jmsConnectionFactory" destination="recieveFromDestination" />
</beans:beans>


When my OSGI container starts up, Spring DM fails to load this context xml and fails with the error

Apr 25, 2008 11:59:59 AM org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext startRefresh
SEVERE: Pre refresh error
org.springframework.beans.factory.parsing.BeanDefi nitionParsingException: Configuration problem: Cannot locate BeanDefinitionParser for element [jms-target]
Offending resource: URL [bundleentry://68/META-INF/spring/email-context.xml]
at org.springframework.beans.factory.parsing.FailFast ProblemReporter.fatal(FailFastProblemReporter.java :59)
at org.springframework.beans.factory.parsing.ReaderCo ntext.fatal(ReaderContext.java:68)
at org.springframework.beans.factory.parsing.ReaderCo ntext.fatal(ReaderContext.java:55)
at org.springframework.beans.factory.xml.NamespaceHan dlerSupport.findParserForElement(NamespaceHandlerS upport.java:79)
at org.springframework.beans.factory.xml.NamespaceHan dlerSupport.parse(NamespaceHandlerSupport.java:69)
at org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.parseCustomElement(BeanDefinition ParserDelegate.java:1253)
at org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.parseCustomElement(BeanDefinition ParserDelegate.java:1243)
at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.parseBeanDefinitions(Defau ltBeanDefinitionDocumentReader.java:135)


I have ensured that the spring integration adapter jars where these element processors are in my eclipse target platform and are in active state.

I am not sure if this is a problem with Spring-integration bundle or with Spring DM's loading of the releavant bean defintion parsers.

Let me know if you have any ideas on how to fix this.

thanks
-Satish

Costin Leau
Apr 25th, 2008, 04:05 PM
Satish, you need to deploy Spring-integration as a bundle and have Spring-Extender started so that it can pick the namespace parser and make it available to your bundle.
Note that your application context needs to be OSGi aware (part of Spring-DM) to take advantage of them.
See the reference documentation in Spring-DM for more information:
http://static.springframework.org/osgi/docs/current/reference/html/

Hope this helps,