1 2 Previous Next 17 Replies Latest reply on Jan 27, 2015 8:21 AM by Kishore Chintoju

    Set properties file in jboss7

    varsha g Newbie

      Hi,

      I have configured the properies file in jboss6 using properties-service.xml .

      here is my configuration for jboss6-->

       

          <mbean code="org.jboss.varia.property.SystemPropertiesService"

           name="jboss:type=Service,name=SystemProperties">

          <attribute name="URLList">

            here is path for properties file.

          </attribute>

          </mbean>

       

      Now i have installed the jboss7 server on my machine.how to deploy or configure this properties in jboss7 ?

        • 1. Re: Set properties file in jboss7
          markus78 Newbie

          Hi,

           

          In JBoss 7 you can define your system properties in the standalone.xml file (or domain) something like this..

           

          <system-properties>
               <property name="URLLIST" value="path for properties file"/>
          </system-properties>

           

          It's explained quite nicely here


          http://community.jboss.org/wiki/JBossAS7SystemProperties

           

          Regards

          /Markus

          • 2. Re: Set properties file in jboss7
            varsha g Newbie

            Hi,
            i have tried the above cofiguration but it is not reading the file.

            It takes name-value pair. e.g if key as ULRLIST then it give value as "url to properties file"

            • 3. Re: Set properties file in jboss7
              jaikiran pai Master

              Are you literally  trying to set that URIList property? That property is no longer used in JBoss AS7, so even if you set it to some value, that value won't be used (unless your application uses it). What exactly are you trying to do?

              • 4. Re: Set properties file in jboss7
                varsha g Newbie

                I want to read the properties file,and i can get the value using the system.getProperty("<key>") in jboss6.X  using the above configuration to do the same. .

                • 5. Re: Set properties file in jboss7
                  jaikiran pai Master

                  Which exact version of JBoss AS7 is this? Can you show us what exactly your configuration looks like? And what exact value you get from a call to System.getProperty(). I'll be highly surprised if this basic system property configuration is broken (i.e. returning some incorrect value).

                  • 6. Re: Set properties file in jboss7
                    varsha g Newbie

                    HI,

                    Am using the jboss 7.0.2. I have added the

                    <extensions>

                    </extensions>

                    <system-properties>
                         <property name="URLLIST" value="path for properties file"/>
                    </system-properties>


                    under the standalone.xml below the </extensions>.

                     

                    here is my properties file:-

                    a1=test;

                     

                    when it try to access the System.getProperty("a1") it gives null

                    but when i tried with System.getProperty("URLLIST") i gives the "path for properties file".

                     

                    But i want to read the properties file specified in path.

                    • 7. Re: Set properties file in jboss7
                      jaikiran pai Master

                      Ok, I now understand what you are trying to do (you should have posted this example earlier). So you want to point to a properites file to pick up the system properties. This isn't supported in AS7. Those individual properties from that properties file need to be configured in the system-properties element of the standalone.xml/domain.xml.

                       

                      Are these really system properties? Or do you want this properties file accessible in the classpath of the application? If it's the latter, then you can package those properties file in your application and then use the ClassLoader.getResourceAsStream() API to load the properties (instead of System.getProperty()).

                      • 8. Re: Set properties file in jboss7
                        varsha g Newbie

                                 Thanks jaikiran.

                                 Actually I was already aware of this but i am trying to read from system.getProperty() as i did in jboss6 by configurin it in properties-service.xml.    In jboss 7 i did not got any idea to do the same, so i prefer this option by reading it through source package.

                        • 9. Re: Set properties file in jboss7
                          jaikiran pai Master

                          varsha g wrote:

                           

                           

                                   Actually I was already aware of this but i am trying to read from system.getProperty() as i did in jboss6 by configurin it in properties-service.xml.    In jboss 7 i did not got any idea to do the same, so i prefer this option by reading it through source package.

                          Thinking a bit more about this, it should still be possible to do something similar. AS7 allows deployment of MBeans via -service.xml files (package them in your deployment's META-INF). So you could write a MBean similar to the AS6 MBean which accepts the path to the properties file and then sets the system properties which can then be accessed by your application code. It's just a matter of deciding which way you want to go.

                          • 10. Re: Set properties file in jboss7
                            Jeff Lavezzo Newbie

                            Setting aside the increasing tension surrounding the possibility that JBoss AS 7 is not ready for prime time yet, here's a scenario on which I'd like suggestions from the experts. (I'm looking at you, Jaikiran Pai)


                             

                            Our system runs on Glassfish and Jboss 4.2.3 and we've been asked to make it work on "a newer JBoss" (that was the extent of the requirement.)  Naively, we picked JBoss 7, unaware of the radical changes it contained.


                             

                            The system is composed primarily of 4 parts.  OurWebServices.war, OurWebApp.war, some jsp based portlets deployed in JBoss Portal or Liferay and OurServerAPI.jar.


                             

                            On other java servers, we put OurServerAPI in the server’s lib directory, OurServer.properties in the shared configuration directory (basically, on Java’s ClassPath) and put OurWebServices.war and OurWebApp.war in the appropriate deployment location.  When we deployed on different servers for different customers, only the properties values were changed.  The code responded to those changes to make all necessary adjustments to the environment. Obviously, putting the properties file INSIDE our war files isn’t the answer.  We’d have to repackage the applications for each new server.


                             

                            We have some evidence that starting up JBoss AS7 like this

                            JBOSS_HOME/standalone.bat –P OurServer.properties

                            works for us, but that seems to contradict what is being said by Marcus, Varsha and Jaikiran.

                             

                             

                            What would you do?

                             

                            Thanks


                            Jeff

                            • 11. Re: Set properties file in jboss7
                              jaikiran pai Master

                              Hi Jeff,

                               

                              This is thread started off with the MBean approach and hence is a bit confusing (I had to re-read this more than once). There are many ways users want to make use of properties file. One usecase is that they want to place it in a location that's available in the classpath and then do a ClassLoader.getResource() or a variant of that to get access to that file and load it later.

                               

                              Your usecase is slightly different, you are using the properties file to setup system properties and the way you are doing it by passing the -P param to the standalone server startup script should be fine.

                              • 12. Re: Set properties file in jboss7
                                rathm1 Newbie

                                We are having the same issue as Jeff, where in Jboss 6 and in Jboss 4.2.3 we had a property file located in the conf directory but now we can't figure out how to get the property file into the classpath of our ear.

                                We don't want to put the property file inside the ear and the -P option doesn't seem attractive.

                                 

                                I had put the property file in the standalone deployments directory and tried the ClassLoader.getResource() but it failed to load the property file.

                                 

                                jaikiran, do you have suggestions for how to add a property file to an ear's classpath?

                                Jeff, did you figure out another way besides the -P?

                                 

                                Thanks a lot.

                                • 13. Re: Set properties file in jboss7
                                  Zachary Bedell Newbie

                                  For what it's worth, the SystemPropertiesService MBean from JBoss 4.2.3 can be forward-ported to JBoss 7.x with minimal effort.  We've got this running (I think, running into other deployment issues yet).  Stuffed a copy of it on Gist if anyone wants to play with it.  We'll probably assemble our hacks for 4.2/7.1 co-existance once I get everything working.

                                   

                                  https://gist.github.com/3763412

                                  • 14. Re: Set properties file in jboss7
                                    neils666 Newbie

                                    Thanks for that @Zachary Bedell - using it fine.

                                     

                                    One question though, why is there a module.xml? Are you using it as a module? I tried but it doesn't start up automatically.

                                    To get it to auto-start I've had to deploy it as a .sar in the usual deployments directory - your example shows it as a .jar.

                                     

                                    Not really a problem, just curious.

                                    1 2 Previous Next