3 Replies Latest reply on Apr 7, 2014 11:09 AM by Francesco Calabri

    Load arbitrary resources outside ear/war/jar

    Francesco Calabri Newbie

      Hi all,

      i would like to load resources from a class without putting them inside my ear/war. The goal for this is to load files which are relative to the environment and the application (application server / war)

      As in this post (http://blog.jyore.com/?p=58), i created a new module and added the dependency to this module inside the MANIFEST of my war.

      The module.xml and the resources are placed in {WILDFLY_HOME}\modules\system\layers\base\com\mycomp\myapp\resources\main

       

      <?xml version="1.0" encoding="UTF-8"?>

      <module xmlns="urn:jboss:module:1.1" name="com.mycomp.myapp.resources">

          <resources>

              <resource-root path="."/>

          </resources>

      </module>

       

      In this folder, as a test, i placed a simle properties file named application_setting.properties.

       

      In a servlet I try to load application_setting.properties

      InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("application_setting.properties");

      but "is" is always null.

       

      Any help is much appreciated!

      Thanks