2016-07-04 3 views
0

При размещении комплекта (с использованием camel) на Karaf я вижу следующее исключение. Ниже приведено исключение, только когда пуск запущен. После этого все работает нормально. Исключение, похоже, не влияет на нашу функциональность. Вопрос идет как на camel 2.16.1 (развернуто на servicemix 6.1.0) и camel 2.16.3 (развернуто на servicemix 7.0.0M2).Ошибка при запуске верблюда из-за круговой зависимости

My blueprint Разделяется на три части. Упрощенный вариант из них представлены ниже: -

  1. blueprint.xml размещены here.
  2. productBeans.xml размещено here.
  3. camelContext.xml размещено here.

Может кто-нибудь, пожалуйста, дайте мне знать, почему это исключение приходит во время пучка? Из приведенной ниже статистики стека видно, что это связано с некоторой циклической зависимостью. Как я могу обойти это?

2016-07-04 11:29:37,497 | ERROR | mix-6.1.0/deploy | BlueprintCamelContext   | 143 - org.apache.camel.camel-blueprint - 2.16.1 | {{bundle.id,143}{bundle.name,org.apache.camel.camel-blueprint}{bundle.version,2.16.1}} | Error occurred during starting Camel: CamelContext(camel-1) due Failed to create route orchestrator-service-route at: >>> process[ref:jsonRPCProcessor] <<< in route: Route(orchestrator-service-route)[[From[jetty:http://0.0.0.0... because of Cannot lookup: jsonRPCProcessor from registry: [email protected] with expected type: interface org.apache.camel.Processor due: [BeanRecipe[name='myTemplate'], BeanRecipe[name='.camelBlueprint.bean.factory.myTemplate'], BeanRecipe[name='camel-1'], BeanRecipe[name='myTemplate']] 
org.apache.camel.FailedToCreateRouteException: Failed to create route orchestrator-service-route at: >>> process[ref:jsonRPCProcessor] <<< in route: Route(orchestrator-service-route)[[From[jetty:http://0.0.0.0... because of Cannot lookup: jsonRPCProcessor from registry: [email protected] with expected type: interface org.apache.camel.Processor due: [BeanRecipe[name='myTemplate'], BeanRecipe[name='.camelBlueprint.bean.factory.myTemplate'], BeanRecipe[name='camel-1'], BeanRecipe[name='myTemplate']] 
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1072) 
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196) 
    at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:947) 
    at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3258) 
    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2981) 
    at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175) 
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2812) 
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2808) 
    at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2831) 
    at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2808) 
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) 
    at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2777) 
    at org.apache.camel.blueprint.BlueprintCamelContext.start(BlueprintCamelContext.java:180)[143:org.apache.camel.camel-blueprint:2.16.1] 
    at org.apache.camel.blueprint.BlueprintCamelContext.maybeStart(BlueprintCamelContext.java:212)[143:org.apache.camel.camel-blueprint:2.16.1] 
    at org.apache.camel.blueprint.BlueprintCamelContext.serviceChanged(BlueprintCamelContext.java:150)[143:org.apache.camel.camel-blueprint:2.16.1] 
    at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:932)[org.apache.felix.framework-4.2.1.jar:] 
    at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:793)[org.apache.felix.framework-4.2.1.jar:] 
    at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:543)[org.apache.felix.framework-4.2.1.jar:] 
    at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4419)[org.apache.felix.framework-4.2.1.jar:] 
    at org.apache.felix.framework.Felix.registerService(Felix.java:3423)[org.apache.felix.framework-4.2.1.jar:] 
    at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346) 
    at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:352) 
    at org.apache.camel.blueprint.BlueprintCamelContext.init(BlueprintCamelContext.java:100)[143:org.apache.camel.camel-blueprint:2.16.1] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_77] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_77] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_77] 
    at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_77] 
    at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:299)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:956)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[15:org.apache.aries.blueprint.core:1.4.4] 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_77] 
    at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:247)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:230)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:145)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:754)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.camel.blueprint.CamelProducerTemplateFactoryBean.getCamelContextWithId(CamelProducerTemplateFactoryBean.java:49) 
    at org.apache.camel.core.xml.AbstractCamelFactoryBean.afterPropertiesSet(AbstractCamelFactoryBean.java:54) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_77] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_77] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_77] 
    at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_77] 
    at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:299)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:956)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[15:org.apache.aries.blueprint.core:1.4.4] 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_77] 
    at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:280)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:806)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[15:org.apache.aries.blueprint.core:1.4.4] 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_77] 
    at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.di.RefRecipe.internalCreate(RefRecipe.java:62)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:106)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:931)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:905)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:886)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:820)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[15:org.apache.aries.blueprint.core:1.4.4] 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_77] 
    at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:247)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:682)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:377)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:269)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:294)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:263)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:253)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[9:org.apache.aries.util:1.1.1] 
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[9:org.apache.aries.util:1.1.1] 
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[9:org.apache.aries.util:1.1.1] 
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[9:org.apache.aries.util:1.1.1] 
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[9:org.apache.aries.util:1.1.1] 
    at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)[org.apache.felix.framework-4.2.1.jar:] 
    at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:695)[org.apache.felix.framework-4.2.1.jar:] 
    at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:483)[org.apache.felix.framework-4.2.1.jar:] 
    at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4403)[org.apache.felix.framework-4.2.1.jar:] 
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2092)[org.apache.felix.framework-4.2.1.jar:] 
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)[org.apache.felix.framework-4.2.1.jar:] 
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)[org.apache.felix.framework-4.2.1.jar:] 
    at org.apache.karaf.features.internal.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:518)[20:org.apache.karaf.features.core:3.0.5] 
    at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeatures(FeaturesServiceImpl.java:476)[20:org.apache.karaf.features.core:3.0.5] 
    at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeature(FeaturesServiceImpl.java:417)[20:org.apache.karaf.features.core:3.0.5] 
    at Proxy1be55f4b_f63a_43b3_883f_77a48747d768.installFeature(Unknown Source)[:] 
    at Proxy1fa9f34f_3928_4828_8542_9d785df163bd.installFeature(Unknown Source)[:] 
    at org.apache.karaf.kar.internal.KarServiceImpl.installFeatures(KarServiceImpl.java:215)[160:org.apache.karaf.kar.core:3.0.5] 
    at org.apache.karaf.kar.internal.KarServiceImpl.install(KarServiceImpl.java:96)[160:org.apache.karaf.kar.core:3.0.5] 
    at org.apache.karaf.kar.internal.KarServiceImpl.install(KarServiceImpl.java:84)[160:org.apache.karaf.kar.core:3.0.5] 
    at Proxya6f8b1d5_e9a2_4e1b_a105_1552c365b9de.install(Unknown Source)[:] 
    at Proxye3575645_14c4_4cf9_8d71_16cd6e82b1a0.install(Unknown Source)[:] 
    at org.apache.karaf.deployer.kar.KarArtifactInstaller.install(KarArtifactInstaller.java:50)[162:org.apache.karaf.deployer.kar:3.0.5] 
    at Proxy6b7a1495_9239_4ff3_b9ed_1fd58a17750b.install(Unknown Source)[:] 
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.install(DirectoryWatcher.java:931)[7:org.apache.felix.fileinstall:3.5.0] 
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.install(DirectoryWatcher.java:865)[7:org.apache.felix.fileinstall:3.5.0] 
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:482)[7:org.apache.felix.fileinstall:3.5.0] 
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358)[7:org.apache.felix.fileinstall:3.5.0] 
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310)[7:org.apache.felix.fileinstall:3.5.0] 
Caused by: org.apache.camel.NoSuchBeanException: Cannot lookup: jsonRPCProcessor from registry: [email protected] with expected type: interface org.apache.camel.Processor due: [BeanRecipe[name='myTemplate'], BeanRecipe[name='.camelBlueprint.bean.factory.myTemplate'], BeanRecipe[name='camel-1'], BeanRecipe[name='myTemplate']] 
    at org.apache.camel.impl.CompositeRegistry.lookupByNameAndType(CompositeRegistry.java:62) 
    at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookupByNameAndType(PropertyPlaceholderDelegateRegistry.java:63) 
    at org.apache.camel.util.CamelContextHelper.lookup(CamelContextHelper.java:137) 
    at org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:157) 
    at org.apache.camel.impl.DefaultRouteContext.mandatoryLookup(DefaultRouteContext.java:151) 
    at org.apache.camel.model.ProcessDefinition.createProcessor(ProcessDefinition.java:95) 
    at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:534) 
    at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:495) 
    at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:219) 
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1069) 
    ... 105 more 
