0

I am currently going crazy trying to start my Dropwizard application that I have packed into a JAR file. When I try to run the JAR with java -jar myjar.jar server configs.yml I get this error:

java.io.FileNotFoundException: File configs.yml not found.

The configs.yml file in the base of my project so the path should be no problem. I've tried different ways to set the path like absolute and relative but nothing works.

I've also changed my Application file trying to add things like:

public void initialize(Bootstrap<AppConfig> bootstrap) {
        bootstrap.setConfigurationSourceProvider(new SubstitutingSourceProvider(
                bootstrap.getConfigurationSourceProvider(),
                new EnvironmentVariableSubstitutor(false)));
}
bootstrap.setConfigurationSourceProvider(
                new ResourceConfigurationSourceProvider());
public void initialize(Bootstrap<AppConfig> bootstrap) {
}

I have looked at all possible tutorials including Dropwizards own and I followed it to a T even copying their code, but still I get the same error. I've followed other tutorials. I've searched for the problem and tried all tricks but nothing seems to work.

I just want my JAR to start. How do I package my config.yml file with my JAR so I can access it through my command? Is there something wrong with Intellij, Dropwizard, Maven or me?

Holken
  • 1
  • 1
  • See my comment here: https://stackoverflow.com/questions/42884004/how-to-package-config-yml-and-resources-in-project-0-0-1-snapshot-jar#comment72966041_42884004 Also note that the example application is started from the main folder for the subproject ("cd dropwizard-example"). The config file lives in the same directory. https://github.com/dropwizard/dropwizard/blob/master/dropwizard-example/README.md#running-the-application – zloster Oct 21 '19 at 11:12
  • Some configurations could have default values and there is the following mechanism for this: https://stackoverflow.com/questions/53831014/can-i-specify-default-values-for-a-config-yml-on-my-java-application But again it is explicit. – zloster Oct 21 '19 at 11:13

1 Answers1

0

Copy your configs.yml file and paste it parallel to your jar file and then run the command.