Skip to content

Loader-Path in Manifest File has No Effect #7178

@hackingpath

Description

@hackingpath

The Problem

I have a JAR in a ./lib/ directory and I want to have all JARs in that directory on my classpath.

This is my generated manifest file:

Manifest-Version: 1.0
Start-Class: biz.test.spring.boot.Application
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Loader-Path: lib                 <=============== look here
Spring-Boot-Version: 1.4.1.RELEASE
Main-Class: org.springframework.boot.loader.PropertiesLauncher

Actually even w/o any setting this should work(see):

loader.path (if empty) defaults to lib (meaning a local directory or a nested one if running from an archive). Because of this PropertiesLauncher behaves the same as JarLauncher when no additional configuration is provided.

But it does not so I tried with the MANIFEST.MF. But it has no effect. I also tried absolute paths. This feature is mentioned here:

Manifest entry keys are formed by capitalizing initial letters of words and changing the separator to “-” from “.” (e.g. Loader-Path). The exception is loader.main which is looked up as Start-Class in the manifest for compatibility with JarLauncher).

I also tried with a setting in application.properties but there is no effect either.

SUMMARY

3 Problems:

  • lib/ folder not on classpath by default
  • Loader-Path in MANIFEST.MF has no effect
  • loader.path in application.properties has no effect

Workaround

I can run the application like this:

java -Dloader.path=lib -jar application-1.0.0.jar

Because I run it as init.d service I have *.conf file that sets loader.path in the JAVA_OPTS property.

But this doubles the effort during releases because the name of the JAR file contains the version and I need to update the link to the JAR AND the name of the *.conf file everytime.

Demo Data

I have a very simple Spring-Boot application to try that out:
https://github.com/PatrickTheFirst/spring-boot-test

The lib folder with the JAR is also checked in. But you can build the JAR on your own with this project:
https://github.com/PatrickTheFirst/demo-rest

If it works you will see a new Rest Servlet V1 servlet and you can call GET localhost:8081/rest/test/get.

System

Linux Mint 17.3 64-bit
Kernel Linux 4.4.0-15-generic x86_64
MATE 1.12.0

Spring Boot 1.4.1.RELEASE
Gradle 2.12

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions