Reputation: 2931
I have a bash script to start my application. My application is a spring application bundled as a FAT Jar with following Manifest entries.
Manifest-Version: 1.0
Implementation-Title: My App
Implementation-Version: 1.0-SNAPSHOT
Implementation-Build: 0aef5a1f96de18795c76b896e349c741d9
Implementation-Date: Sep 21, 2016 07:02:48 GMT
Created-By: 1.8.0_77 (Oracle Corporation)
Implementation-Vendor: App Team
Main-class: com.demo.ApplicationInitializer
I put this under a folder /Users/nn/apps/myapp/instance1
. This applications needs a config file configs.yml
from classpath and it was decided that this should be outside of the JAR file. This is the reason why I created a folder /Users/nn/apps/myapp/shared
and put this configs.yml
under it. In my startup script (start.sh
), I am adding following code to set the classpath:
JAVA_CLASSPATH="/Users/nn/apps/myapp/shared:/Users/nn/apps/myapp/instance1"
JAVA_CLASSPATH="$JAVA_CLASSPATH:/Users/nn/apps/myapp/shared/configs.yml"
export CLASSPATH=$JAVA_CLASSPATH
java <my_other_settings> -jar myapp-fatjar.jar
I get exception that configs.yml
is not in classpath (a Spring bean in my app tries to load this which throws exception).
I have also tried explicitly passing -classpath
to java
command pointing to $JAVA_CLASSPATH
.
What am I doing wrong?
Upvotes: 0
Views: 362
Reputation: 157
You could try the following start.sh script:
JAVA_CLASSPATH="/Users/nn/apps/myapp/shared:/Users/nn/apps/myapp/instance1"
JAVA_CLASSPATH="$JAVA_CLASSPATH:/Users/nn/apps/myapp/shared/configs.yml"
JAVA_CLASSPATH="$JAVA_CLASSPATH:myapp-fatjar.jar"
java -cp $JAVA_CLASSPATH com.demo.ApplicationInitializer
see https://stackoverflow.com/a/15930980/4473044
Upvotes: 1