Cannot load property file as module

97 views
Skip to first unread message

Dennis Soans

unread,
Aug 24, 2023, 11:19:56 AM8/24/23
to WildFly
I am attempting to run a Service Provider (Wildfly 26) to execute a Custom Credential Store Class in the first module. This Class then calls another application Class (in a WAR) that attempts to read a Property file in the second module.

The standalone has both the Service Provider jar and the property file in separate modules - one for Jar and one for property file and both modules are global-modules.  Other application jars are in a WAR in the EAR.

        <subsystem xmlns="urn:jboss:domain:ee:6.0">
<global-modules>
<module name="com.myApp" slot="main" />  
<module name="configuration" slot="main" />
</global-modules> 

Example:
Module 1 (Property file):  <WILDLFY_HOME>/modules/configuration/main

<module xmlns="urn:jboss:module:1.1" name="configuration">

    <resources>
        <resource-root path="myapp.properties"/>
    </resources>
</module>

Module 2 (Service Provider) : <WILDLFY_HOME>/modules/system/layers/base/com/myApp/main

<module xmlns="urn:jboss:module:1.1" name="com.myApp">

    <resources>
      <!--   <resource-root path="."/> -->
  <resource-root path="myServiceProvider.jar"/>
    </resources>

Wildfly can find the Service provider with below:

<providers name="credstore"/>
                </aggregate-providers>
                <provider-loader name="credstore" module="com.myApp" class-names="com.myApp.CustomCredentialStoreProvider"/>
            </providers>

Unfortunately it cannot find the property file. I had first tried to place both property file and jar in same module but Wildfly tripped up on reading the property file and complained about being a zip file, so I decided to place them in separate modules.

I am reading the property file in Java as:

instream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("myapp.properties");

I get a NullPointerException here as property file is not located.

I have also made other attempts in defining the modules under the EAR META-INF in jboss-deployment-structure.xml as well as with Dependencies line in application.xml.

So to summarize, why is the jar module (service Provider) located without issue BUT not the property module...????

Reply all
Reply to author
Forward
0 new messages