简体   繁体   中英

Error Reading custom configuration file in dropwizard Application

So we have a normal batching application that we decided to port over to dropwizard. We want to use dropwizard for lot of benefits that it gives us out of the box like HealthCheck, metrics etc.

We might add some REST admin end points later but right now we are just using DropWizard Managed Service to start our application in a separate thread. We created a sample config yml file but it's mostly just a skeleton.

This porting over is just mostly lift and shift and we want to avoid huge refactor in our code. The application is currently tied with two different properties file and we want to keep it that way.

We have figured a way out to deploy our app using a custom deployer that generates these property files "application.properties" and "system.properties" For some reason the app can't read those files and is throwing NPE. This is a java application. All the jars are under lib directory and the config files are under config directory. It just doesn't seem to resolve those files. I have tried searching the dropwizard docs but didn't find anything useful. The code just simply expects the file in a particular directory

private static final String APP_PROPERTIES_FILE = "/application.properties";
File file = new File(DataSourceFactory.class.getResource(filename)
            .getFile());

The dropwizard version : 1.2.2 And this is how I'm running the app :

java -cp "deployed/App/lib/*:deployed/App/config/*"  com.commercehub.app.MainClass server config.yml 

Any comments are really appreciated!

The issue was with my classpath. I didn't need the trailing /* for the config folder.

java -cp "deployed/App/lib/*:deployed/App/config"  com.commercehub.app.MainClass server config.yml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM