6 Replies Latest reply on Oct 3, 2012 1:07 AM by srinivas.bijjam

    accessing custom created datasources in JBOSS 7.1

    srinivas.bijjam

      Greetings of the day

      Generally we define the datasource in standalone.xml and then we will use the same in the application code based on JNDI Name and this is working fine for me. But we have a peculiar functionality where in we create the custom datasources through our application and then create the datasource xml with custom names like oracle.Host_Name-ds.xml, sqlserver.Host_Name-ds.xml, mysql.Host_Name-ds.xml,oracle.Host_Name1-ds.xml etc etc and we use this datasources to connect

              String dsName = oracle.Host_Name;  try { javax.sql.DataSource ds = DataSourceHelper.getDataSource(dsName);  conn = ds.getConnection(); } 

      in JBOSS 4.x we used to create these files on fly(through application) and store them in application server/server/default/deploy folder and we used to access the data source with out any problem.

      In JBoss 7.X, how to bind the created datasources so that we will access them without change in the code. I don't want to change the code because there are so many instances where we are using it and also it will impact other functionality

      Regards Srini

        • 1. Re: accessing custom created datasources in JBOSS 7.1
          wdfink

          I see two issues with that approach.

          First is that write to the filesystem will break the EE specification.

          The other one is that *-ds.xml files are not recommended to use, instead of development environment.

           

          Nevertheless you might store the datasource file in the standalone/deployment folder and it will be deployed automaticaly. But the behavior might be different, i.e. timing of the availibility etc..

          • 2. Re: accessing custom created datasources in JBOSS 7.1
            srinivas.bijjam

            Hi Fink

                 Any work around solution for this?

                Our's is data optimising application where in we get the data from different data sources and then do some business functionality on this data. User creates the data sources through the web application that is deployed on this JBOSS 7.1 Server. Once the user creates the datasource related info like(data source url, user id , password etc etc) we will create respective ds.xml file and stores in deployment folder. In JBOSS 4.x, we used to access these xml's with out any problem.

               If we write to deployment folder, server is trying to deploy these file's also

             

            Regards

            Srini

            • 3. Re: accessing custom created datasources in JBOSS 7.1
              wdfink

              If you are happy with that you might try it and use the standalone/deployment folder for your ds files (or add a new deploment folder in the configuration).

               

              The issue is that you are not able to do so in a cluster and the behavior might different or not possible in other versions or different AS server.

              1 of 1 people found this helpful
              • 4. Re: accessing custom created datasources in JBOSS 7.1
                srinivas.bijjam

                Hi Fink

                   How can I restrict (or ask) server to deploy only the ear file and ignore the rest of the files in the deployment folder?

                • 5. Re: accessing custom created datasources in JBOSS 7.1
                  wdfink

                  You might add a new folder to the subsystem deployment-scanner

                  <deployment-scanner name="MyDS" path="deployments-ds" relative-to="jboss.server.base.dir" scan-interval="5000" auto-deploy-zipped=="false" auto-deploy-exploded="false"/>

                  also yo can set auto-deploy-xml (but this is true by default).

                   

                  I'm not sure whether this avoid all possibilities but you might also use that folder only for your *-ds.xml.

                  • 6. Re: accessing custom created datasources in JBOSS 7.1
                    srinivas.bijjam

                    I got the problem solved.

                    Just keep the ds.xml files in deployments folder and automatically binding will happen once these files get deployed.

                    You need to keep only the files which are required to get deployed and others you can remove from the deployment folder and add them in config or module folders

                    1 of 1 people found this helpful