You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by John Dubchak <jo...@johndubchak.com> on 2015/06/12 00:28:13 UTC
ClassCastException in blueprint Route
Hi,
I have a service component, deployed as a separate bundle, that exports
a package, com.example.services.configuration, and a service that
implements a ConfigurationService interface in another package called
LocalService:
com.example.services.configruation.ConfigurationService
com.example.services.configruation.local.LocalConfigurationService
Another bundle imports the service using a filter (from the blueprint XML):
<reference id="configurationService"
interface="com.castlighthealth.services.configuration.ConfigurationService"
filter="(realm=local)"/>
and sets it as a property on a route bean. When I start this second
bundle in ServiceMix I am getting a stacktrace [1] and just can't seem
to figure out what I am doing wrong. Any guidance is very much appreciated.
John
[1]
2015-06-11 21:59:41,641 | ERROR | Thread-58 |
BlueprintContainerImpl | ? ?
| 7 - org.apache.aries.blueprint.core - 1.4.0 | Unable to start
blueprint container for bundle my-process-router
org.osgi.service.blueprint.container.ComponentDefinitionException:
Unable to initialize bean .camelBlueprint.factory.eventRouterContext
at
org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:714)
at
org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)
at
org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)
at
org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
at
java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_60-ea]
at
org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
at
org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)
at
org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:230)
at
org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:145)
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:753)
at
org.apache.camel.blueprint.handler.CamelNamespaceHandler$CamelDependenciesFinder.process(CamelNamespaceHandler.java:863)
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.processProcessors(BlueprintContainerImpl.java:528)
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:361)
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:269)
at
org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:276)
at
org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:245)
at
org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:235)
at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)
at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)
at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)
at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)
at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)
at
org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)
at
org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:695)
at
org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:483)
at
org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4244)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1923)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:931)
at
org.apache.karaf.shell.osgi.StartBundle.doExecute(StartBundle.java:37)
at
org.apache.karaf.shell.osgi.BundlesCommand.doExecute(BundlesCommand.java:37)
at
org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at
org.apache.karaf.shell.console.jline.Console.run(Console.java:183)
at java.lang.Thread.run(Thread.java:744)[:1.7.0_60-ea]
at
org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$4.doRun(ShellFactoryImpl.java:144)[47:org.apache.karaf.shell.ssh:2.3.4]
at
org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$4$1.run(ShellFactoryImpl.java:135)
at java.security.AccessController.doPrivileged(Native
Method)[:1.7.0_60-ea]
at javax.security.auth.Subject.doAs(Subject.java:356)[:1.7.0_60-ea]
at
org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$4.run(ShellFactoryImpl.java:133)[47:org.apache.karaf.shell.ssh:2.3.4]
Caused by: java.lang.ClassCastException:
com.example.services.configuration.local.LocalConfigurationService
cannot be cast to com.example.services.configuration.ConfigurationService
at
Proxy5216067d_ed21_408f_b02b_9397ef0efbb3.getCurrentConfiguration(Unknown Source)
at
com.example.services.routes.ConfigurableEndpointPair.getConfiguration(ConfigurableEndpointPair.java:24)
at
com.example.services.routes.ConfigurableEndpointPair.getInbound(ConfigurableEndpointPair.java:53)
at
com.example.services.routes.EventRoute.configure(EventRoute.java:55)
at
org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:322)
at
org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:276)
at
org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:262)
at
org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:679)
at
org.apache.camel.core.xml.AbstractCamelContextFactoryBean.installRoutes(AbstractCamelContextFactoryBean.java:761)
at
org.apache.camel.core.xml.AbstractCamelContextFactoryBean.setupRoutes(AbstractCamelContextFactoryBean.java:311)
at
org.apache.camel.blueprint.CamelContextFactoryBean.afterPropertiesSet(CamelContextFactoryBean.java:304)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)[:1.7.0_60-ea]
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_60-ea]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_60-ea]
at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_60-ea]
at
org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:297)
at
org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:958)
at
org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)
Re: ClassCastException in blueprint Route
Posted by yogu13 <yo...@gmail.com>.
Hello John,
The configuration seems to be good...
Does your LocalConfigurationService has a getCurrentConfiguration method ?
if yes then i hope its returning an instance which is of type
com.example.services.configuration.ConfigurationService
Regards,
-Yogesh
--
View this message in context: http://camel.465427.n5.nabble.com/ClassCastException-in-blueprint-Route-tp5768116p5768181.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ClassCastException in blueprint Route
Posted by John Dubchak <jo...@johndubchak.com>.
Hi Yogesh,
I actually (and accidentally) replied directly to Andy.
Here is the declaration of the bean and the service export in the
provider's blueprint.xml:
<bean id="configurationService"
class="com.example.services.configuration.local.LocalConfigurationService">
<property name="realm" value="local"/>
<property name="configuration" ref="configuration"/>
<property name="appName" value="The Process Manager"/>
</bean>
<service ref="configurationService"
interface="com.example.services.configuration.ConfigurationService">
<service-properties>
<entry key="realm" value="local"/>
</service-properties>
</service>
And here is the consumer's blueprint.xml importing it and referencing it:
<reference id="configurationService"
interface="com.example.services.configuration.ConfigurationService"
filter="(realm=local)"/>
John
On 6/12/15 10:08 PM, yogu13 wrote:
> Hello John,
>
> What i am saying is that the problem seems to be with the object returned by
> the getCurrentConfiguration method of your LocalConfigurationService.
>
> based on the trace
>
> Caused by: java.lang.ClassCastException:
> com.example.services.configuration.local.LocalConfigurationService
> cannot be cast to com.example.services.configuration.ConfigurationService
> at
> Proxy5216067d_ed21_408f_b02b_9397ef0efbb3.getCurrentConfiguration(Unknown
> Source)
>
> Also as Andrew mentions it would be great if you could post how the service
> is being declared along with the service properties
>
> Regards,
> -Yogesh
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/ClassCastException-in-blueprint-Route-tp5768116p5768149.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: ClassCastException in blueprint Route
Posted by yogu13 <yo...@gmail.com>.
Hello John,
What i am saying is that the problem seems to be with the object returned by
the getCurrentConfiguration method of your LocalConfigurationService.
based on the trace
Caused by: java.lang.ClassCastException:
com.example.services.configuration.local.LocalConfigurationService
cannot be cast to com.example.services.configuration.ConfigurationService
at
Proxy5216067d_ed21_408f_b02b_9397ef0efbb3.getCurrentConfiguration(Unknown
Source)
Also as Andrew mentions it would be great if you could post how the service
is being declared along with the service properties
Regards,
-Yogesh
--
View this message in context: http://camel.465427.n5.nabble.com/ClassCastException-in-blueprint-Route-tp5768116p5768149.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ClassCastException in blueprint Route
Posted by John Dubchak <jo...@johndubchak.com>.
Hi Yogesh,
Thank you for your reply. It seems that you're saying to ignore the
cause that it cannot cast LocalConfigurationService to
ConfigurationService. Is that correct?
Thanks,
John
On 6/11/15 8:54 PM, yogu13 wrote:
> Hi,
>
> Looking at the stacktrace... the problem seems to be with the object
> returned by the getCurrentConfiguration method of your
> LocalConfigurationService.
>
> Looking at the trace it looks like blueprint did resolved the reference to
> your implementation and returned a proxy for it.
>
> would suggest to have a close look at method...
>
> Regards,
> -Yogesh
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/ClassCastException-in-blueprint-Route-tp5768116p5768119.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: ClassCastException in blueprint Route
Posted by yogu13 <yo...@gmail.com>.
Hi,
Looking at the stacktrace... the problem seems to be with the object
returned by the getCurrentConfiguration method of your
LocalConfigurationService.
Looking at the trace it looks like blueprint did resolved the reference to
your implementation and returned a proxy for it.
would suggest to have a close look at method...
Regards,
-Yogesh
--
View this message in context: http://camel.465427.n5.nabble.com/ClassCastException-in-blueprint-Route-tp5768116p5768119.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ClassCastException in blueprint Route
Posted by Andrew Block <an...@gmail.com>.
John,
Would you be able to post how the service is being declared along with the service properties to ensure the correct service is being referenced in your consumer blueprint.
Thanks,
Andy
--
Andrew Block
On June 11, 2015 at 5:28:54 PM, John Dubchak (john@johndubchak.com) wrote:
Hi,
I have a service component, deployed as a separate bundle, that exports
a package, com.example.services.configuration, and a service that
implements a ConfigurationService interface in another package called
LocalService:
com.example.services.configruation.ConfigurationService
com.example.services.configruation.local.LocalConfigurationService
Another bundle imports the service using a filter (from the blueprint XML):
<reference id="configurationService"
interface="com.castlighthealth.services.configuration.ConfigurationService"
filter="(realm=local)"/>
and sets it as a property on a route bean. When I start this second
bundle in ServiceMix I am getting a stacktrace [1] and just can't seem
to figure out what I am doing wrong. Any guidance is very much appreciated.
John
[1]
2015-06-11 21:59:41,641 | ERROR | Thread-58 |
BlueprintContainerImpl | ? ?
| 7 - org.apache.aries.blueprint.core - 1.4.0 | Unable to start
blueprint container for bundle my-process-router
org.osgi.service.blueprint.container.ComponentDefinitionException:
Unable to initialize bean .camelBlueprint.factory.eventRouterContext
at
org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:714)
at
org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)
at
org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)
at
org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
at
java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_60-ea]
at
org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
at
org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)
at
org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:230)
at
org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:145)
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:753)
at
org.apache.camel.blueprint.handler.CamelNamespaceHandler$CamelDependenciesFinder.process(CamelNamespaceHandler.java:863)
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.processProcessors(BlueprintContainerImpl.java:528)
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:361)
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:269)
at
org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:276)
at
org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:245)
at
org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:235)
at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)
at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)
at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)
at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)
at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)
at
org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)
at
org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:695)
at
org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:483)
at
org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4244)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1923)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:931)
at
org.apache.karaf.shell.osgi.StartBundle.doExecute(StartBundle.java:37)
at
org.apache.karaf.shell.osgi.BundlesCommand.doExecute(BundlesCommand.java:37)
at
org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[15:org.apache.karaf.shell.console:2.3.4]
at
org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at
org.apache.karaf.shell.console.jline.Console.run(Console.java:183)
at java.lang.Thread.run(Thread.java:744)[:1.7.0_60-ea]
at
org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$4.doRun(ShellFactoryImpl.java:144)[47:org.apache.karaf.shell.ssh:2.3.4]
at
org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$4$1.run(ShellFactoryImpl.java:135)
at java.security.AccessController.doPrivileged(Native
Method)[:1.7.0_60-ea]
at javax.security.auth.Subject.doAs(Subject.java:356)[:1.7.0_60-ea]
at
org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$4.run(ShellFactoryImpl.java:133)[47:org.apache.karaf.shell.ssh:2.3.4]
Caused by: java.lang.ClassCastException:
com.example.services.configuration.local.LocalConfigurationService
cannot be cast to com.example.services.configuration.ConfigurationService
at
Proxy5216067d_ed21_408f_b02b_9397ef0efbb3.getCurrentConfiguration(Unknown Source)
at
com.example.services.routes.ConfigurableEndpointPair.getConfiguration(ConfigurableEndpointPair.java:24)
at
com.example.services.routes.ConfigurableEndpointPair.getInbound(ConfigurableEndpointPair.java:53)
at
com.example.services.routes.EventRoute.configure(EventRoute.java:55)
at
org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:322)
at
org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:276)
at
org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:262)
at
org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:679)
at
org.apache.camel.core.xml.AbstractCamelContextFactoryBean.installRoutes(AbstractCamelContextFactoryBean.java:761)
at
org.apache.camel.core.xml.AbstractCamelContextFactoryBean.setupRoutes(AbstractCamelContextFactoryBean.java:311)
at
org.apache.camel.blueprint.CamelContextFactoryBean.afterPropertiesSet(CamelContextFactoryBean.java:304)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)[:1.7.0_60-ea]
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_60-ea]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_60-ea]
at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_60-ea]
at
org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:297)
at
org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:958)
at
org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)