You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Freeman Fang <fr...@gmail.com> on 2012/11/01 02:05:54 UTC

Re: Can not call JBI endpoint from blueprint

Hi,

Most likely this error is caused by bundle start sequence. Per the async nature of OSGi, your logic shouldn't rely on the bundle start sequence.
So if you want to send message to 
ENDPOINT_NAME=ID:myhost-13ab72ce48c-0:0
but this endpoint isn't up yet, you see such exception.

Several options.
Option1
if you use karaf feature to deploy bundles, you can specify lower start-level to the bundle which you wanna start early. This way is simple and very helpful in most cases, but it still can't fully guarantee bundle start sequence.

So Option2
The only way I know can guarantee one bundle(A) fully started before another one(bundleB) is  that bundle A export an OSGi service and bundle B refer this OSGi service.

Freeman

-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: http://weibo.com/u/1473905042

On 2012-10-31, at 下午11:31, gasius wrote:

> Hi,
> 
> I need to call JBI endpoint from my OSGi bundle using blueprint (route to
> legacy application). At first I received NPE in JbiEndpoint when deploying
> bundle. After finding issue 
> https://issues.apache.org/jira/browse/SMXCOMP-945
> <https://issues.apache.org/jira/browse/SMXCOMP-945>   I installed
> servicemix-camel version 2011.02.2 and it solved that problem. But now
> everything works well only before SMX restart. After restart I receive NPE
> in another place /JbiBinding.createJbiMessageExchange(JbiBinding.java:151)/.
> The only way to fix this is to stop SMX, clean data/cache directory, start
> SMX and make fresh installation of my applications. But this is very tedious
> activity.
> 
> Comparing logs of fresh and not-fresh start of application I have found one
> difference. When it is fresh start I see this:
> 
> /ManagementEndpointRegistry       | 170 -
> org.apache.servicemix.nmr.management - 1.5.0 | Registering endpoint:
> org.apache.servicemix.nmr.core.InternalEndpointWrapper@9ce5306e with
> properties {ENDPOINT_NAME=ID:myhost-13ab72ce48c-0:0,
> javax.jbi.servicedesc.ServiceEndpoint=org.apache.servicemix.common.ExternalEndpoint@2091ad16,
> jbi.external=true,
> NAME={http://camel.apache.org/schema/jbi}provider:ID:myhost-13ab72ce48c-0:0,
> objectClass=[Ljava.lang.String;@3bfa900e, service.id=426,
> SERVICE_NAME={http://camel.apache.org/schema/jbi}provider,
> UNTARGETABLE=true}/
> 
> But I cannot see anything like this for non-fresh start. Can someone advise
> me?
> 
> 
> 
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Can-not-call-JBI-endpoint-from-blueprint-tp5714805.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Can not call JBI endpoint from blueprint

Posted by gasius <na...@combalt.com>.
I think there is no matter if I deploy consumer endpoint or not in any case I
should not get NPE. But of course I tried to deploy jbi consumer, in this
case very simple:

/        <camel:route id="smx4tolegacy">
            <camel:from uri="jbi:service:http://test.com/TestService" />
            <camel:log message="Legacy app contains ${body}" />
        </camel:route>
/
And like I said it works only when I start totally fresh SMX (cleared cache
and jbi folders before start). If I shutdown and start again then no matter
which application starts first and which second (tried various combinations)
I always get NPE stacktrace which posted earlier.



--
View this message in context: http://servicemix.396122.n5.nabble.com/Can-not-call-JBI-endpoint-from-blueprint-tp5714805p5714811.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Can not call JBI endpoint from blueprint

Posted by gasius <na...@combalt.com>.
As I mentioned I can see that after fresh start jbi provider was registered
as OSGi service with InternalEndpointWrapper. When I print command
*services:list 177* (177 is PID of org.apache.servicemix.jbi.osgi bundle) I
can see it in the list:

/Apache ServiceMix :: JBI :: OSGi (177) provides:
------------------------------------------------
objectClass = org.apache.servicemix.jbi.runtime.ComponentRegistry
osgi.service.blueprint.compname = componentRegistry
service.id = 330
----
......
----
*ENDPOINT_NAME = ID:myhost-13abc443ee9-0:0*
javax.jbi.servicedesc.ServiceEndpoint =
org.apache.servicemix.common.ExternalEndpoint@5e9e6837
jbi.external = true
NAME =
{http://camel.apache.org/schema/jbi}provider:ID:myhost-13abc443ee9-0:0
objectClass = org.apache.servicemix.nmr.api.Endpoint
service.id = 429
SERVICE_NAME = {http://camel.apache.org/schema/jbi}provider
UNTARGETABLE = true/

But when I execute same command after restart I can not see my jbi provider
in the list. Is there any way to enforce registration of my jbi provider? I
tried to add this to my blueprint:

/<bean class="org.apache.servicemix.common.osgi.EndpointExporter" />/

But nothing has changed.



--
View this message in context: http://servicemix.396122.n5.nabble.com/Can-not-call-JBI-endpoint-from-blueprint-tp5714805p5714814.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Can not call JBI endpoint from blueprint

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

Did you ever really deploy a JBI endpoint play the role as a provider, so that the camel jbi consumer endpoint can talk to?
Please take a look at [1] to get more details about how camel-jbi works
[1]http://camel.apache.org/jbi.html
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: http://weibo.com/u/1473905042

On 2012-11-1, at 下午3:15, gasius wrote:

> Thank you for response but seems it's not the case.
> 
> My blueprint refers to the class which defines one simple route:
> /from("timer:foo?period=5000").setBody().constant("<xml>hello</xml>").log("SMX4
> app contains ${body}").to("jbi:service:http://test.com/TestService");/
> 
> When I start fresh SMX instance (after cache clean) and deploy this
> application I can see such message in log (it's ok because I do not deploy
> 2nd application containing jbi endpoint):
> 
> /SMX4 app contains <xml>hello</xml>
> Error processing exchange [ ... ]
> Could not dispatch exchange. No matching endpoints./
> 
> But when I restart SMX instance I always can see only this:
> 
> /SMX4 app contains <xml>hello</xml>
> Failed delivery for exchangeId: ID-myhost-55497-1351693058334-2-1. Exhausted
> after delivery attempt: 1 caught: java.lang.NullPointerException
> java.lang.NullPointerException
> 	at
> org.apache.servicemix.camel.JbiBinding.createJbiMessageExchange(JbiBinding.java:151)[195:servicemix-camel:2011.02.2]
> 	at
> org.apache.servicemix.camel.JbiBinding.makeJbiMessageExchange(JbiBinding.java:125)[195:servicemix-camel:2011.02.2]
> 	at
> org.apache.servicemix.camel.CamelConsumerEndpoint.prepareMessageExchange(CamelConsumerEndpoint.java:127)[195:servicemix-camel:2011.02.2]
> 	at
> org.apache.servicemix.camel.CamelConsumerEndpoint.process(CamelConsumerEndpoint.java:104)[195:servicemix-camel:2011.02.2]
> 	at
> org.apache.servicemix.camel.JbiEndpoint$JbiProducer$2.call(JbiEndpoint.java:130)[195:servicemix-camel:2011.02.2]
> 	at
> org.apache.servicemix.camel.JbiEndpoint$JbiProducer$2.call(JbiEndpoint.java:127)[195:servicemix-camel:2011.02.2]
> 	at
> org.apache.servicemix.camel.JbiBinding.runWithCamelContextClassLoader(JbiBinding.java:114)[195:servicemix-camel:2011.02.2]
> 	at
> org.apache.servicemix.camel.JbiEndpoint$JbiProducer.process(JbiEndpoint.java:127)[195:servicemix-camel:2011.02.2]
> 	at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:114)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:284)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:109)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:69)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:90)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:318)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:209)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:306)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.Pipeline.process(Pipeline.java:116)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.Pipeline.process(Pipeline.java:79)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:139)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:106)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:69)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:104)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:121)[91:org.apache.camel.camel-core:2.8.5]
> 	at
> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:58)[91:org.apache.camel.camel-core:2.8.5]
> 	at java.util.TimerThread.mainLoop(Timer.java:512)[:1.6.0_32]
> 	at java.util.TimerThread.run(Timer.java:462)[:1.6.0_32]/
> 
> 
> 
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Can-not-call-JBI-endpoint-from-blueprint-tp5714805p5714809.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Can not call JBI endpoint from blueprint

