cesarjv opened a new issue, #5986: URL: https://github.com/apache/camel-quarkus/issues/5986
Good afternoon, I am currently working with Apache Camel in Quarkus and I am having problems applying the DSL java onException command in the RestRoute class, the problem lies when I am going to apply the native compilation and because I have some custom exception classes that use the onException line, I have the custom exceptions with the annotation @RegisterForReflection, the problem is that I am using the exception org.apache.http.conn.HttpHostConnectException and with this I do not know how to apply the annotation @RegisterForReflection: Class ResRoute ``` package org.tmve.customer.ms.route; import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.model.rest.RestBindingMode; import org.apache.http.NoHttpResponseException; import org.apache.http.conn.HttpHostConnectException; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.tmve.customer.ms.beans.response.UserProfile; import org.tmve.customer.ms.exceptions.NotFoundDataException; import org.tmve.customer.ms.exceptions.EmptyDataExceptionQueryParam; import org.tmve.customer.ms.exceptions.RequiredValueException; import org.tmve.customer.ms.processor.*; import org.tmve.customer.ms.utilities.BeanDate; import javax.enterprise.context.ApplicationScoped; import java.net.UnknownHostException; import static org.apache.camel.model.rest.RestParamType.body; @ApplicationScoped public class ResRoute extends RouteBuilder { @ConfigProperty(name="client.findCustomerByDocId") String findCustomerByDocId; @ConfigProperty(name="client.findCustomerAccountListByDocId") String findCustomerAccountsListByDocId; @ConfigProperty(name="client.findPostpaidAccountInfo") String findPostpaidAccountInfo; @ConfigProperty(name="client.findCustomerDocumentBySubscriberId") String findCustomerDocumentBySubscriberId; @ConfigProperty(name="client.findFeatureByAccount") String findFeatureByAccount; @ConfigProperty(name = "path.openapi") String openApiPath; @ConfigProperty(name = "descripcion.servicio") String serviceDescription; private ConfigureSsl configureSsl; private static final String SALIDA_BSS_EXCEPTION = "Salida del microservicio BSS UserProfile ${exchangeProperty[bodyRs]}"; private static final String USER_PROFILE = "UserProfile"; private static final String MSG_EXCEPTION = "Descripcion de la Exception: ${exception.message}"; private static final String DATE_LOG = "[${bean:BeanDate.getCurrentDateTime()}] "; private static final String DIRECT_PIPELINE = "direct:pipeline"; public ResRoute() { configureSsl = new ConfigureSsl(); } @Override public void configure() throws Exception { BeanDate beanDate= new BeanDate(); getContext().getRegistry().bind("BeanDate",beanDate); restConfiguration() .bindingMode(RestBindingMode.json) .dataFormatProperty("json.in.disableFeatures", "FAIL_ON_UNKNOWN_PROPERTIES") .apiContextPath(openApiPath) .apiProperty("api.title", USER_PROFILE) .apiProperty("api.description", serviceDescription) .apiProperty("api.version", "1.0.0") .apiProperty("cors", "true"); rest("userProfile/v3/") .get("/users/{user_id}").to("direct:/{user_id}") .outType(UserProfile.class) .param().name(USER_PROFILE).type(body).description("parametro de salida").required(true) .endParam() .to("direct:userIdParam"); rest("/userProfile/v3/") .get("/users?").to("direct:/users?") .outType(UserProfile.class) .param().name(USER_PROFILE).type(body).description("parametro de salida").required(true).endParam() .to("direct:usersQueryParam"); onException(RequiredValueException.class) .handled(true) .process(new UserProfileProcessorInvalidFormatException()) .log(DATE_LOG+MSG_EXCEPTION) .log(DATE_LOG+SALIDA_BSS_EXCEPTION); onException(Exception.class) .handled(true) .process(new UserProfileProcessorException()) .log(DATE_LOG+MSG_EXCEPTION) .log(DATE_LOG+SALIDA_BSS_EXCEPTION); onException(NotFoundDataException.class) .handled(true) .process(new UserProfileProcessorInformationSubscriber()) .log(DATE_LOG+MSG_EXCEPTION) .log(DATE_LOG+SALIDA_BSS_EXCEPTION); onException(HttpHostConnectException.class) .handled(true) .process(new UserProfileProcessHttpHostConectionException()) .log(DATE_LOG+MSG_EXCEPTION) .log(DATE_LOG+SALIDA_BSS_EXCEPTION); from("direct:userIdParam") .doTry() .process(new UserProfileProcessorUserIdParamReq()) .log(DATE_LOG+"User ID: ${exchangeProperty[userId]}") .log(DATE_LOG+"UserId Encrypt: ${exchangeProperty[userIdEncrypt]}") .log(DATE_LOG+"Correlator ID: ${exchangeProperty[correlatorId]}") .endDoTry() .to(DIRECT_PIPELINE); from("direct:usersQueryParam") /*.removeHeaders("CamelHttp*") */ .doTry() .process(new UserProfileProcessorQueryParamReq()) .choice() .when(simple("${exchangeProperty[isSearchByQueryParamIdDocumentValueAndIdDocumentType]} == 'true'")) .to(DIRECT_PIPELINE) .otherwise() .log(DATE_LOG+"Identity: ${exchangeProperty[identityQueryParam]}") .log(DATE_LOG+"IdentityType: ${exchangeProperty[identityTypeQueryParam]}") .process(new FindCustomerDocumentBySubscriberIdReq()) .log(DATE_LOG+"Entrada Microservicio FindCustomerDocumentBySubscriberId: ${exchangeProperty[findCustomerDocumentBySubscriberIdRequest]}") .to(configureSsl.setupSSLContext(getCamelContext(), findCustomerDocumentBySubscriberId)) .process(new FindCustomerDocumentBySubscriberIdRes()) .log(DATE_LOG+"Salida FindCustomerDocumentBySubscriberId: ${exchangeProperty[findCustomerDocumentBySubscriberIdResponseStatus]}") .log(DATE_LOG+"User ID Mediante QueryParam: ${exchangeProperty[userId]}") .to(DIRECT_PIPELINE) .endDoTry() /*.to(DIRECT_PIPELINE) */ .doCatch(EmptyDataExceptionQueryParam.class) .process(new UserProfileEmptyDataSubscriberQueryParam()) .log(DATE_LOG+MSG_EXCEPTION) .log(DATE_LOG+SALIDA_BSS_EXCEPTION); from(DIRECT_PIPELINE) .doTry() .log(DATE_LOG+"UserId: ${exchangeProperty[userId]}") .process(new FindCustomerByDocIdProcessorReq()) .to(configureSsl.setupSSLContext(getCamelContext(), findCustomerByDocId)) .choice() .when(header(Exchange.HTTP_RESPONSE_CODE).isEqualTo(200)) .process(new FindCustomerByDocIdProcessorRes()) .log(DATE_LOG+"Mensaje Ejecucion MS FindCustomerByDocId: ${exchangeProperty[findCustomerByDocIdResponseMessage]}") .when(header(Exchange.HTTP_RESPONSE_CODE).isEqualTo(404)) .process(new FindCustomerByDocIdProcessorResHttp404()) .log(DATE_LOG+"Mensaje Ejecucion MS FindCustomerByDocId: ${exchangeProperty[findCustomerByDocIdResponseMessage]}") .otherwise() .log("Error al consultar Microservicio FindCustomerByDocId con codigo de respuesta: ${header.CamelHttpResponseCode}") .process(new UserProfileFaultProcessRes()) .end() .log(DATE_LOG+"Document userId: ${exchangeProperty[userDocument]}") .log(DATE_LOG+"Name userId: ${exchangeProperty[userName]}") .process(new FindCustomerAccountListByDocIdReq()) .to(configureSsl.setupSSLContext(getCamelContext(), findCustomerAccountsListByDocId)) .choice() .when(header(Exchange.HTTP_RESPONSE_CODE).isEqualTo(200)) .process(new FindCustomerAccountsListByDocIdRes()) .log(DATE_LOG+"Mensaje Ejecucion MS FindCustomerAccountListByDocId: ${exchangeProperty[findCustomerAccountListByDocIdResponseMessage]}") .log(DATE_LOG+"Total Cuentas Prepago: ${exchangeProperty[prepaidAccountCount]}") .log(DATE_LOG+"Total Cuentas Pospago: ${exchangeProperty[postpaidAccountCount]}") .log(DATE_LOG+"Cuentas Prepago: ${exchangeProperty[prepaidAccounts]}") .log(DATE_LOG+"Cuentas Pospago: ${exchangeProperty[postpaidAccounts]}") .otherwise() .log("Error al consultar Microservicio FindCustomerAccountsListByDocId con codigo de respuesta: ${header.CamelHttpResponseCode}") .process(new UserProfileFaultProcessRes()) .end() .loop(simple("${exchangeProperty[postpaidAccountCount]}")) .process(new FindPostpaidAccountInfoProcessReq()) .to(configureSsl.setupSSLContext(getCamelContext(), findPostpaidAccountInfo)) .process(new FindPostpaidAccountInfoProcessRes()) .end() .log(DATE_LOG+"Busqueda SVA para Cuentas Pospago Exitosa....") .loop(simple("${exchangeProperty[prepaidAccountCount]}")) .process(new FindFeaturesByAccountProcessorReq()) .to(configureSsl.setupSSLContext(getCamelContext(), findFeatureByAccount)) .process(new FindFeatureByAccountProcessorRes()) .end() .log(DATE_LOG+"Busqueda SVA para Cuentas Prepago Exitosa....") .choice() .when(simple("${exchangeProperty[isSearchByQueryParam]} == 'true'")) .process(new UserProfileProcessorQueryParamRes()) .log(DATE_LOG+"Salida MS UserProfile: ${exchangeProperty[userProfileResponse]}") .otherwise() .process(new UserProfileProcessorUserIdRes()) .log(DATE_LOG+"Salida MS UserProfile: ${exchangeProperty[userProfileResponse]}") .endDoTry() .doCatch(UnknownHostException.class) .process(new UserProfileProcessHttpHostConectionException()) .log(DATE_LOG+MSG_EXCEPTION) .log(DATE_LOG+SALIDA_BSS_EXCEPTION) .doCatch(NoHttpResponseException.class) .process(new UserProfileProcessHttpHostConectionException()) .log(DATE_LOG+MSG_EXCEPTION) .log(DATE_LOG+SALIDA_BSS_EXCEPTION); } } ``` The error is the following when doing the native compilation: ``` 20:03:34 ERROR traceId=, parentId=, spanId=, sampled= [or.ap.ca.qu.ma.CamelMainRuntime] (main) Failed to start application: org.apache.camel.FailedToCreateRouteException: Failed to create route route2: Route(route2)[From[direct:userIdParam] -> [OnException[[org.... because of java.lang.ClassNotFoundException: org.apache.http.conn.HttpHostConnectException at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:81) at org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49) at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:937) at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:800) at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:3008) at org.apache.camel.quarkus.core.FastCamelContext.doInit(FastCamelContext.java:174) at org.apache.camel.support.service.BaseService.init(BaseService.java:83) at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2679) at org.apache.camel.support.service.BaseService.start(BaseService.java:111) at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2698) at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:262) at org.apache.camel.quarkus.main.CamelMain.doStart(CamelMain.java:94) at org.apache.camel.support.service.BaseService.start(BaseService.java:119) at org.apache.camel.quarkus.main.CamelMain.startEngine(CamelMain.java:140) at org.apache.camel.quarkus.main.CamelMainRuntime.start(CamelMainRuntime.java:49) at org.apache.camel.quarkus.core.CamelBootstrapRecorder.start(CamelBootstrapRecorder.java:45) at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot173480958.deploy_0(Unknown Source) at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot173480958.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:108) at io.quarkus.runtime.Quarkus.run(Quarkus.java:71) at io.quarkus.runtime.Quarkus.run(Quarkus.java:44) at io.quarkus.runtime.Quarkus.run(Quarkus.java:124) at io.quarkus.runner.GeneratedMain.main(Unknown Source) Caused by: org.apache.camel.RuntimeCamelException: java.lang.ClassNotFoundException: org.apache.http.conn.HttpHostConnectException at org.apache.camel.reifier.errorhandler.ErrorHandlerReifier.createExceptionClasses(ErrorHandlerReifier.java:322) at org.apache.camel.reifier.errorhandler.ErrorHandlerReifier.addExceptionPolicy(ErrorHandlerReifier.java:299) at org.apache.camel.reifier.errorhandler.ErrorHandlerReifier.configure(ErrorHandlerReifier.java:342) at org.apache.camel.reifier.errorhandler.DefaultErrorHandlerReifier.createErrorHandler(DefaultErrorHandlerReifier.java:62) 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.RouteReifier.doCreateRoute(RouteReifier.java:342) at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:75) ... 24 more ``` The classes of exceptions that I have registered for reflection are the following: GlobalApiException ``` @RegisterForReflection public abstract class GlobalApiException extends RuntimeException { /** * */ private static final long serialVersionUID = 1L; public GlobalApiException(final String exception) { super(exception); } } ``` BusinessRuleException ``` @RegisterForReflection public abstract class BusinessRuleException extends GlobalApiException { private static final long serialVersionUID = 1L; /** * @param exception */ public BusinessRuleException(final String exception) { super(exception); } } ``` EmptyDataExceptionQueryParam ``` @RegisterForReflection public class EmptyDataExceptionQueryParam extends BusinessRuleException { /** * @param exception * */ private static final long serialVersionUID = 1L; public EmptyDataExceptionQueryParam(String exception) { super(exception); } } ``` InvalidFormatException ``` @RegisterForReflection public class InvalidFormatException extends BusinessRuleException{ /** * */ private static final long serialVersionUID = 1L; public InvalidFormatException(String exception) { super(exception); } } ``` NotFoundDataException ``` @RegisterForReflection public class NotFoundDataException extends BusinessRuleException { /** * @param exception * */ private static final long serialVersionUID = 1L; public NotFoundDataException(String exception) { super(exception); } } ``` RequiredValueException ``` @RegisterForReflection public class RequiredValueException extends BusinessRuleException{ /** * */ private static final long serialVersionUID = 1L; public RequiredValueException(String exception) { super(exception); } } ``` What do I need to add to be able to register the exceptions that I place in the onException lines and that are not custom exceptions? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org