Caused by: org.apache.aries.blueprint.di.CircularDependencyException: [BeanRecipe[name='myTemplate'], BeanRecipe[name='.camelBlueprint.bean.factory.myTemplate'], BeanRecipe[name='camel-1'], BeanRecipe[name='myTemplate']] 
    at org.apache.aries.blueprint.container.BlueprintRepository.push(BlueprintRepository.java:343)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:71)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:247)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:230)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:145)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:754)[15:org.apache.aries.blueprint.core:1.4.4] 
    at org.apache.camel.blueprint.BlueprintContainerRegistry.lookupByNameAndType(BlueprintContainerRegistry.java:54) 
    at org.apache.camel.impl.CompositeRegistry.lookupByNameAndType(CompositeRegistry.java:56) 
    ... 114 more 

РЕДАКТИРОВАТЬ - Кажется, ошибка происходит потому, что jsonRPCProcessor использует myTemplate, как показано ниже: -

<bean id="jsonRPCProcessor"  class="com.j1.orchestratorservice.basecomponent.processor.JSONRPCProcessor"> 
     <argument ref="myTemplate" /> 
     <argument> 
      <map>   
       <!-- Product End Points --> 
       <entry key="Product.createProducts" value-ref="createProductsWFInfo" />    
      </map> 
     </argument> 
     <argument ref="exceptionHandler" /> 
    </bean> 

