Buddhika Alwis
Buddhika Alwis

Reputation: 371

how to configure main class path in tanuki wrapper for spring boot

I am using a spring boot application and after build my project using maven, i can see a jar file of my application with maintaining following folder structure

enter image description here

buddika@buddika-pc:~/Desktop/visitor-tracking-automation-api-server/bin$ ll /home/buddika/Desktop/api-0.0.1-SNAPSHOT/
total 32
drwxrwxr-x  6 buddika buddika  4096 Sep 18 22:51 ./
drwxr-xr-x 33 buddika buddika 12288 Sep 18 23:14 ../
drwxr-xr-x  4 buddika buddika  4096 Sep 18 22:08 BOOT-INF/
drwxr-xr-x  3 buddika buddika  4096 Sep 18 22:08 META-INF/
drwxr-xr-x  3 buddika buddika  4096 Sep 18 22:08 org/

but problem is in tanuki wrapper. it is not identify this (BOOT-INF/classes/com/visitor/tracking/automation/api/boot/APIServerStart) folder structure.

enter image description here

instead above folder structure of jar, it is expecting following folder structure. I manually brought "com" folder to the front from BOOT-INF. that time wrapper is identify the main class and worked

enter image description here

buddika@buddika-pc:~/Desktop/visitor-tracking-automation-api-server/bin$ ll /home/buddika/Desktop/api-0.0.1-SNAPSHOT/
total 32
drwxrwxr-x  6 buddika buddika  4096 Sep 18 22:51 ./
drwxr-xr-x 33 buddika buddika 12288 Sep 18 23:14 ../
drwxr-xr-x  4 buddika buddika  4096 Sep 18 22:08 BOOT-INF/
drwxr-xr-x  3 buddika buddika  4096 Sep 18 22:08 com/
drwxr-xr-x  3 buddika buddika  4096 Sep 18 22:08 META-INF/
drwxr-xr-x  3 buddika buddika  4096 Sep 18 22:08 org/

my question is how to configure this main class path without manually bring the "com" package to front.

is there a way to make the jar by bring "com" package to front without putting in to "BOOT-INF"

following configurations were used in wrapper.conf file

wrapper.java.command=java
wrapper.working.dir=..
wrapper.java.mainclass=com.visitor.tracking.automation.api.boot.APIServerStarter
set.default.REPO_DIR=lib
set.default.APP_BASE=.

Upvotes: 2

Views: 850

Answers (1)

CoocooFroggy
CoocooFroggy

Reputation: 162

What worked for me was setting the Main class to org.springframework.boot.loader.JarLauncher instead of my application's Main class.

The documentation for JarLauncher says:

Launcher for JAR based archives. This launcher assumes that dependency jars are included inside a /BOOT-INF/lib directory and that application classes are included inside a /BOOT-INF/classes directory.

This way, you don't have to move your package to the root of the jar—the "org" folder shown in your screenshots should already have the path to JarLauncher.

Upvotes: 0

Related Questions