[英]java.lang.ClassCastException: org.apache.camel.builder.ValueBuilder cannot be cast to java.lang.String
I am getting crazy because I am not able to track down why I have this exception in my camel route: 我发疯了,因为我无法追踪为什么我的骆驼路线中有这个例外:
java.lang.ClassCastException: org.apache.camel.builder.ValueBuilder
cannot be cast to java.lang.String
Can you please give me an hint of what does it mean? 您能给我提示一下这是什么意思吗? I have no explicit casts in my code.
我的代码中没有明确的强制转换。
After seeing your (correct) annotations I add: 在看到您的(正确)注释后,我添加:
Can you suggest me a better way to debug exceptions with eclipse debugger? 您能建议我用Eclipse调试器调试异常的更好方法吗?
I can finally add the exception WITH stacktrace: 我终于可以使用stacktrace添加异常:
java.lang.ClassCastException
org.apache.camel.builder.ValueBuilder cannot be cast to java.lang.String
at org.apache.camel.component.cache.CacheProducer.process(CacheProducer.java:61)
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge. process(AsyncProcessorConverterHelper.java:61)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:122)
at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:298)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:117)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor. processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.management.InstrumentationProcessor. process(InstrumentationProcessor.java:72)
Thanks, Mario 谢谢,马里奥
From the API Specifications for the ClassCastException
: 从
ClassCastException
的API规范中:
Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance.
抛出该异常以指示代码已尝试将对象强制转换为不是实例的子类。
So, for example, when you try to assign a org.apache.camel.builder.ValueBuilder
to a java.lang.String
, the operation fails to be accomplished because java.lang.String
is not an subclass of org.apache.camel.builder.ValueBuilder
, and therefore a ClassCastException
is thrown. 因此,例如,当您尝试将
org.apache.camel.builder.ValueBuilder
分配给java.lang.String
,操作将无法完成,因为java.lang.String
不是org.apache.camel.builder.ValueBuilder
的子类。 org.apache.camel.builder.ValueBuilder
,因此ClassCastException
。
I have found the problem! 我发现了问题!
This is the previous code (that worked), taken from official camel tutorial: 这是先前的代码(有效),摘自官方骆驼教程:
in.setHeader(CacheConstants.CACHE_OPERATION, constant(CacheConstants.CACHE_OPERATION_ADD));
This is the correct code that produces no exception: 这是不产生异常的正确代码:
in.setHeader(CacheConstants.CACHE_OPERATION, CacheConstants.CACHE_OPERATION_ADD);
constant() changes a String in a ValueBuilder causing the exception. constant()更改导致异常的ValueBuilder中的String。
I suppose this is a bug because the behaviour of camel cache component has changed. 我认为这是一个错误,因为骆驼缓存组件的行为已更改。
Mario 马里奥
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.