I have an application packaged in an EAR file and deployed on WildFly 9.0.2 Final. it needs to read some system properties defined by WildFly.
The problem is that the classes in the EAR fail to read the WildFly system properties. For example - the following code gets a NullPointerException:
String DEPLOY_DIR = System.getProperty("jboss.server.base.dir") + File.separator + "deployments"
File deployDir = new File(DEPLOY_DIR);
And this is the error:
java.lang.NullPointerException
at java.io.File.<init>(File.java:277)
The error occurs because the following returns null:
System.getProperty("jboss.server.base.dir")
Note that when WildFly goes up, its related system properties are shown correctly in its log:
jboss.server.base.dir = C:\javaSoft\workspaces\WildFly_Migration\App\configuration\wildfly-9.0.2.Final\standalone
jboss.server.config.dir = C:\javaSoft\workspaces\WildFly_Migration\App\configuration\wildfly-9.0.2.Final\standalone\configuration
jboss.server.data.dir = C:\javaSoft\workspaces\WildFly_Migration\App\configuration\wildfly-9.0.2.Final\standalone\data
jboss.server.deploy.dir = C:\javaSoft\workspaces\WildFly_Migration\App\configuration\wildfly-9.0.2.Final\standalone\data\content
jboss.server.log.dir = C:\javaSoft\workspaces\WildFly_Migration\App\configuration\wildfly-9.0.2.Final\standalone\log
My question - Is there any reason why the EAR can’t read any of the system properties?