4 Replies Latest reply on Nov 20, 2010 12:32 PM by wdfink

    Provide one datasource with two different JNDI names

    wdfink

      I've two application ear with a persistence.xml point to a different jta-data-source.

      The EARs should not be changed, but in the deployment both applications should use the same DB schema, and for sure the same connection pool.

       

      Is it possible to create such simple link via an extra deployment file or adding alias to the datasource ds.xml file?

        • 1. Re: Provide one datasource with two different JNDI names
          jaikiran

          Yes, that's possible:

          <?xml version="1.0" encoding="UTF-8"?>
          <server>
              <mbean code="org.jboss.naming.NamingAlias"
                  name="org.myapp:alias=myDSAlias">
                  <attribute name="FromName">aliasJNDIName</attribute>
                  <attribute name="ToName">java:DefaultDS</attribute>
              </mbean>
          
          </server>
          
          • 2. Re: Provide one datasource with two different JNDI names
            wdfink

            Well I think I understand something wrong.

             

            My example:

            drop DefaultDS (the hsqldb connector)

            create a new Oracle datasource with name 'MyDatasource'

            --> here the start of ejbtimer failed because of missing DefaultDS

            create a file alias-service.xml (example from last post)

            --> the DefaultDS is still not available

             

            What is wrong? Must I set some dependencies?

            • 3. Re: Provide one datasource with two different JNDI names
              jaikiran

              I misunderstood your first question then. The NamingAlias just creates a LinkRef for a source to target jndi name.

               

              From what I see in your latest post, you are trying something different. The DefaultDS does some other things that just binding to JNDI at java:DefaultDS. For example, there are multiple MBeans which are created using the "DefaultDS" as the name for those services. And then there are numerous other services which depend on the name of this DefaultDS MBeans. So in your case, when you drop the DefaultDS in favour of the MyDataSource name, you have to make sure that the dependent MBeans also you this new name to depend on.

               

              This wiki http://community.jboss.org/wiki/ChangeDefaultDataSource has the details of which exact files need to be changed.

              • 4. Re: Provide one datasource with two different JNDI names
                wdfink

                Mmmh,

                what I want to is to have one Datasource with two different names for full compatible EJB2, EJB3 persistence and other plain JDBC access via pool.

                This is because of orchestring applications from different suppliers, we don't have the permission to change the EAR descriptor.

                 

                Remove the DefaultDS was only experimental to have a default installation without complex application.