-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Open
Labels
status: waiting-for-feedbackWe need additional information before we can continueWe need additional information before we can continuestatus: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged
Description
I'm using logback the default logging system with graal native image and I'm using this repo under native-image/spring-boot-microservice-jibber.
What I changed:
- pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>spring</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>spring</name>
<properties>
<spring-cloud.version>2023.0.0</spring-cloud.version>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-wiremock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.rednoise</groupId>
<artifactId>rita</artifactId>
<version>2.4.501</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<buildArgs combine.children="append">
<arg>-Ob</arg>
<arg>--initialize-at-run-time=com.fasterxml.jackson.databind.*,com.fasterxml.jackson.core.*,org.apache.logging.slf4j.*</arg>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>- in the main package HintConfiguration + logback.xml + applycation.yaml
@Configuration
@ImportRuntimeHints(HintConfiguration.InnerHintRegistar.class)
public class HintConfiguration {
public static class InnerHintRegistar implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints runtimeHints, ClassLoader classLoader) {
runtimeHints.resources().registerPattern("logback.xml");
}
}
}<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- Optional: define a few common properties -->
<property name="LOG_DATEFORMAT_PATTERN" value="yyyy-MM-dd HH:mm:ss.SSS"/>
<property name="LOG_LEVEL_PATTERN" value="%5p"/>
<property name="LOG_FILE_FORMAT"
value="%d{${LOG_DATEFORMAT_PATTERN}} ${LOG_LEVEL_PATTERN} [%t][%c{1}:%L]: %m%n"/>
<!-- Console appender -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${LOG_FILE_FORMAT}</pattern>
</encoder>
</appender>
<!-- Root logger -->
<root level="INFO">
<appender-ref ref="CONSOLE"/>
</root>
</configuration>spring:
application:
name: test
cloud:
config:
fail-fast: false
profile: int1-test
discovery:
enabled: false
config:
import: "optional:configserver:http://localhost:8888?label=master"- in the test package:
package com.example.benchmarks.jibber;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.test.web.reactive.server.WebTestClient;
import com.github.tomakehurst.wiremock.client.WireMock;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
@RouteTest
public class CiaoTest {
@Test
void contextLoads() {}
}
@SpringBootTest
public class DemoApplicationTest {
@Test
void contextLoads() {
}
}
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@SpringBootTest
@AutoConfigureWebTestClient(timeout = "30000")
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@AutoConfigureWireMock(port = 9900)
@DisabledInNativeImage
public @interface RouteTest {
}
package com.example.benchmarks.jibber;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class DemoApplicationTest {
@Test
void contextLoads() {
}
}Error:
Caused by: java.nio.file.FileAlreadyExistsException: /Users/paolopiccinini/development/graalvm-demos/native-image/spring-boot-microservice-jibber/target/spring-aot/test/resources/META-INF/spring/logback-model
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:94)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:261)
at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:482)
at java.base/java.nio.file.Files.newOutputStream(Files.java:228)
at java.base/java.nio.file.Files.copy(Files.java:3153)
at org.springframework.aot.generate.FileSystemGeneratedFiles.addFile(FileSystemGeneratedFiles.java:93)
if I use @SpringBootTest instead of @RouteTest the test will work, if I remove spring-cloud-config-starter tests will work and if I change filename lombok.xml -> notImportant.xml test will work.
Command to reproduce mvn clean -PnativeTest test.
Can someone help me understand what is the problem? spring boot should work with lombok or lombok-spring.xml
Metadata
Metadata
Assignees
Labels
status: waiting-for-feedbackWe need additional information before we can continueWe need additional information before we can continuestatus: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triaged