在我基于Spring的Camel maven项目中,为Jasper报告添加了以下依赖项,我在项目构建时遇到了问题。
Jasper Dependency:
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.0.4</version>
</dependency>
以下是异常的堆栈跟踪:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> RestBinding <<< in route: Route(route1)[[From[rest:post:/request:/addMultiple?inType=j... because of Error creating bean with name 'org.apache.camel.component.jackson.JacksonDataFormat': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.camel.component.jackson.JacksonDataFormat]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1556)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:123)
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:332)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:773)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> RestBinding <<< in route: Route(route1)[[From[rest:post:/request:/addMultiple?inType=j... because of Error creating bean with name 'org.apache.camel.component.jackson.JacksonDataFormat': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.camel.component.jackson.JacksonDataFormat]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1028)
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.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:255)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
... 19 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.camel.component.jackson.JacksonDataFormat': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.camel.component.jackson.JacksonDataFormat]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:278)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1133)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1036)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:505)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:342)
at org.apache.camel.spring.spi.SpringInjector.newInstance(SpringInjector.java:39)
at org.apache.camel.impl.DefaultDataFormatResolver.resolveDataFormat(DefaultDataFormatResolver.java:57)
at org.apache.camel.impl.DefaultCamelContext.resolveDataFormat(DefaultCamelContext.java:3561)
at org.apache.camel.model.rest.RestBindingDefinition.createProcessor(RestBindingDefinition.java:109)
at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:505)
at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:217)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1025)
... 32 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.camel.component.jackson.JacksonDataFormat]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:270)
... 44 more
Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:458)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:379)
at org.apache.camel.component.jackson.JacksonDataFormat.<init>(JacksonDataFormat.java:109)
at org.apache.camel.component.jackson.JacksonDataFormat.<init>(JacksonDataFormat.java:96)
at org.apache.camel.component.jackson.JacksonDataFormat.<init>(JacksonDataFormat.java:84)
at org.apache.camel.component.jackson.JacksonDataFormat.<init>(JacksonDataFormat.java:74)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
... 46 more
我认为jasper报告的支持jackson依赖项与之前的依赖项存在冲突。
以下是jasper报告的pom.xml的依赖关系层次结构。
但是,如果我删除了jasper报告的依赖关系,那么它工作正常。
我无法完全解决这个问题。
答案 0 :(得分:2)
您的问题出错了,更改了答案
您的方法所在的类是jackson.core 2.4.3的一部分。如果明确包含它,它应该可以解决您的问题。
添加以下依赖项:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.4.3</version>
</dependency>