Lajos Arpad
Lajos Arpad

Reputation: 76464

Why is getConfiguration occasionally throwing File cannot be null?

This might seem to be a simple question (if that's the case, please excuse me), but after 20 minutes of online searching I did not find any sensible answer.

I have several cron jobs to be executed via QuartzRunner, let's call the first FooBean and the second BarBean for now. FooBean is running daily at 00:00 for 6 (!) hours and sometimes it is not executed properly. After carefully studying the logs I found out that FooBean fails to execute when BarBean fails to execute. BarBean is executed daily at 03:00 and sometimes it throws:

 22866 java.lang.NullPointerException: File cannot be <null>
 22867     at org.jconfig.FileWatcher.<init>(FileWatcher.java:54)
 22868     at org.jconfig.handler.AbstractHandler.addFileListener(AbstractHandler.java:39)
 22869     at org.jconfig.ConfigurationManager.addFileListener(ConfigurationManager.java:180)
 22870     at org.jconfig.ConfigurationManager.getConfiguration(ConfigurationManager.java:122)

sometimes it does not throw it and then FooBean is executed properly. If BarBean fails, then the log shows some Transaction deadlock issue repeatedly for ten minutes and then JDBC connection failures repeated again and again for almost three hours. I do not understand what file is being involved. The line throwing the error looks like:

    Configuration config = ConfigurationManager.getConfiguration("inventory");

and org.jconfig namespaces are involved here. Intuitively this seems to be a misconfiguration, but I did not find any sources which explain the issue.

Upvotes: 0

Views: 243

Answers (1)

kSp
kSp

Reputation: 313

The ConfigurationManagers getConfiguration-Method tries to load a config file from your classpath. The function concatenates the given name with '_config.xml'. In your case this would be 'inventory_config.xml' this file should be in available on your classpath (main/resources) because ConfigurationManager tries to load it from there.

Upvotes: 1

Related Questions