Hello List!
My environment is ServiceMix 4.2.0-fuse-02-00 and Camel 2.2.0-fuse-02-00.
I'm not sure whether this problem is related to ServiceMix or Camel.
In our integration solution, we developed our own Tracer, whcih extends
org.apache.camel.processor.interceptor.Tracer. We have to do this, because
we have the requirement to trace some more information as the default Tracer
in Camel trace. Our Tracer collect all the needed data and write the new
trace exchange into a queue. This tracer instance is exported as an OSGI
service, so that all other services can use this service and we don't have
to configure the tracer in each service again. It looks like following
tracer bundle:
{code}
<bean id="tracer"
class="com.xxx.yyy.services.common.tracer.processor.interceptor.Tracer">
<property name="enabled" value="${tracer.enabled}" />
<property name="logLevel" value="${tracer.logLevel}" />
<property name="destinationUri"
value="${toTracerEndpoint}${toTracerEndpoint.options}" />
<property name="traceOutExchanges" value="true" />
<property name="traceExceptions" value="true" />
<property name="traceInterceptorFactory"
ref="traceInterceptorFactory" />
</bean>
<bean id="traceInterceptorFactory"
class="com.xxx.yyy.services.common.tracer.processor.interceptor.WlsiTraceInterceptorFactory">
<property name="traceFilter" ref="filterPredicate" />
</bean>
<bean id="filterPredicate"
class="com.xxx.yyy.services.common.tracer.processor.interceptor.ToNodePredicate">
<property name="excludePatterns" ref="excludePatterns" />
</bean>
<util:list id="excludePatterns">
<value>^marshal\[.*\]$</value>
<value>^unmarshal\[.*\]$</value>
<value>^direct:.*$</value>
<value>^removeHeader\[.*\]$</value>
<value>^setHeader\[.*\]$</value>
<value>^choice$</value>
<value>^split$</value>
</util:list>
<osgi:service ref="tracer" auto-export="class-hierarchy" />
{code}
In each other service, we import this OSGI service and Camel detect and use
our central tracer instance:
bundle n:
{code}
<osgi:reference id="tracer"
interface="org.apache.camel.processor.interceptor.Tracer" />
{code}
But in one of our services, we get the following exception after starting
the bundle:
{code}
karaf@root> listException in thread "SpringOsgiExtenderThread-21"
org.springframework.beans.factory.BeanCreationException: Er
ror creating bean with name 'tracer': FactoryBean threw exception on object
creation; nested exception is org.springframework
.aop.framework.AopConfigException: Could not generate CGLIB subclass of
class [class org.apache.camel.processor.interceptor.T
racer]: Common causes of this problem include using a final class or a
non-visible class; nested exception is java.lang.Illeg
alArgumentException: class
org.apache.camel.processor.interceptor.Tracer$$EnhancerByCGLIB$$3c5de9de is
not an enhanced class
at
org.springframework.beans.factory.support.FactoryBeanRegistrySupport$1.run(FactoryBeanRegistrySupport.java:127)
at java.security.AccessController.doPrivileged(Native Method)
at
org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistr
ySupport.java:116)
at
org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistryS
upport.java:91)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:12
88)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:217)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanF
actory.java:425)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplication
Context.java:728)
at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegate
dExecutionApplicationContext.java:69)
at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecu
tionApplicationContext.java:355)
at
org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDele
gatedExecutionApplicationContext.java:320)
at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$Complet
eRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.springframework.aop.framework.AopConfigException: Could not
generate CGLIB subclass of class [class org.apache
.camel.processor.interceptor.Tracer]: Common causes of this problem include
using a final class or a non-visible class; neste
d exception is java.lang.IllegalArgumentException: class
org.apache.camel.processor.interceptor.Tracer$$EnhancerByCGLIB$$3c5d
e9de is not an enhanced class
at
org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:213)
at
org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
at
org.springframework.osgi.service.util.internal.aop.ProxyUtils$1.run(ProxyUtils.java:65)
at java.security.AccessController.doPrivileged(Native Method)
at
org.springframework.osgi.service.util.internal.aop.ProxyUtils.createProxy(ProxyUtils.java:62)
at
org.springframework.osgi.service.util.internal.aop.ProxyUtils.createProxy(ProxyUtils.java:39)
at
org.springframework.osgi.service.importer.support.AbstractServiceProxyCreator.createServiceProxy(AbstractServicePr
oxyCreator.java:107)
at
org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean.createProxy(OsgiServiceProxyFactoryB
ean.java:206)
at
org.springframework.osgi.service.importer.support.AbstractServiceImporterProxyFactoryBean.getObject(AbstractServic
eImporterProxyFactoryBean.java:86)
at
org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean.getObject(OsgiServiceProxyFactoryBea
n.java:161)
at
org.springframework.beans.factory.support.FactoryBeanRegistrySupport$1.run(FactoryBeanRegistrySupport.java:121)
... 15 more
Caused by: java.lang.IllegalArgumentException: class
org.apache.camel.processor.interceptor.Tracer$$EnhancerByCGLIB$$3c5de9de
is not an enhanced class
at net.sf.cglib.proxy.Enhancer.setCallbacksHelper(Enhancer.java:618)
at net.sf.cglib.proxy.Enhancer.setThreadCallbacks(Enhancer.java:609)
at
net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:631)
at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:538)
at
net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:225)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
at
org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:201)
... 25 more
{code}
I think the problem is, that Camel/ServiceMix tries to proxy the tracer
instance again. But I couldn't figure out why...
My route looks as following:
{code}
public void configure() {
JaxbDataFormat jaxb = new
JaxbDataFormat(Issuer.class.getPackage().getName());
errorHandler(
deadLetterChannel(toErrorEndpoint)
.retryAttemptedLogLevel(LoggingLevel.DEBUG)
.retriesExhaustedLogLevel(LoggingLevel.INFO));
onException(SAXParseException.class, ValidationException.class,
IllegalArgumentException.class)
.handled(true)
.maximumRedeliveries(0);
onException(Exception.class)
.handled(true)
.maximumRedeliveries(redeliveryCount)
.redeliverDelay(redeliveryDelay)
.backOffMultiplier(redeliveryBackOffMultiplier);
from(fromEndpoint).routeId(PreProcessingRoute.class.getName())
.split(body(String.class).tokenize(lineTokenizer)).streaming()
.processRef("regExpValidationProcessor")
.transacted("required")
.beanRef("idempotentKeyEnricher", "addIdempotentKey")
.idempotentConsumer(
header(Constants.HEADER_IDEMPOTENT_KEY),
idempotentRepository)
.convertBodyTo(Issuer.class)
.marshal(jaxb)
.convertBodyTo(String.class)
.to(toEndpoint); // activeMQ queue
}
{code}
Thanks for every help, hint or suggestion,
Christian