Search code examples
apache-camelkaraf

Karaf camel-dozer issues


We are running Karaf 4.1.5 with Camel 2.21.0

I have a very simple test route to do dozer mapping.

        from("timer:test?repeatCount=1")
            .bean(First.class)
            .to("dozer:test?targetModel=xyz.Second")
            .log("Done");

Building a bundle using maven-bundle-plugin (using this for a few other routes without issues) and deploying we get :

Caused by: java.lang.ClassNotFoundException: com.sun.el.ExpressionFactoryImpl not found by dozer [501]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639) ~[?:?]
at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80) ~[?:?]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:?]
at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1927) ~[?:?]
at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:978) ~[?:?]
at org.apache.camel.core.osgi.utils.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:47) ~[?:?]
at org.apache.camel.core.osgi.utils.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:69) ~[?:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:?]
at javax.el.FactoryFinder.newInstance(FactoryFinder.java:87) ~[?:?]
at javax.el.FactoryFinder.find(FactoryFinder.java:197) ~[?:?]
at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:197) ~[?:?]
at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:168) ~[?:?]
at org.dozer.loader.xml.ELEngine.<init>(ELEngine.java:44) ~[?:?]
at org.apache.camel.converter.dozer.MapperFactory.configureBeanContainer(MapperFactory.java:162) ~[?:?]
at org.apache.camel.converter.dozer.MapperFactory.parseConfiguration(MapperFactory.java:98) ~[?:?]
at org.apache.camel.converter.dozer.MapperFactory.create(MapperFactory.java:56) ~[?:?]
at org.apache.camel.component.dozer.DozerEndpoint.initDozerBeanContainerAndMapper(DozerEndpoint.java:151) ~[?:?]
at org.apache.camel.component.dozer.DozerEndpoint.doStart(DozerEndpoint.java:115) ~[?:?]

I tried adding required class to Import-Package: *;com.sun.el

Which then results in java.lang.ClassCastException: com.sun.el.ExpressionFactoryImpl cannot be cast to javax.el.ExpressionFactor:

Caused by: java.lang.ClassCastException: com.sun.el.ExpressionFactoryImpl cannot be cast to javax.el.ExpressionFactory
at org.apache.camel.converter.dozer.MapperFactory.configureBeanContainer(MapperFactory.java:154) ~[?:?]
at org.apache.camel.converter.dozer.MapperFactory.parseConfiguration(MapperFactory.java:98) ~[?:?]
at org.apache.camel.converter.dozer.MapperFactory.create(MapperFactory.java:56) ~[?:?]
at org.apache.camel.component.dozer.DozerEndpoint.initDozerBeanContainerAndMapper(DozerEndpoint.java:151) ~[?:?]
at org.apache.camel.component.dozer.DozerEndpoint.doStart(DozerEndpoint.java:115) ~[?:?]
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) ~[?:?]
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:75) ~[?:?]
at org.apache.camel.processor.SendProcessor.doStart(SendProcessor.java:241) ~[?:?]
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) ~[?:?]
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:75) ~[?:?]
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:60) ~[?:?]
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:104) ~[?:?]
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:90) ~[?:?]
at org.apache.camel.processor.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1472) ~[?:?]
at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:44) ~[?:?]
at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:31) ~[?:?]

Seems dozer tries to load com.sun.el.ExpressionFactoryImpl, but there is already a javax.el.ExpressionFactoryImpl around.

Can anyone give me some direction, why a vanilla Karaf 4.1.5, with camel 2.21.0 and camel-dozer would not work?


Solution

  • The solution is to upgrade to camel 2.22.0. Karaf 4.1.5 plus camel 2.22.0 with camel-dozer works, if you include com.sun.el in the "Import-Package" of the maven-bundle-plugin

    <Import-Package>*;com.sun.el</Import-Package>