1 year ago

#356466

test-img

gringogordo

Best way to debug the classloader when it isn't finding a property file

I'm deploying a jar which I believe has been packaged acceptably.

all the files except META-INF/MANIFEST.MF are in a single folder /share

so in the jar is is essentially

   META-INF/
   META-INF/MANIFEST.MF
   share/
   share/file21.class
   ...
   share/some.properties

in the code I'm trying to load the properties from file21.class

try {
    logger.error("@@@@@@@@1");
    InputStream in = File21.class.getResourceAsStream("/some.properties");
    logger.error("@@@@@@@@2");
    this.prop.load(in);
    in.close();
    // this.prop.load(getClass().getResourceAsStream("/some.properties"));
    logger.error("@@@@@@@@3");
...

} catch (IOException ex) {
    logger.error("error", ex);
} catch (Exception e) {
    logger.error("general exception", e);
}   

I have tried some variations and I never get to log point 3. I get

general exception: java.lang.NullPointerException at share.Class.(GetPropertyException.java:93)

Is there an easy way to see where the class loader is looking and where I should point it (or put the file) I'm using Ant so I'm using a build file to move the property file in the class path. Or so I thought.

java-8

classpath

0 Answers

Your Answer

Accepted video resources