卡拉夫骆驼推土机问题

Karaf camel-dozer issues

我们是 运行 Karaf 4.1.5 和 Camel 2.21.0

我有一个非常简单的测试路线来做推土机映射。

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

使用 maven-bundle-plugin 构建一个包(将它用于其他一些没有问题的路由)并部署我们得到:

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.access0(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) ~[?:?]

我尝试将必需的 class 添加到 Import-Package: *;com.sun.el

然后导致 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) ~[?:?]

似乎推土机试图加载 com.sun.el.ExpressionFactoryImpl,但周围已经有一个 javax.el.ExpressionFactoryImpl。

谁能给我一些指导,为什么香草 Karaf 4.1.5、camel 2.21.0 和 camel-dozer 不起作用?

解决方法是升级到camel 2.22.0。 如果您在 maven-bundle-plugin

的 "Import-Package" 中包含 com.sun.el,则 Karaf 4.1.5 加上带有 camel-dozer 的 camel 2.22.0
<Import-Package>*;com.sun.el</Import-Package>