调用Camel-jackson API时,在操作数堆栈上获取错误类型

时间:2017-01-13 15:07:09

标签: jackson apache-camel osgi jbossfuse blueprint-osgi

我的应用程序和服务器中有camel-jackson和jackson-databind jar,我使用的是jboss fuse。我能够部署没有错误的包,但是当我安装/更新调用camel-jackson api的包时,我得到了下面提到的错误。根据我的要求,我需要两个杰克逊api。

有人可以建议吗?

的pom.xml

<dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.8.5</version>
</dependency>

<dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jackson</artifactId>
            <version>2.15.1</version>
</dependency>

<dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.8.5</version>
        </dependency>
<dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.8.5</version>
        </dependency>

错误日志

    ERROR: Bundle test-project [114] EventDispatcher: Error during dispatch.     (java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    org/apache/camel/component/jackson/JacksonDataFormat.doStart()V @31: invokevirtual
  Reason:
    Type 'com/fasterxml/jackson/module/jaxb/JaxbAnnotationModule' (current frame, stack[1]) is not assignable to 'com/fasterxml/jackson/databind/Module'
Current Frame:
bci: @31
flags: { }
locals: { 'org/apache/camel/component/jackson/JacksonDataFormat', 'com/fasterxml/jackson/module/jaxb/JaxbAnnotationModule' }
stack: { 'com/fasterxml/jackson/databind/ObjectMapper', 'com/fasterxml/jackson/module/jaxb/JaxbAnnotationModule' }
Bytecode:
0x0000000: 2ab4 000b 9900 1fbb 0034 59b7 0035 4cb2

full_frame(@779,{Object[#250]},{})
)
java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    org/apache/camel/component/jackson/JacksonDataFormat.doStart()V @31: invokevirtual
  Reason:
    Type 'com/fasterxml/jackson/module/jaxb/JaxbAnnotationModule' (current frame, stack[1]) is not assignable to 'com/fasterxml/jackson/databind/Modul
e'
  Current Frame:
    bci: @31
    flags: { }
    locals: { 'org/apache/camel/component/jackson/JacksonDataFormat', 'com/fasterxml/jackson/module/jaxb/JaxbAnnotationModule' }
    stack: { 'com/fasterxml/jackson/databind/ObjectMapper', 'com/fasterxml/jackson/module/jaxb/JaxbAnnotationModule' }
  Bytecode:
    0x0000000: 2ab4 000b 9900 1fbb 0034 59b7 0035 4cb2
   ....

        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
        at java.lang.Class.getConstructor0(Class.java:3075)
        at java.lang.Class.newInstance(Class.java:412)
        at org.apache.camel.util.ObjectHelper.newInstance(ObjectHelper.java:1514)
        at org.apache.camel.util.ReflectionInjector.newInstance(ReflectionInjector.java:32)
        at org.apache.camel.impl.DefaultInjector.newInstance(DefaultInjector.java:45)
        at org.apache.camel.impl.osgi.Activator$BaseResolver.createInstance(Activator.java:438)
        at org.apache.camel.impl.osgi.Activator$BaseResolver.createInstance(Activator.java:408)
        at org.apache.camel.impl.osgi.Activator$BundleDataFormatResolver.resolveDataFormat(Activator.java:253)
        at org.apache.camel.core.osgi.OsgiDataFormatResolver.getDataFormat(OsgiDataFormatResolver.java:66)
        at org.apache.camel.core.osgi.OsgiDataFormatResolver.resolveDataFormat(OsgiDataFormatResolver.java:54)
        at org.apache.camel.blueprint.BlueprintDataFormatResolver.resolveDataFormat(BlueprintDataFormatResolver.java:46)
        at org.apache.camel.impl.DefaultCamelContext.resolveDataFormat(DefaultCamelContext.java:3561)
        at org.apache.camel.model.DataFormatDefinition.createDataFormat(DataFormatDefinition.java:118)
        at org.apache.camel.model.dataformat.JsonDataFormat.createDataFormat(JsonDataFormat.java:287)
        at org.apache.camel.model.DataFormatDefinition.getDataFormat(DataFormatDefinition.java:97)
        at org.apache.camel.model.DataFormatDefinition.getDataFormat(DataFormatDefinition.java:72)
        at org.apache.camel.model.UnmarshalDefinition.createProcessor(UnmarshalDefinition.java:175)
        at org.apache.camel.model.ProcessorDefinition.createProcessor(ProcessorDefinition.java:482)
        at org.apache.camel.model.ProcessorDefinition.createOutputsProcessorImpl(ProcessorDefinition.java:446)
        at org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:413)
        at org.apache.camel.model.TryDefinition.createProcessor(TryDefinition.java:70)
        at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:533)
        at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:494)
        at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:219)
        at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1025)
        at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:185)
        at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:841)
        at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:2895)
        at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2618)
        at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:167)
        at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2467)
        at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2463)
        at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486)
        at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2463)
        at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
        at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2432)
        at org.apache.camel.blueprint.BlueprintCamelContext.start(BlueprintCamelContext.java:180)
        at org.apache.camel.blueprint.BlueprintCamelContext.maybeStart(BlueprintCamelContext.java:212)
        at org.apache.camel.blueprint.BlueprintCamelContext.serviceChanged(BlueprintCamelContext.java:150)
        at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:943)
        at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:794)
        at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:544)
        at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4445)
        at org.apache.felix.framework.Felix.registerService(Felix.java:3431)
        at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346)
        at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:353)
        at org.apache.camel.blueprint.BlueprintCamelContext.init(BlueprintCamelContext.java:100)
        at sun.reflect.GeneratedMethodAccessor120.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:299)
        at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:956)
        at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)
        at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)
        at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)
        at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
        at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:247)
        at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:682)
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:377)
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:269)
        at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:294)
        at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:263)
        at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:253)
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)
        at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)
        at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1127)
        at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:696)
        at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:484)
        at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4429)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2100)
        at org.apache.felix.framework.Felix.updateBundle(Felix.java:2412)
        at org.apache.felix.framework.BundleImpl.update(BundleImpl.java:994)
        at org.apache.felix.framework.BundleImpl.update(BundleImpl.java:981)
        at org.apache.karaf.util.bundles.BundleUtils.update(BundleUtils.java:43)
        at org.apache.karaf.util.bundles.BundleUtils.update(BundleUtils.java:36)
        at org.apache.karaf.shell.osgi.UpdateBundle.doExecute(UpdateBundle.java:37)
        at org.apache.karaf.shell.osgi.BundleCommand.doExecute(BundleCommand.java:41)
        at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)
        at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:54)
        at org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:119)
        at org.apache.karaf.shell.console.commands.$BlueprintCommand1890029429.execute(Unknown Source)
        at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)
        at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
        at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:92)
        at org.apache.karaf.shell.console.jline.Console.run(Console.java:197)
        at org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$1.runConsole(ShellFactoryImpl.java:173)
        at org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$1$1.run(ShellFactoryImpl.java:125)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.apache.karaf.jaas.modules.JaasHelper.doAs(JaasHelper.java:47)
        at org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$1.run(ShellFactoryImpl.java:123)

1 个答案:

答案 0 :(得分:1)

对于你的问题不是最理想的答案,因为它没有解决camel-jackson的问题,但我只是通过将我的JsonLibrary切换到GSon(camel-gson)来解决这个完全相同的错误。

https://github.com/apache/camel/blob/master/components/camel-gson/src/main/docs/json-gson-dataformat.adoc

如果您对camel-jackson没有严格要求,这可能对您有所帮助。就像删除camel-jackson一样简单并替换为camel-gson:

的pom.xml:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-gson</artifactId>
</dependency>

路线建设者:

from("mock:json")
        .bean(genericProcessor())
        .marshal().json(JsonLibrary.Gson) //convert processor result to JSON