Camel Quarkus类未找到异常:HTTP操作失败异常错误

58wvjzkj  于 2022-11-07  发布在  Apache
关注(0)|答案(1)|浏览(152)

我有一个Quarkus应用程序,它使用Apache-Camel,并且在本地运行良好。当我构建它并尝试运行Docker容器时,我得到以下错误:

ERROR [io.qua.run.Application] (main) Failed to start application (with profile prod): java.lang.ClassNotFoundException: org.apache.camel.http.base.HttpOperationFailedException
at org.apache.camel.quarkus.core.CamelQuarkusClassResolver.resolveMandatoryClass(CamelQuarkusClassResolver.java:68)
at org.apache.camel.reifier.errorhandler.ErrorHandlerReifier.createExceptionClasses(ErrorHandlerReifier.java:197)
at org.apache.camel.reifier.errorhandler.ErrorHandlerReifier.addExceptionPolicy(ErrorHandlerReifier.java:177)
at org.apache.camel.reifier.errorhandler.ErrorHandlerReifier.configure(ErrorHandlerReifier.java:220)
at org.apache.camel.reifier.errorhandler.DefaultErrorHandlerReifier.createErrorHandler(DefaultErrorHandlerReifier.java:53)
at org.apache.camel.impl.DefaultModelReifierFactory.createErrorHandler(DefaultModelReifierFactory.java:65)
at org.apache.camel.reifier.errorhandler.ErrorHandlerRefReifier.createErrorHandler(ErrorHandlerRefReifier.java:36)
at org.apache.camel.impl.DefaultModelReifierFactory.createErrorHandler(DefaultModelReifierFactory.java:65)
at org.apache.camel.reifier.ProcessorReifier.wrapInErrorHandler(ProcessorReifier.java:751)
at org.apache.camel.reifier.ProcessorReifier.wrapChannelInErrorHandler(ProcessorReifier.java:732)
at org.apache.camel.reifier.ProcessorReifier.wrapChannel(ProcessorReifier.java:711)
at org.apache.camel.reifier.ProcessorReifier.wrapChannel(ProcessorReifier.java:617)
at org.apache.camel.reifier.ProcessorReifier.wrapProcessor(ProcessorReifier.java:613)
at org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:860)
at org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:585)
at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:236)
at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:74)
at org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:887)
at org.apache.camel.impl.DefaultModel.addRouteDefinitions(DefaultModel.java:190)
at org.apache.camel.impl.DefaultCamelContext.addRouteDefinitions(DefaultCamelContext.java:344)
at org.apache.camel.builder.RouteBuilder.populateRoutes(RouteBuilder.java:676)
at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:529)
at org.apache.camel.impl.engine.AbstractCamelContext.addRoutes(AbstractCamelContext.java:1175)
at io.quarkus.arc.impl.EventImpl$Notifier.notifyObservers(EventImpl.java:323)
at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:305)
at io.quarkus.arc.impl.EventImpl.fire(EventImpl.java:73)
at io.quarkus.arc.runtime.ArcRecorder.fireLifecycleEvent(ArcRecorder.java:130)
at io.quarkus.arc.runtime.ArcRecorder.handleLifecycleEvents(ArcRecorder.java:99)
at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent1144526294.deploy_0(Unknown Source)
at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent1144526294.deploy(Unknown Source)
at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
at io.quarkus.runtime.Application.start(Application.java:101)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:103)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:67)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:120)
at io.quarkus.runner.GeneratedMain.main(Unknown Source)

我的gradle依赖项是

dependencies {
implementation 'io.quarkus:quarkus-container-image-docker'
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
implementation enforcedPlatform("${quarkusPlatformGroupId}:quarkus-camel-bom:${quarkusPlatformVersion}")
implementation 'io.quarkus:quarkus-arc'
implementation 'io.quarkus:quarkus-config-yaml'

implementation 'io.quarkus:quarkus-smallrye-jwt'
implementation 'io.quarkus:quarkus-smallrye-health'
implementation 'io.quarkus:quarkus-smallrye-metrics'
implementation 'io.quarkus:quarkus-smallrye-openapi'
implementation 'io.quarkus:quarkus-smallrye-jwt-build'

implementation 'io.quarkus:quarkus-jackson'
implementation 'io.quarkus:quarkus-resteasy-jackson'
implementation 'io.quarkus:quarkus-resteasy'

implementation 'org.apache.camel.quarkus:camel-quarkus-file'
implementation 'org.apache.camel.quarkus:camel-quarkus-core'
implementation 'org.apache.camel.quarkus:camel-quarkus-base64'
implementation 'org.apache.camel.quarkus:camel-quarkus-ahc'
implementation 'org.apache.camel.quarkus:camel-quarkus-jackson'
implementation 'org.apache.camel.quarkus:camel-quarkus-ftp'
implementation 'org.apache.camel.quarkus:camel-quarkus-rest'
implementation 'org.apache.camel.quarkus:camel-quarkus-http'

implementation group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.3.1'

testImplementation 'io.quarkus:quarkus-junit5'
testImplementation 'io.rest-assured:rest-assured'

compileOnly 'org.projectlombok:lombok:1.18.16'

}
当我在IntelliJ终端中使用“quarkus dev”运行它时,我没有遇到任何问题。我是否尝试运行容器时,我得到了错误。为什么会发生这种错误?我不知道如何解决它。
编辑:
行程HttpException的位置:

onException(HttpOperationFailedException.class)
            .process(new HttpExceptionHandler())
            .maximumRedeliveries(5)
            .redeliveryDelay(1000L)
            .backOffMultiplier(2)
            .retryAttemptedLogLevel(LoggingLevel.WARN)
            .handled(true)
            .stop();

处理程序本身:

import org.apache.camel.Exchange;
import org.apache.camel.component.file.FileConstants;
import org.apache.camel.http.base.HttpOperationFailedException;
import org.jboss.logging.Logger;

public class HttpExceptionHandler implements org.apache.camel.Processor {

private static final Logger LOG = Logger.getLogger(HttpExceptionHandler.class);

@Override
public void process(Exchange exchange) {
    HttpOperationFailedException failedException = exchange.getProperty(
            Exchange.EXCEPTION_CAUGHT,
            HttpOperationFailedException.class);

    ...

}

}

ruyhziif

ruyhziif1#

当在路由中使用onException时,您定义的类需要注册为反射,以便它在本机模式下工作。
因此,如果您有.onException(HttpOperationFailedException.class),则需要注册HttpOperationFailedException以进行反射。例如:

@RegisterForReflection(targets = HttpOperationFailedException.class)
public class Routes extends RouteBuilder {
    public void configure() {
        // Route configuration goes here
    }
}

Camel Quarkus用户指南中提供了有关此问题的更多信息:
https://camel.apache.org/camel-quarkus/2.11.x/user-guide/native-mode.html#using-onexception-clause-in-native-mode
我打开了一个问题,以改善未来的事情,使HttpOperationFailedException不需要手动注册。
https://github.com/apache/camel-quarkus/issues/3971

相关问题