4 Replies Latest reply on Dec 19, 2011 11:48 AM by eabrand

    how to load external property file in JBOSS

    sandipvdhande

      My application is using websales.property file ...where should i place the file so that this file can be loaded in my application

        • 1. Re: how to load external property file in JBOSS
          informsantosh

          Hi
          To access the propery file change the ant script to include that file in WEB-INF/ folder and add in the war.

          If you are using some frameworks like struts or spring its pretty easy to load property files. For struts you can refer to the example like how they load application message properties. For Spring i am giving you sample code below
          if property file is like
          jdbc.driver=org.postgresql.Driver
          jdbc.url=jdbc:postgresql://localhost/test
          jdbc.user=postgres
          jdbc.password=

          And your bean configuration will look like this:



          /WEB-INF/jdbc.properties




          ${jdbc.driver}


          ${jdbc.url}


          ${jdbc.user}


          ${jdbc.password}

          • 2. Re: how to load external property file in JBOSS
            informsantosh

            Hi ,

            I have used another way I have added system/application properties to properties-service.xml, This file can be found at server/default/deploy.

            To acess the variables declared in properties-service.xml , we will be able to access these varibles ${test.name}, This variable can be acceed from any config file like spring app-context.xml / web.xml . These properties can loaded prior to loading EJB/ any jar

            • 3. Re: how to load external property file in JBOSS
              jefo

              Hi guys,

              I have followed some tips in other posts but I cannot make this works.

              My properties-service.xml

              <attribute name="Properties">
               myProperty=myPropertyValue
              </attribute>
              


              my app-servlet.xml
              <bean id="MyService" class="acme.MyServiceImp">
               <property name="myProperty" value="${myProperty}"/>
              </bean>
              


              The issue is that the ${myProperty} value in my app-servlet.xml are not bind to the correct value that I spect for, myPropertyValue.

              Is there some additional spring conf that I forgot?!?

              Any help will be apreciate, tks.

              • 4. Re: how to load external property file in JBOSS
                eabrand

                Did this ever get resolved?