тогда myTemplate определяется в camelContext, который в свою очередь, использует jsonRPCProcessor, как показано ниже: -

<camelContext xmlns="http://camel.apache.org/schema/blueprint" 
     useMDCLogging="true"> 
     <template id="myTemplate" /> 
     <route id="orchestrator-service-route"> 
      <from uri="jetty:http://0.0.0.0:8888/orchestratorservice" /> 
      <process ref="jsonRPCProcessor" /> 
     </route> 
     <route id="file-upload-service-route"> 
      <from 
       uri="jetty:http://0.0.0.0:8889/fileuploadservice?enableMultipartFilter=true" /> 
      <process ref="fileUploadProcessor" /> 
     </route> 
... 
</camelContext> 

Я попытался et the producer в моем пользовательском Процессере, как указано в этом link. Может ли кто-нибудь предложить мне другой способ установить producer в моем обычном jsonRPCProcessor, чтобы он не приводил к какой-либо циклической зависимости?

+0

Есть ли причина, по которой вы разделили их на три файла? Почему бы и нет? –

+0

Да, это стало огромным. Здесь, чтобы стало легче понять, я добавил очень небольшую его часть. – tuk

+0

Ну, я имею в виду, что жалоба связана с круговой зависимостью, поэтому материалы в ваших конфигурационных файлах относятся друг к другу. Так вот что я имею в виду, возможно, поставить все в одном и убедиться, что он работает, а затем разделить их на три. –

ответ

0

Я могу обойти это, удалив myTemplate от jsonRPCProcesor и fileUploadProcessor. Теперь мой jsonRPCProcessor выглядеть, как показано ниже: -

<bean id="jsonRPCProcessor" class="com.j1.orchestratorservice.basecomponent.processor.JSONRPCProcessor"> 
    <argument> 
     <map>   
      <entry key="Product.createProducts" value-ref="createProductsWFInfo" /> 
     </map> 
    </argument> 
    <argument ref="exceptionHandler" /> 
</bean> 

аннотированный ProducerTemplate (в базовом классе) в моем коде с @EndPointInject. Что-то вроде ниже: -

@EndpointInject 
protected ProducerTemplate myTemplate;