Skip to content

Unable to build a native image with a custom application directory #44798

@stefferro

Description

@stefferro

Hi,

I am experiencing an issue while building a native image when specifying a custom app directory.

The building process fails at the very end with the following error message.

[INFO]     [creator]     Finished generating 'com.example.demo.DemoApplication' in 1m 48s.
[INFO]     [creator]       Removing bytecode
[INFO]     [creator]     unable to invoke layer creator
[INFO]     [creator]     unable to remove /myapp/BOOT-INF
[INFO]     [creator]     unlinkat /myapp/BOOT-INF: permission denied
[INFO]     [creator]     ERROR: failed to build: exit status 1

The documentation does not mention that changing the default application directory is not supported for native image so I presume this is an issue.

How to reproduce

  • Generate a default demo project using Spring Initializr; You can use this link
  • Modify the spring-boot-maven-plugin as below. I specify an application directory other than /workspace and enable the native build.
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
	    <image>
	        <applicationDirectory>/myapp</applicationDirectory>
		<env>
		    <BP_NATIVE_IMAGE>true</BP_NATIVE_IMAGE>
		</env>
	    </image>
	</configuration>
</plugin>
  • Run the maven command to generate the image
./mvnw spring-boot:build-image -Pnative

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fixstatus: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions