我有一个在JBoss Eap 7.4上运行的Apache Camel 3.17独立模式的应用程序,我试图通过Undertow组件声明一个初始路由,但它开始和停止时出现错误“地址已在使用中”。我不明白问题是什么,我留下了我的问题的代码和日志。非常感谢。
@Override
public void contextInitialized(ServletContextEvent sce) {
try {
DefaultCamelContext camelContext = new DefaultCamelContext();
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("undertow:http://localhost:8080/mecSc/request")
.to("direct:procesarDatos");
from("direct:procesarDatos")
.log("Recibiendo datos: ${body}")
.to("log:output");
}
});
camelContext.start();
} catch (Exception e) {
// Manejar excepciones según sea necesario
}
字符串
}
日志显示:
2023-11-14 23:45:03,278 INFO undertow.DefaultUndertowHost: Starting Undertow
server on http://localhost:8080
2023-11-14 23:45:03,278 INFO io.undertow: starting server: Undertow - 2.2.5.Final-redhat-00001
2023-11-14 23:45:03,284 WARN undertow.DefaultUndertowHost: Failed to start Undertow server on http://localhost:8080, reason: java.net.BindException: Address already in use
2023-11-14 23:45:03,285 INFO io.undertow: stopping server: Undertow - 2.2.5.Final-redhat-00001
2023-11-14 23:45:03,291 ERROR engine.AbstractCamelContext: Error starting CamelContext (camel-1) due to exception thrown: java.net.BindException: Address already in use: java.lang.RuntimeException: java.net.BindException: Address already in use
at [email protected]//io.undertow.Undertow.start(Undertow.java:254)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.component.undertow.DefaultUndertowHost.registerHandler(DefaultUndertowHost.java:110)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.component.undertow.UndertowComponent.registerEndpoint(UndertowComponent.java:381)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.component.undertow.UndertowConsumer.doStart(UndertowConsumer.java:129)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.support.service.BaseService.start(BaseService.java:119)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.impl.engine.AbstractCamelContext.startService(AbstractCamelContext.java:3660)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.impl.engine.InternalRouteStartupManager.doStartOrResumeRouteConsumers(InternalRouteStartupManager.java:401)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.impl.engine.InternalRouteStartupManager.doStartRouteConsumers(InternalRouteStartupManager.java:319)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.impl.engine.InternalRouteStartupManager.safelyStartRouteServices(InternalRouteStartupManager.java:213)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.impl.engine.InternalRouteStartupManager.doStartOrResumeRoutes(InternalRouteStartupManager.java:147)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.impl.engine.AbstractCamelContext.doStartCamel(AbstractCamelContext.java:3362)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.impl.engine.AbstractCamelContext.doStartContext(AbstractCamelContext.java:3032)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.impl.engine.AbstractCamelContext.doStart(AbstractCamelContext.java:2987)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.support.service.BaseService.start(BaseService.java:119)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2648)
at deployment.mecSc-camel-1.0.0.war//org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:262)
at deployment.mecSc-camel-1.0.0.war//sube.apps.mec.sc.camel.CamelServletContextListener.contextInitialized(CamelServletContextListener.java:30)
at [email protected]//io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)
at [email protected]//io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:219)
at [email protected]//io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:187)
at [email protected]//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at [email protected]//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at [email protected]//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
at [email protected]//io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:255)
at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:96)
at [email protected]//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at [email protected]//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at [email protected]//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:829)
at [email protected]//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: java.net.BindException: Address already in use
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:459)
at java.base/sun.nio.ch.Net.bind(Net.java:448)
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
at [email protected]//org.xnio.nio.NioXnioWorker.createTcpConnectionServer(NioXnioWorker.java:178)
at [email protected]//org.xnio.XnioWorker.createStreamConnectionServer(XnioWorker.java:310)
at [email protected]//io.undertow.Undertow.start(Undertow.java:196)
... 39 more
型
1条答案
按热度按时间lpwwtiir1#
问题是端口
8080
可能已经分配给EAP内部Undertow服务器。因此,如果您尝试使用同一端口配置Camel路由,则会发生端口冲突。默认情况下,
camel-undertow
和EAP Undertow HTTP服务器没有集成。因此,您需要更改EAP HTTP服务器使用的端口,或者更改camel-undertow
使用者端点URI上的端口。另外,还有由Red Hat EAP提供的Camel EAP子系统,它提供了
camel-undertow
和EAP Undertow服务器之间的集成。https://access.redhat.com/documentation/en-us/red_hat_fuse/7.12/html/installing_on_jboss_eap/index