gpt4 book ai didi

apache-camel - 由 DefaultCamelContext.start() 引起的 StackOverflowException,似乎是由 Camel 进入无限循环引起的

转载 作者:行者123 更新时间:2023-12-04 04:23:49 27 4
gpt4 key购买 nike

我已经搜索过这个并且还没有找到关于这个的问题。我正在创建一个 Camel 路线,它监视一个 shapefiles (.shp) 的文件夹。下面的代码是实现 Camel 路线的代码。

final String filePath = settings.getSetting(GMTI_VOCAB.SHAPEFILE_PATH);
logger.debug("filePath={}", filePath);
final File file = new File(filePath);
if (file.mkdir())
{
logger.warn("Shapefile path did not exist. Creating directory.");
}

logger.debug("Creating file route.");
context.addRoutes(new RouteBuilder()
{

@Override
public void configure() throws Exception
{
String path = String.format("file://%s?noop=true&include=.*shp$", file.getAbsolutePath());
logger.debug("Route is: {}", path);
from(path).bean(this, "process(${file:path})");
}
});
logger.debug("Starting context");
context.start();
logger.info("Communicator started!");

目前返回的文件路径只是“shapefile”,导致 file.getAbsolutePath() 返回“C:\Users\medderssc\gmti_intestor\shapefiles”。返回的结果路径是
from("file://C:\Users\medderssc\gmti_intestor\shapefiles?noop=true&include=.*shp$").bean(this, "process(${file:path})");

context 是一个 DefaultCamelContext 并且 Camel 是通过 maven 导入的,在 POM 中有以下条目:
    <dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.10.0</version>
</dependency>

“Communicator started”永远不会输出,程序在此之前崩溃,告诉我在 context.start() 期间发生错误。下面的堆栈跟踪显示了 StackOverflowException。请注意堆栈本身重复了几次,这意味着 Camel 本身以某种方式进入了某种无限递归循环。除了发布的代码中的内容之外,没有其他 Camel 配置。任何人都可以帮忙吗?异常堆栈如下:

Oct 1, 2012 9:33:50 AM com.saic.ogc.client.BaseClient createMessageFactory INFO: Defaulting to built-in message factory... Oct 1, 2012 9:33:50 AM com.saic.ogc.client.BaseClient initTemplate INFO: Setting interceptor! Exception in thread "main" java.lang.StackOverflowError

at org.apache.camel.model.RouteDefinition.toString(RouteDefinition.java:119)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at java.util.AbstractCollection.toString(Unknown Source)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at org.apache.camel.model.RoutesDefinition.toString(RoutesDefinition.java:60)
at org.apache.camel.builder.RouteBuilder.toString(RouteBuilder.java:58)
at org.apache.camel.model.BeanDefinition.description(BeanDefinition.java:81)
at org.apache.camel.model.BeanDefinition.toString(BeanDefinition.java:70)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at java.util.AbstractCollection.toString(Unknown Source)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at org.apache.camel.model.RouteDefinition.toString(RouteDefinition.java:119)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at java.util.AbstractCollection.toString(Unknown Source)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at org.apache.camel.model.RoutesDefinition.toString(RoutesDefinition.java:60)
at org.apache.camel.builder.RouteBuilder.toString(RouteBuilder.java:58)
at org.apache.camel.model.BeanDefinition.description(BeanDefinition.java:81)
at org.apache.camel.model.BeanDefinition.toString(BeanDefinition.java:70)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at java.util.AbstractCollection.toString(Unknown Source)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at org.apache.camel.model.RouteDefinition.toString(RouteDefinition.java:119)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at java.util.AbstractCollection.toString(Unknown Source)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at org.apache.camel.model.RoutesDefinition.toString(RoutesDefinition.java:60)
at org.apache.camel.builder.RouteBuilder.toString(RouteBuilder.java:58)
at org.apache.camel.model.BeanDefinition.description(BeanDefinition.java:81)
at org.apache.camel.model.BeanDefinition.toString(BeanDefinition.java:70)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at java.util.AbstractCollection.toString(Unknown Source)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at org.apache.camel.model.RouteDefinition.toString(RouteDefinition.java:119)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at java.util.AbstractCollection.toString(Unknown Source)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at org.apache.camel.model.RoutesDefinition.toString(RoutesDefinition.java:60)
at org.apache.camel.builder.RouteBuilder.toString(RouteBuilder.java:58)
at org.apache.camel.model.BeanDefinition.description(BeanDefinition.java:81)
at org.apache.camel.model.BeanDefinition.toString(BeanDefinition.java:70)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at java.util.AbstractCollection.toString(Unknown Source)
at java.lang.String.valueOf(Unknown Source)

最佳答案

乍一看,问题似乎是您的 .bean(this,...)指的是匿名类( new RouteBuilder() )并将尝试运行 configure() (因此递归/sfo)...尝试为您的 bean/process() 方法使用单独的类...

关于apache-camel - 由 DefaultCamelContext.start() 引起的 StackOverflowException,似乎是由 Camel 进入无限循环引起的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12678040/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com