Hi,

I don't think there's a way you can init camel-context which include spring-dm property placeholder outside the OSGi container. Because to init bean like id="testcfg" it will use OSGi configAdim service which need some core functionality from OSGi container such as bundleContext get involved anyway.

If you add
<dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring</artifactId>
        </dependency>
        <dependency>
                <groupId>org.springframework.osgi</groupId>
                <artifactId>spring-osgi-core</artifactId>
                <version>1.2.1</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework</groupId>
<artifactId>org.springframework.aop</ artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.springframework</groupId>
<artifactId>org.springframework.beans</ artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.springframework</groupId>
<artifactId>org.springframework.context</ artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.springframework</groupId>
<artifactId>org.springframework.core</ artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.osgi</groupId>
                <artifactId>org.osgi.core</artifactId>
                <version>4.2.0</version>
            </dependency>

into your pom you can get around the namespace handler issue but see more errors and you can get more concrete idea what I mean.

So if you want to run your camel context out of OSGi container, you have to remove such bean
<osgix:cm-properties id="testcfg" persistent-id="config" />
<ctx:property-placeholder properties-ref="testcfg" />
IMO.

Freeman



On 2011-7-18, at 下午3:59, Dinesh wrote:

We have camel based application as OSGi bundle and were able to run using
[mvn camel:run] apart from deploying it as a bundle in Servicemix.

Later we moved the properties file out of bundle.For this we have used
Compendium Services.This facilitates us to keep the configuration file
outside the bundle (in Servicemix_HOME/etc folder).To implement this we have addded http://www.springframework.org/schema/osgi-compendium"; namespace
handler  in the camel-context file. This namespace handler is part of
Spring-DM. So now we are we forced to deploy it in OSGi container. We can't
use [mvn camel:run]

Is there any way that we can run this using [mvn camel:run] without removing osgi-compendium namespace handler from camel-context file(so that we can keep the configuration file outside bundle in case when we deploy in OSGi
container)?

When using [mvn camel:run], we are getting the exception:

Error occurred while running main from: org.apache.camel.spring.Main
java.lang.reflect.InvocationTargetException
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at
sun .reflect .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at
sun .reflect .DelegatingMethodAccessorImpl .invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.apache.camel.maven.RunMojo$1.run(RunMojo.java:415)
       at java.lang.Thread.run(Thread.java:662)
Caused by:
org .springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/osgi-compendium ]
Offending resource: file
[D:\poc\camel-osgi-wkf\target\classes\META-INF\spring\camel- context.xml]
       at
org .springframework .beans .factory .parsing.FailFastProblemReporter.error(FailFastProblemReporter.java: 68)
       at
org .springframework .beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
       at
org .springframework .beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
       at
org .springframework .beans .factory .xml .BeanDefinitionParserDelegate .error(BeanDefinitionParserDelegate.java:284)
       at
org .springframework .beans .factory .xml .BeanDefinitionParserDelegate .parseCustomElement(BeanDefinitionParserDelegate.java:1332)
       at
org .springframework .beans .factory .xml .BeanDefinitionParserDelegate .parseCustomElement(BeanDefinitionParserDelegate.java:1325)
                
                
Our camel-context.xml is:
<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:osgix="http://www.springframework.org/schema/osgi-compendium";
        xmlns:ctx="http://www.springframework.org/schema/context";
        xsi:schemaLocation="
      http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
      http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
      http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
      http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd
      http://www.springframework.org/schema/osgi-compendium
http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium-1.2.xsd ">

<camelContext id="test-wkf" xmlns="http://camel.apache.org/schema/spring ">
                <propertyPlaceholder id="properties" location="ref:testcfg" />
                <routeBuilder ref="TestRoute" />
        </camelContext>

        <osgix:cm-properties id="testcfg" persistent-id="config" />

        <ctx:property-placeholder properties-ref="testcfg" />
        .........
        .........
</beans>

Any help/suggestion will be highly appreciated.

--
View this message in context: 
http://camel.465427.n5.nabble.com/Problem-with-Camel-osgi-compendium-and-mvn-camel-run-tp4598536p4598536.html
Sent from the Camel - Users mailing list archive at Nabble.com.

---------------------------------------------
Freeman Fang

FuseSource
Email:[email protected]
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com









Reply via email to