java - Executable Jar cannot find typesafe/config application.conf on classpath -


i have command line app downloads reports, processes them, uploads data google drive. i'm using typesafe-config magic strings need. typesafe-config looks on classpath application.conf file , uses hocon map config objects fields in class, this:

from ~/configs/application.conf:

my.homepageurl = "https://my.home.com"

from myclass.java:

private static config config = configfactory.load(); private static final string home_url = config.getstring("my.homepageurl"); 

i'm using maven-shade-plugin build executable .jar easy deployment on remote server. plugin looks this:

<plugin>                 <groupid>org.apache.maven.plugins</groupid>                 <artifactid>maven-shade-plugin</artifactid>                 <version>2.4</version>                 <configuration>                     <transformers>                         <transformer implementation="org.apache.maven.plugins.shade.resource.manifestresourcetransformer">                             <manifestentries>                                 <main-class>com.my.reports.reportrunner</main-class>                                 <class-path>~/configs/application.conf</class-path>                             </manifestentries>                         </transformer>                     </transformers>                 </configuration>                 <executions>                     <execution>                         <phase>package</phase>                         <goals>                             <goal>shade</goal>                         </goals>                     </execution>                 </executions>             </plugin> 

the problem is, when run executable .jar, application.conf isn't found on classpath (i guess bug in typesafe code). works fine in intellij.

dustinevan@imac:~/bin$ java -jar my-reports-1.0-snapshot.jar  exception in thread "main" java.lang.exceptionininitializererror caused by: com.typesafe.config.configexception$missing: no configuration setting found key 'my'     @ com.typesafe.config.impl.simpleconfig.findkey(simpleconfig.java:124)     @ com.typesafe.config.impl.simpleconfig.find(simpleconfig.java:147)     @ com.typesafe.config.impl.simpleconfig.find(simpleconfig.java:159)     @ com.typesafe.config.impl.simpleconfig.find(simpleconfig.java:164)     @ com.typesafe.config.impl.simpleconfig.getlist(simpleconfig.java:212)     @ com.typesafe.config.impl.simpleconfig.gethomogeneousunwrappedlist(simpleconfig.java:271)     @ com.typesafe.config.impl.simpleconfig.getstringlist(simpleconfig.java:329)     @ com.stellarliving.reports.ecp.reportrunner.<clinit>(reportrunner.java:19)  dustinevan@imac:~/configs$ ls total 8 -rw-r--r--@  1 dustinevan  staff  1520 jun 13 01:16 application.conf 

i've tried many permutations, , done lots of reading solve this, appreciated.

as had same problem...

the -jar overrides classpath settings, jar seen. -dconfig.trace=loads show seen java.

we want application.conf on classpath, jar, so: java -cp .:my-reports-1.0-snapshot.jar full.path.to.main.main did trick me. application.conf found , overrides reference.conf in jar.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -