Ошибка AOP и ClasCastException в osgi: служба в сервисном миксе - PullRequest
0 голосов
/ 08 апреля 2019

Я использую Servicemix 6.1 с собственными пакетами.Почти каждый пакет имеет свои собственные osgi: сервис как

Bundle-1 имеет

<bean id="Service1" class="..."/>

<osgi:service ref="Service1" ranking="3">
    <osgi:interfaces>
        <value>com.test1.Service</value>
    </osgi:interfaces>
</osgi:service>

Bundle-2 имеет

<bean id="Service2" class="..."/>

<osgi:service ref="Service2" ranking="3">
    <osgi:interfaces>
        <value>com.test2.Service</value>
    </osgi:interfaces>
</osgi:service>

Bundle-3 имеет Service1..3

<bean id="Service3" class="..."/>

<osgi:service ref="Service3" ranking="3">
    <osgi:interfaces>
        <value>com.test3.Service</value>
    </osgi:interfaces>
</osgi:service>

Кроме того, некоторые из этих пакетов должны импортировать такие службы, как

Bundle-3, имеющие

<bean id="budnle3SomeClass" class="...">
<property name="firstService" ref="Service1">
<property name="secondService" ref="Service2">
</bean>

<osgi:reference id="Service1"
                    interface="com.test1.Service" timeout="5000"
                    cardinality="0..1"/>

<osgi:reference id="Service2"
                    interface="com.test2.Service" timeout="5000"
                    cardinality="0..1"/>

Все работает хорошо, пока я начинаю тестировать новую функциюв ... например, Bundle-1.

Итак, когда я удаляю из servicemix Bundle-1, мой Bundle-3 пытается найти потерянный Service1.Но когда я добавляю его обратно с некоторыми функциями, servicemix видит, что был добавлен новый пакет, и после этого он регистрирует ошибки, такие как org.springframework.aop.AopInvocationException: Конфигурация AOP кажется недопустимой: попытался вызвать метод или ClassCastException.И строка, где возникает эта ошибка, где я использую этот сервис, как

class budnle3SomeClass{
Service1 firstService;
Service2 secondService;

public void methodWithError(){
firstService.doSmthMethod();// that line works well all time, but after re-add Bundl1 I can't make even firstService.getClass(); I got AOP error
}

public void setFirstService(Service1 firstService){
this.firstService=firstService;
}

public void setSecondService(Service2 secondService){
this.secondService=secondService;
}

Но, когда я делаю Обновить импорт-экспорт всех пакетов, ошибки исчезают, и мой Bundle-3 начинает использовать Service1из Bundle-1.

Требуется изменить иногда самую новую версию, а иногда и ошибки.Я не знаю, как решить это на уровне XML.Может быть, кто-то знает это.

PS

Добавлен мой StackTrace как фрагмент

org.springframework.aop.AopInvocationException: AOP configuration seems to be invalid: tried calling method [public abstract java.util.List com.test1.Service1.methodWithError(int)] on target [com.test1.impl.Service1Impl@3ed3ee58]; nested exception is java.lang.IllegalArgumentException: java.lang.ClassCastException@3ff5ec9
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:325)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:132)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:120)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
	at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)[109:org.springframework.osgi.core:1.2.1]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:132)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:120)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at com.sun.proxy.$Proxy535.doSmthMethod(Unknown Source)
	at com.test3.budnle3SomeClass.methodWithError(budnle3SomeClass.java:188)[436:com.test3.MyBundle3]
	at com.test3.impl.UpperService3.methodWithError(UpperService3.java:1789)[436:com.test3.MyBundle3]
	at sun.reflect.GeneratedMethodAccessor202.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_202]
	at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_202]
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:132)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:120)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
	at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)[109:org.springframework.osgi.core:1.2.1]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:132)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:120)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	at com.sun.proxy.$Proxy568.doSmthMethod(Unknown Source)  
	at sun.reflect.GeneratedMethodAccessor200.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_202]
	at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_202]
	at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:408)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:279)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:252)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:177)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:68)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.component.bean.BeanProducer.process(BeanProducer.java:38)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:163)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.processor.loadbalancer.QueueLoadBalancer.process(QueueLoadBalancer.java:44)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.processor.loadbalancer.LoadBalancerSupport.process(LoadBalancerSupport.java:97)[151:org.apache.camel.camel-core:2.16.5]
	at org.apache.camel.component.quartz2.CamelJob.execute(CamelJob.java:60)[438:org.apache.camel.camel-quartz2:2.16.1]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202)[443:org.quartz-scheduler.quartz:2.2.1]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)[443:org.quartz-scheduler.quartz:2.2.1]
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@3ff5ec9
	at sun.reflect.GeneratedMethodAccessor165.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_202]
	at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_202]
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)[403:org.apache.servicemix.bundles.spring-aop:3.2.18.RELEASE_1]
	... 60 more

PSS И эта проблема актуальна, когда я останавливаюсь, удаляю в servicemix и затем удаляю связку из FileSystem.Когда я только удаляю из FileSystem, а затем добавляю новый пакет, нет проблем, как я вижу

...