Posted by gasius <na...@combalt.com>.
Thank you for response but seems it's not the case.

My blueprint refers to the class which defines one simple route:
/from("timer:foo?period=5000").setBody().constant("<xml>hello</xml>").log("SMX4
app contains ${body}").to("jbi:service:http://test.com/TestService");/

When I start fresh SMX instance (after cache clean) and deploy this
application I can see such message in log (it's ok because I do not deploy
2nd application containing jbi endpoint):

/SMX4 app contains <xml>hello</xml>
Error processing exchange [ ... ]
Could not dispatch exchange. No matching endpoints./

But when I restart SMX instance I always can see only this:

/SMX4 app contains <xml>hello</xml>
Failed delivery for exchangeId: ID-myhost-55497-1351693058334-2-1. Exhausted
after delivery attempt: 1 caught: java.lang.NullPointerException
java.lang.NullPointerException
	at
org.apache.servicemix.camel.JbiBinding.createJbiMessageExchange(JbiBinding.java:151)[195:servicemix-camel:2011.02.2]
	at
org.apache.servicemix.camel.JbiBinding.makeJbiMessageExchange(JbiBinding.java:125)[195:servicemix-camel:2011.02.2]
	at
org.apache.servicemix.camel.CamelConsumerEndpoint.prepareMessageExchange(CamelConsumerEndpoint.java:127)[195:servicemix-camel:2011.02.2]
	at
org.apache.servicemix.camel.CamelConsumerEndpoint.process(CamelConsumerEndpoint.java:104)[195:servicemix-camel:2011.02.2]
	at
org.apache.servicemix.camel.JbiEndpoint$JbiProducer$2.call(JbiEndpoint.java:130)[195:servicemix-camel:2011.02.2]
	at
org.apache.servicemix.camel.JbiEndpoint$JbiProducer$2.call(JbiEndpoint.java:127)[195:servicemix-camel:2011.02.2]
	at
org.apache.servicemix.camel.JbiBinding.runWithCamelContextClassLoader(JbiBinding.java:114)[195:servicemix-camel:2011.02.2]
	at
org.apache.servicemix.camel.JbiEndpoint$JbiProducer.process(JbiEndpoint.java:127)[195:servicemix-camel:2011.02.2]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:114)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:284)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:109)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:69)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:90)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:318)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:209)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:306)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.Pipeline.process(Pipeline.java:116)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.Pipeline.process(Pipeline.java:79)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:139)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:106)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:69)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:104)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:121)[91:org.apache.camel.camel-core:2.8.5]
	at
org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:58)[91:org.apache.camel.camel-core:2.8.5]
	at java.util.TimerThread.mainLoop(Timer.java:512)[:1.6.0_32]
	at java.util.TimerThread.run(Timer.java:462)[:1.6.0_32]/



--
View this message in context: http://servicemix.396122.n5.nabble.com/Can-not-call-JBI-endpoint-from-blueprint-tp5714805p5714809.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.