5 Replies Latest reply on Mar 13, 2012 1:37 PM by viggo.navarsete

    conf directory equivalent in JBoss 7?

    viggo.navarsete

      I'm porting an application from JBoss 6.1.0.Final to JBoss 7.1.0.Final. We had some configuration files in $JBOSS_HOME/server/<server instance>/conf directory which we read using

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

       

      In JBoss 7.1.0.Final there isn't a conf directory, but there is something similar, $JBOSS_HOME/standalone/configuration where I thought I could put the files and read them the same way...BUT, that directory doesn't seem to be on the classpath anymore.

       

      Does anyone know where I could put such files using JBoss 7?

        • 1. Re: conf directory equivalent in JBoss 7?
          wdfink

          You might have a look to  this thread.

           

          I would pack such resources in a jar and add it to the module directory. For your app aou have to set a dependency.

          • 2. Re: conf directory equivalent in JBoss 7?
            viggo.navarsete

            Thanks for input Wolf-Dieter!

             

            The problem is that they discuss the problem, and actuallys states that it is a difference between the two mentioned configuration directories, but there is no solution to my problem there. They mention log4j.xml and datasources as two files, but they are "jboss specific" files, and have their new places in the new jboss. I'm talking about my own configuration files which I used to put in $JBOSS_HOME/server/<instance/conf directory, and read it with Thread.currentThread()......

            This doesn't seem to work anymore in JBoss 7, and that's the problem I want to discuss in this thread. The configuration files I have are files that we use to change the configuration of our application, and it was very convenient to have configuration file that could be easily changed. If the files are put in a jar it will be more messy, and impossible to change.

            • 3. Re: conf directory equivalent in JBoss 7?
              guinotphil

              I guess you should get rid of the current way you load such resources, because they are not meant to be on your application's class loader.

               

              Why don't you add a property on your standalone.xml to the system path of the configuration, eg <property name="myapp.confdir" value="/etc/myapp"/>

               

              And then, create your own ConfigurationLoader that can load a file like this:

               

              InputStream getResourceAsStream( String filename ) {

                  return new File(new File(System.getProperty("myapp.confdir"), filename).getURI().getURL().openStream();

              }

              • 4. Re: conf directory equivalent in JBoss 7?
                wdfink

                Just to notice, use of java.io.* inside of a JEE application is violating the spec.

                I know it is used often but may have some side effects.

                • 5. Re: conf directory equivalent in JBoss 7?
                  viggo.navarsete

                  Wolf-Dieter and guinotphil: Any best practises on how I should do it?