quarkus icon indicating copy to clipboard operation
quarkus copied to clipboard

Error Quarkus Native Build step org.apache.camel.quarkus.core.deployment.CamelProcessor#camelServices threw an exception: java.nio.file.ClosedFileSystemException

Open cesarjv opened this issue 8 months ago • 2 comments

Good afternoon, I am currently working with Camel and Quarkus and I am trying to compile my native code, it is giving me the following error when trying to do the native compilation:

[error]: Build step org.apache.camel.quarkus.core.deployment.CamelNativeImageProcessor#camelRuntimeCatalog threw an exception: java.nio.file.ClosedFileSystemException
[ERROR]         at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.ensureOpen(ZipFileSystem.java:1666)
[ERROR]         at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.getFileAttributes(ZipFileSystem.java:536)
[ERROR]         at jdk.zipfs/jdk.nio.zipfs.ZipPath.readAttributes(ZipPath.java:767)
[ERROR]         at jdk.zipfs/jdk.nio.zipfs.ZipPath.readAttributes(ZipPath.java:777)
[ERROR]         at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.readAttributes(ZipFileSystemProvider.java:276)
[ERROR]         at java.base/java.nio.file.Files.readAttributes(Files.java:1851)
[ERROR]         at java.base/java.nio.file.Files.isDirectory(Files.java:2322)
[ERROR]         at org.apache.camel.quarkus.core.deployment.util.CamelSupport.services(CamelSupport.java:62)
[ERROR]         at org.apache.camel.quarkus.core.deployment.CamelNativeImageProcessor.camelRuntimeCatalog(CamelNativeImageProcessor.java:177)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:864)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:282)
[ERROR]         at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:833)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:501)

The command to compile natively that I am using is the following:

/mvnw package -Pnative -Dquarkus.native.container-build=true -Djacoco.destFile=target/jacoco-report/jacoco.xml verify org.jacoco:jacoco-maven-plugin:0.8.7:prepare-agent

Attaches my pom.xml:

