You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Dinesh <di...@gmail.com> on 2011/07/18 09:59:38 UTC

Problem with Camel,osgi-compendium and mvn camel:run

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.

Re: Problem with Camel,osgi-compendium and mvn camel:run

Posted by Freeman Fang <fr...@gmail.com>.
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:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com










Re: Problem with Camel,osgi-compendium and mvn camel:run

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Apr 14, 2014 at 12:37 AM, vrahul <vr...@gmail.com> wrote:
> I am using   2.10.0.redhat-60024 version but still getting the same namespace
> not found exception.
> Is there is a way to run the compendium namespace camel file in fuse ide/mvn
> camel:run.
>

No you cannot use camel:run to bootup a jvm with spring-dm that uses
OSGi compendion or other OSGi sutff. It only works if the spring xml
files is not using any of the osgi pieces.

You can take a look at pax-exam and maybe use that to bootup a karaf
based container with your code and with spring-dm, then it would work
as its a realy osgi container.


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



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Problem with Camel,osgi-compendium and mvn camel:run

Posted by vrahul <vr...@gmail.com>.
No i am not using Blueprint, I have to use spring only.



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

Re: Problem with Camel,osgi-compendium and mvn camel:run

Posted by Willem Jiang <wi...@gmail.com>.
Did you use blueprint to define the camel context?

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On April 14, 2014 at 3:37:45 PM, vrahul (vrahul1991@gmail.com) wrote:
> I am using 2.10.0.redhat-60024 version but still getting the same namespace
> not found exception.
> Is there is a way to run the compendium namespace camel file in fuse ide/mvn
> camel:run.
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-Camel-osgi-compendium-and-mvn-camel-run-tp4598536p5750176.html  
> Sent from the Camel - Users mailing list archive at Nabble.com.
>  


Re: Problem with Camel,osgi-compendium and mvn camel:run

Posted by vrahul <vr...@gmail.com>.
I am using   2.10.0.redhat-60024 version but still getting the same namespace
not found exception. 
Is there is a way to run the compendium namespace camel file in fuse ide/mvn
camel:run. 



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

Re: Problem with Camel,osgi-compendium and mvn camel:run

Posted by Claus Ibsen <cl...@gmail.com>.
Camel 2.10 will support running OSGi blueprint XML files using the mvn
camel:run plugin.
And the OSGi config admin should be supported as well (well as far as
we have seen/tested).



On Wed, May 2, 2012 at 6:45 PM, ychawla <pr...@yahoo.com> wrote:
> Hi Dinesh,
> You will see a similar error if you try to run Camel JUnit tests and are
> using OSGi for your properties file.  To make this slightly less painful,
> you can put your PropertyPlaceHolder in its own file.  For example, this
> file can be called properties-context.xml
>
> <beans xmlns="http://www.springframework.org/schema/beans" ...>
>
>    <osgix:cm-properties id="cfg-properties" persistent-id="cfg.id"/>
>    <ctx:property-placeholder properties-ref="cfg-properties"/>
>
> </beans>
>
> Then import this file in your camel-context.xml:
>
>        <import resource="properties-context.xml"/>
>
> Then under src/test/resources/META-INF/spring add a different
> properties-context.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans" ...>
>        <ctx:property-placeholder location="file:///${conf.home}/my.cfg"/>
> </beans>
>
> This way you can set this up once and then write J-Unit tests without having
> to change anything.
>
> This doesn't help for camel:run.  For this you can either set up ServiceMix
> debugging:
> http://www.ithoughts.de/servicemix-4-2-debugging-and-more-gotchas
>
> Or you can just comment out the OSGi properties and replace it with the
> spring file placeholder :-)
>
> -Yogesh
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-Camel-osgi-compendium-and-mvn-camel-run-tp4598536p5681080.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Problem with Camel,osgi-compendium and mvn camel:run

Posted by ychawla <pr...@yahoo.com>.
Hi Dinesh,
You will see a similar error if you try to run Camel JUnit tests and are
using OSGi for your properties file.  To make this slightly less painful,
you can put your PropertyPlaceHolder in its own file.  For example, this
file can be called properties-context.xml

<beans xmlns="http://www.springframework.org/schema/beans" ...>

    <osgix:cm-properties id="cfg-properties" persistent-id="cfg.id"/>
    <ctx:property-placeholder properties-ref="cfg-properties"/>

</beans>

Then import this file in your camel-context.xml:

	<import resource="properties-context.xml"/>

Then under src/test/resources/META-INF/spring add a different
properties-context.xml:

<beans xmlns="http://www.springframework.org/schema/beans" ...>
	<ctx:property-placeholder location="file:///${conf.home}/my.cfg"/>
</beans>

This way you can set this up once and then write J-Unit tests without having
to change anything.

This doesn't help for camel:run.  For this you can either set up ServiceMix
debugging:
http://www.ithoughts.de/servicemix-4-2-debugging-and-more-gotchas

Or you can just comment out the OSGi properties and replace it with the
spring file placeholder :-)

-Yogesh

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

Re: Problem with Camel,osgi-compendium and mvn camel:run

Posted by Willem Jiang <wi...@gmail.com>.
camel:run doesn't support to provide the OSGi services like you used in 
the ServiceMix.

If you want support the camel:run with your osgi application bundle. You 
may consider to provide your camel context with two layer.

one is for the pure Spring configuration without any OSGi service, you 
should not put it into some place like "META-INF/camel/" instead of the 
"META-INF/spring/" directory.

The other is wrap the configure file with OSGi configure Admin service, 
then you can using include resource to load the pure camel context like 
this.
<import resource="classpath:META-INF/camel/camel.xml" />

You can specify the Spring configure file url in the camel maven plugin 
like this and include the properties holder configurer properties.xml 
like this

<plugin>
                 <groupId>org.apache.camel</groupId>
                 <artifactId>camel-maven-plugin</artifactId>
                 <version>${camel.version}</version>
                 <configuration>
                     <!--  the spring context file must be separate from 
the OSGi bundle, so we provide one here -->
 
<fileApplicationContextUri>src/main/resources/META-INF/camel/camel.xml;src/main/resources/META-INF/camel/properties.xml
                     </fileApplicationContextUri>
                 </configuration>
             </plugin>

On 7/18/11 3:59 PM, 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.
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang