10 Replies Latest reply on Nov 16, 2010 9:47 AM by rossog

    jBoss folders in classpath?

    bmelloni

      What are the jBoss' folders that are exposed to apps in the classpath?

       

      I thought that server/<enviroment>/conf and server/<enviroment>/lib were among them, but the application is having trouble reading the file when I use specificy it as being at "classpath:<filename>.xml".

       

      I am not a jBoss beginner, but this was clearly a beginner question... so I placed it in this forum

        • 1. Re: jBoss folders in classpath?
          jaikiran

          Bruno Melloni wrote:

           

           

          I thought that server/<enviroment>/conf and server/<enviroment>/lib were among them, but the application is having trouble reading the file when I use specificy it as being at "classpath:<filename>.xml".

           

           

          If you have placed a xyz.xml file in JBOSS_HOME/server/< servername>/conf folder (which is by default in the classpath) then in your java code, you can do this:

           

          InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("xyz.xml"); 
          
          • 2. Re: jBoss folders in classpath?
            rossog

            I'm interested in this too.

            I wold like to keep jboss conf and application conf separeted, so my aim is to add a new folder, let's say server/<enviroment>/properties, to the classpath.

            Is there a way to deal with it?

            Thanks

            • 3. Re: jBoss folders in classpath?
              rossog

              My version is JBoss 5.1 (ie RedHat release).

              • 4. Re: jBoss folders in classpath?
                wdfink

                So what I do is to separate lib and deploy:

                conf/jboss-service.xml:

                <service>

                  <classpath codebase="${jboss.common.lib.url}" archives="*"/>
                   <classpath codebase="applib" archives="*"/>c

                  <classpath codebase="${jboss.common.lib.url}" archives="*"/>

                   <classpath codebase="applib" archives="*"/>

                 

                conf/bootstrap/profile.xml (also farm will be found here but we do not use it):

                      <property name="applicationURIs">

                         <list elementClass="java.net.URI">

                            <value>${jboss.server.home.url}deploy</value>

                            <value>${jboss.server.home.url}appdeploy</value>

                         </list>

                      </property>

                To separate the conf directory I suppose to find something like '${jboss.server/home.url}/home' or ${jboss.server.config.url} but I don't find something.
                Also a look into the sources does not offer a configuration parameter for this.
                So I'm also interested to find it out.


                 

                1 of 1 people found this helpful
                • 5. Re: jBoss folders in classpath?
                  bmelloni

                  Interesting Wolf-Dieter.  Looks like a clean solution.

                   

                  At our company we do what jBoss support suggested years ago:  We put our common library JARs in a .SAR.  That way they are exposed to all of the other applications, so that you don't need to add them to the applications ./lib or ./WEB-INF/lib.

                   

                  We also create .SAR projects for heavily reused integration interface applications (like the code used to interface to our General Ledger app).  It keeps the code (and its configuartion property and .xml files) neatly contained in one app, but is accessible "as a library" to all of the other apps that need it.

                   

                  We only put things in server/<env>/conf or server/<env>/lib when we want jBoss itself to see something - which is extremely rare.

                   

                  The original post was caused by something in .../conf apparently not being seen by jBoss, but we discovered that it was unrelated and simply caused by the difference on how jBoss handles deployment of things in .../deploy and .../deploy-hasingleton.

                  • 6. Re: jBoss folders in classpath?
                    rossog

                    @Bruno Melloni: could you explain it a little further? Let's say I have a library heavily used by different webapps (IE, Logging Interceptors). This library needs a configuration file which I want to keep outside the jar itself, and outside server/<nameserver>/conf folder.

                    How would you deal with that file?

                    Thanks.

                    • 7. Re: jBoss folders in classpath?
                      bmelloni

                      We normally would just put that library's configuration file in the .SAR, right next to the .jar of the library.

                       

                      Here are some details of what we do:

                       

                      • To keep our applications separate for jBoss' components we place all of our deployed applications in server/<env>/deploy/CustomApps.  (just create the folder, jBoss will treat them as if they were in ./deploy)
                      • In CustomApps we have an OpenSourceLibs.sar.  It contains a minimal META-INF/jboss-service.xml (<server/>) and all of the open source libraries that we use and are not supplied by jBoss already (various apache commons jars, spring and its dependencies, etc).  Because of how jBoss works, all of these assets are by default in our other apps classpath and we don't need to add them to their lib folders.
                      • Also in CustomApps we have a GeneralLedgerIF.sar that contains again a minimal META-INF/jboss-service.xml, generalledgerIF.jar and generalledgerIFContext.xml (the spring context for the general ledger interface).  Since jBoss exposes these in the classpath, an application that needs to interface with the general ledger can load a spring bean from generalledgerIFContext.xml or make a method call to a class in gneralledgerIF.jar... without having any of it in the .../lib folder of the app.
                      • If for some *rare* reason a given app (say a Billing to General Ledger integration app - B2GL for short) needs to use a different version of libraries, jboss has options in jboss-web.xml that allow you to ensure that those "wrong version" libraries in B2GL are not seen by any other application, and that B2GL uses its own version of the libraries instead of the ones in the "shared" .sars.  I won't go into those jboss-web.xml options... as they are quite complex and well documented by jBoss.
                      • 8. Re: jBoss folders in classpath?
                        wdfink

                        But (AFAIK) .SAR files are JBoss specific and not always JEE compliant.

                        • 9. Re: jBoss folders in classpath?
                          bmelloni

                          Of course .SAR files are jBoss specific, just like the server/<environment>/conf and server/<environment>/lib folders.  It is just a deployment strategy that is clean and easy to manage.

                           

                          In Tomcat (which I use for development because of its much faster start) I create an OpenSourceLibs subfolder of the server's lib folder and modify its configuration files so that it recognizes it.  In that subfolder I put the exact same contents that I put in the jBoss OpenSourceLibs.sar.

                          • 10. Re: jBoss folders in classpath?
                            rossog

                            Ok, I managed to deal with it.

                            This is basically what I did:

                            • create a sar folder, with all my jar, as suggested by Bruno Melloni
                            • create a META-INF/jboss-service.xml in it, containing a new classpath:

                            <service>

                                <classpath codebase='.' archives='*' />

                            </service>

                            • in META-INF/ I also put all my *.properties files

                            This way it looks like everything is fine.

                            Thank you all for your help, hope this solution helps someone else too.