pom.xml

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.tmve.subscriber</groupId>
    <artifactId>get-activate-session-by-ip</artifactId>
    <version>1.0.0-DEV</version>
    <properties>
        <compiler-plugin.version>3.11.0</compiler-plugin.version>
        <maven.compiler.release>17</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
        <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
        <quarkus.platform.version>3.2.10.Final</quarkus.platform.version>
        <skipITs>true</skipITs>
        <surefire-plugin.version>3.0.0</surefire-plugin.version>
        <jacoco.version>0.8.7</jacoco.version>
        <sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/jacoco-report/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>${quarkus.platform.artifact-id}</artifactId>
                <version>${quarkus.platform.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>quarkus-camel-bom</artifactId>
                <version>${quarkus.platform.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-rest-openapi</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-bean-validator</artifactId>
            <version>3.7.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-bean</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-direct</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-http</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-jackson</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-jaxb</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-log</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-arc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.22</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-openapi-java</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-smallrye-openapi</artifactId>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>swagger-ui</artifactId>
            <version>4.11.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-opentelemetry</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-opentelemetry-exporter-otlp</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-jacoco</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
        </dependency>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>1.6.11</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>quarkus-maven-plugin</artifactId>
                <version>${quarkus.platform.version}</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <goals>
                            <goal>build</goal>
                            <goal>generate-code</goal>
                            <goal>generate-code-tests</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${compiler-plugin.version}</version>
                <configuration>
                    <compilerArgs>
                        <arg>-parameters</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <configuration>
                    <systemPropertyVariables>
                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                        <maven.home>${maven.home}</maven.home>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <systemPropertyVariables>
                        <native.image.path>${project.build.directory}/${project.build.finalName}-runner
                        </native.image.path>
                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                        <maven.home>${maven.home}</maven.home>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>native</id>
            <activation>
                <property>
                    <name>native</name>
                </property>
            </activation>
            <properties>
                <skipITs>false</skipITs>
                <quarkus.package.type>native</quarkus.package.type>
            </properties>
        </profile>
    </profiles>
</project>

Class Route:

package com.tmve.subscriber.ms.route;

import com.tmve.subscriber.ms.beans.BeanDate;
import com.tmve.subscriber.ms.beans.request.Request;
import com.tmve.subscriber.ms.beans.response.Response;
import com.tmve.subscriber.ms.exceptions.InvalidFormatException;
import com.tmve.subscriber.ms.exceptions.NotFoundDataException;
import com.tmve.subscriber.ms.processor.FindPhoneNumberByIpDummyProcess;
import com.tmve.subscriber.ms.processor.NotFoundDataExcepcionProcessor;
import com.tmve.subscriber.ms.processor.RequiredValueExcepcionProcessor;
import jakarta.enterprise.context.ApplicationScoped;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.bean.validator.BeanValidationException;
import org.apache.camel.model.rest.RestBindingMode;
import org.apache.camel.model.rest.RestParamType;
import org.eclipse.microprofile.config.inject.ConfigProperty;

@ApplicationScoped
public class RestRoute extends RouteBuilder {
    @ConfigProperty(name = "client.idp")
    String urlIdp;

    @ConfigProperty(name = "path.openapi")
    String pathOpenapi;

    @ConfigProperty(name = "descripcion.servicio")
    String descriptionService;


    private static final String SALIDA_BSS_EXCEPTION = "Salida del microservicio GetActivateSessionByIp ${body}";
    private static final String MSG_EXCEPTION = "Descripcion de la Exception: ${exception.message}";

    private static final String DATE_LOG = "[${bean:BeanDate.getCurrentDateTime()}] ";

    @Override
    public void configure() {

        BeanDate beanDate= new BeanDate();
        getContext().getRegistry().bind("BeanDate", beanDate);

        restConfiguration().bindingMode(RestBindingMode.json).dataFormatProperty("json.in.disableFeatures","FAIL_ON_UNKNOWN_PROPERTIES")
                /*.clientRequestValidation(true) */
                .apiContextPath(pathOpenapi)
                .apiProperty("api.title","GetActiveSessionByIp")
                .apiProperty("api.description",descriptionService)
                .apiProperty("api-version","1.0.0")
                .apiProperty("cors","true");
        rest("/api/")
                .produces("application/json")
                .consumes("application/json")
                .post("/getActivateSessionByIp")
                .type(Request.class)
                .param().name("x-transaction-id").type(RestParamType.header).required(true).endParam()
                .outType(Response.class)
                .param().name("Response").type(RestParamType.body).description("Parametros de Salidas")
                .required(true)
                .endParam().to("direct:pipeline");
                from("direct:pipeline")
                        .doTry()
                            .process(exchange -> {
                                String xTransactionId = exchange.getIn().getHeader("x-transaction-id", String.class);
                                String xUser=exchange.getIn().getHeader("x-user",String.class);
                                String xToken=exchange.getIn().getHeader("x-token",String.class);
                                if (xTransactionId == null || xTransactionId.isEmpty() || xUser == null || xUser.isEmpty() || xToken == null || xToken.isEmpty()) {
                                    throw new InvalidFormatException("header parameters is missing or invalid");
                                }
                            })
                            .log(DATE_LOG+ "Valor Header x-transaction-id: ${header.x-transaction-id}")
                            .to("bean-validator:validateRequest")
                            .log(DATE_LOG+ "Datos de Entrada del MS: ${body}")
                            .process(new FindPhoneNumberByIpDummyProcess())
                            .log(DATE_LOG+ "Datos de Salida del MS: ${body}")
                        .endDoTry()
                        .doCatch(BeanValidationException.class)
                            .process(new RequiredValueExcepcionProcessor())
                            .log(DATE_LOG+MSG_EXCEPTION)
                            .log(DATE_LOG+SALIDA_BSS_EXCEPTION)
                        .doCatch(InvalidFormatException.class)
                            .process(new RequiredValueExcepcionProcessor())
                            .log(DATE_LOG+MSG_EXCEPTION)
                            .log(DATE_LOG+SALIDA_BSS_EXCEPTION)
                        .doCatch(NotFoundDataException.class)
                            .process(new NotFoundDataExcepcionProcessor())
                            .log(DATE_LOG+MSG_EXCEPTION)
                            .log(DATE_LOG+SALIDA_BSS_EXCEPTION);
    }
}

application.properties

quarkus.ssl.native=true
quarkus.http.ssl-port=${PORT-SSl:8080}
quarkus.http.insecure-requests=disabled
quarkus.http.ssl.certificate.key-store-file-type=JKS
quarkus.http.ssl.certificate.key-store-file=${UBICATION_CERTIFICATE_SSL:srvdevrma1.jks}
quarkus.http.ssl.certificate.key-store-password=${PASSWORD_CERTIFICATE_SSL:11111111111}
quarkus.http.cors=true
quarkus.jackson.timezone=${TIME_ZONE:GMT-4}
quarkus.http.read-timeout=${READ_TIMEOUT:30000}
path=/api/getActivateSessionByIp

descripcion.servicio=Microservicio que ejecuta la busqueda de un numero movil a partir de una IP/Puerto en la plataforma de Trazabilidad de Red
#ssl client
client.ssl.password=service123
client.ssl.resource=srvdevrma1.jks


#Open telemetry
quarkus.application.name=GetActivateSessionByIp
quarkus.otel.exporter.otlp.traces.endpoint=${URL_JAEGER:http://172.28.2.107:4317}
quarkus.otel.enabled=true
quarkus.log.console.format=%d{HH:mm:ss} %-5p traceId=%X{traceId}, parentId=%X{parentId}, spanId=%X{spanId}, sampled=%X{sampled} [%c{2.}] (%t) %s%e%n

#Ruta OpenApi
path.openapi=/api/getActivateSessionByIp/openapi/swagger-ui/

#Headersw
quarkus.http.header."X-Content-Type-Options".value=nosniff
quarkus.http.header."X-Frame-Options".value=DENY
quarkus.http.header."Content-Security-Policy".value=default-src
quarkus.http.header."X-XSS-Protection".value=1; mode=block
quarkus.http.header."Expect-CT".value=report-only
quarkus.http.header."Permissions-Policy".value=geolocation=*, fullscreen=*
quarkus.http.header."Cache-Control".value=no-cache

#Report Jacoco
quarkus.jacoco.excludes=com/huawei/**

#path.openapi=/openapi.yaml
camel.rest.api-context-path=/api/getActivateSessionByIp/openapi.yaml
quarkus.swagger-ui.urls.camel=/api/getActivateSessionByIp/openapi.yaml

quarkus.swagger-ui.enable=true
quarkus.swagger-ui.path=/api/getActivateSessionByIp/swagger-ui/
quarkus.swagger-ui.always-include=true

#Error Code

error.0.code=0
error.0.message=Transaccion Exitosa

error.101.code=101
error.101.message=Token invalido

error.102.code=102
error.102.message=Peticion incorrecta

error.103.code=103
error.103.message=Imposible identificar cliente con datos entregados

error.104.code=104
error.104.message=Error interno

error.105.code=105
error.105.message=Timeout

#native-build
quarkus.native.additional-build-args=-march=compatibility,-H:IncludeResources=.*\\.jks

Proccessor:

NotFoundDataExcepcionProcessor

package com.tmve.subscriber.ms.processor;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.tmve.subscriber.ms.beans.response.Response;
import com.tmve.subscriber.ms.mapping.IGetActiveSessionByIpResponse;
import com.tmve.subscriber.ms.mapping.impl.GetActiveSessionByIpResponseImpl;
import jakarta.enterprise.context.ApplicationScoped;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.eclipse.microprofile.config.ConfigProvider;

@ApplicationScoped
public class NotFoundDataExcepcionProcessor implements Processor {

    private final String errorCode103 = ConfigProvider.getConfig().getValue("error.103.code", String.class);
    private final String errorMessage103 = ConfigProvider.getConfig().getValue("error.103.message", String.class);
    private final IGetActiveSessionByIpResponse response;
    private final ObjectMapper objectMapper;

    public NotFoundDataExcepcionProcessor() {
        response = new GetActiveSessionByIpResponseImpl();
        objectMapper = new ObjectMapper();
    }
    @Override
    public void process(Exchange exchange) throws Exception {

        Response apiResponse = response.toResponse(null,errorCode103, errorMessage103);
        String jsonResponse = objectMapper.writeValueAsString(apiResponse);
        exchange.setProperty("bodyRs", objectMapper.writeValueAsString(jsonResponse));
        exchange.getMessage().setHeader(Exchange.CONTENT_TYPE, "application/json");
        exchange.getMessage().setHeader(Exchange.HTTP_RESPONSE_CODE, 404);
        exchange.getMessage().setBody(jsonResponse);
    }
}

RequiredValueExcepcionProcessor

package com.tmve.subscriber.ms.processor;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.tmve.subscriber.ms.beans.response.Response;
import com.tmve.subscriber.ms.mapping.IGetActiveSessionByIpResponse;
import com.tmve.subscriber.ms.mapping.impl.GetActiveSessionByIpResponseImpl;
import jakarta.enterprise.context.ApplicationScoped;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.eclipse.microprofile.config.ConfigProvider;

@ApplicationScoped
public class RequiredValueExcepcionProcessor implements Processor {

    private final String errorCode102 = ConfigProvider.getConfig().getValue("error.102.code", String.class);
    private final String errorMessage102 = ConfigProvider.getConfig().getValue("error.102.message", String.class);
    private final IGetActiveSessionByIpResponse response;
    private final ObjectMapper objectMapper;

    public RequiredValueExcepcionProcessor() {
        response = new GetActiveSessionByIpResponseImpl();
        objectMapper = new ObjectMapper();
    }
    @Override
    public void process(Exchange exchange) throws Exception {

        String id= exchange.getProperty("id",String.class);
        Response apiResponse = response.toResponse(null,errorCode102, errorMessage102);
        String jsonResponse = objectMapper.writeValueAsString(apiResponse);
        exchange.setProperty("bodyRs", objectMapper.writeValueAsString(jsonResponse));
        exchange.getMessage().setHeader(Exchange.CONTENT_TYPE, "application/json");
        exchange.getMessage().setHeader(Exchange.HTTP_RESPONSE_CODE, 400);
        exchange.getMessage().setBody(jsonResponse);
    }
}

FindPhoneNumberByIpDummyProcess

package com.tmve.subscriber.ms.processor;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.tmve.subscriber.ms.beans.request.Request;
import com.tmve.subscriber.ms.beans.response.Response;
import com.tmve.subscriber.ms.exceptions.NotFoundDataException;
import com.tmve.subscriber.ms.mapping.IGetActiveSessionByIpResponse;
import com.tmve.subscriber.ms.mapping.impl.GetActiveSessionByIpResponseImpl;
import com.tmve.subscriber.ms.utilities.PhoneNumberByIP;
import jakarta.enterprise.context.ApplicationScoped;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.eclipse.microprofile.config.ConfigProvider;

@ApplicationScoped
public class FindPhoneNumberByIpDummyProcess implements Processor {

    private final String errorCode0 = ConfigProvider.getConfig().getValue("error.0.code", String.class);
    private final String errorMessage0 = ConfigProvider.getConfig().getValue("error.0.message", String.class);
    private final IGetActiveSessionByIpResponse response;
    private final ObjectMapper objectMapper;

    public FindPhoneNumberByIpDummyProcess() {
        response = new GetActiveSessionByIpResponseImpl();
        objectMapper = new ObjectMapper();
    }

    @Override
    public void process(Exchange exchange) throws Exception {
        Request request=exchange.getIn().getBody(Request.class);
        String ipAddress=request.getIp_address();
        String sourcePort= String.valueOf(request.getSource_port());
        String phoneNumber;
        if (PhoneNumberByIP.map.containsKey(ipAddress)){
            phoneNumber=PhoneNumberByIP.map.get(ipAddress);
        } else {
            throw new NotFoundDataException("No se encontro informacion asociado al subscriptor");
        }
        Response apiResponse = response.toResponse(phoneNumber,errorCode0, errorMessage0);
        String jsonResponse = objectMapper.writeValueAsString(apiResponse);
        exchange.setProperty("bodyRs", objectMapper.writeValueAsString(jsonResponse));
        exchange.getMessage().setHeader(Exchange.CONTENT_TYPE, "application/json");
        exchange.getMessage().setHeader(Exchange.HTTP_RESPONSE_CODE, 200);
        exchange.getMessage().setBody(apiResponse);
    }
}

Class PhoneNumberByIP

package com.tmve.subscriber.ms.utilities;

import io.quarkus.runtime.annotations.RegisterForReflection;

import java.util.Map;

public class PhoneNumberByIP {

    public static Map<String,String> map= Map.ofEntries(
            Map.entry("35.170.127.17","+5842xxxxxx"),
            Map.entry("188.225.2.32","+58414xxxxxx"),
            Map.entry("255.110.216.33","+58414xxxxxx"),
            Map.entry("101.54.36.138","+584145xxxxxx"),
            Map.entry("172.26.120.251","+58414xxxxxx"),
            Map.entry("152.83.50.147","+58414xxxxxx"),
            Map.entry("198.57.235.107","+58414xxxxxx"));
}

What could be happening so that my code is not compiling correctly?

cesarjv avatar Jun 14 '24 18:06 cesarjv