4 Replies Latest reply on Jun 26, 2006 10:51 AM by Carsten Hoehne

    DataSource configuration at runtime

    Carsten Hoehne Master

      Hello, i do have a question about microcontainer and seam managed sessions. Please have a look at:
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=85491
      Can anybody help me out?
      Ciao,
      Carsten

        • 1. Re: DataSource configuration at runtime
          Thomas Heute Master

          This sounds very wrong to me that you deploy then copy a war file or that you define the datasource *after* the deployment.

          Didn't you mean "package" instead of deploy ?

          • 2. Re: DataSource configuration at runtime
            Carsten Hoehne Master

            Hello,
            yes you are right, i have used the wrong wording. here is the correction
            By now, for every targetsystem i do this:
            1. edit jboss-bean.xml
            2. package the app (run Ant build script)
            3. copy the resulting war to the right system

            But what i need is:
            1. package the app (run Ant build script)
            2. copy the war to all target systems
            3. configure the right database into the app after deployment

            define the datasource *after* the deployment.


            Before using seam, i used a datasource provided by Tomcat.

            i was used to specify my datasource in file context.xml in the META-INF Directory in my app.
            So i can edit /conf/Catalina/localhost/baz.xml after deployment.
            But now i am using the microcontainer and can not make any use of a tomcat provided datasource. Am i right?
            Ciao,
            Carsten


            • 3. Re: DataSource configuration at runtime
              Thomas Heute Master

              You need to use the JNDI tree of Tomcat for the datasource then (and keep JBoss JNDI for everything else)

              The easiest way to do (if you are using one of the Seam example as skeleton) is to configure in:
              ./embedded-ejb/conf/default.persistence.properties

              those 2 keys:
              hibernate.jndi.java.naming.factory.initial
              hibernate.jndi.java.naming.factory.url.pkgs
              to the tomcat JNDI values. Deleting those 2 keys should actually work just fine.

              • 4. Re: DataSource configuration at runtime
                Carsten Hoehne Master

                Hello Thomas,
                so i have to use embeddable ejb?
                At the moment i use seam managed sessions as introduced with the example 'hibernate' (the derivate from the hotel booking example)

                If i use embeddablke EJB as suggested, how to inject the transaction manager into a datasource provided by Tomcat?

                from jboss-beans.xml:
                 <property name="transactionManager"><inject bean="TransactionManager"/></property>


                If there is no easy solution for my environment i have and will live with the little inconvinience to package my app once for every database. (Concrete: I have to write an anttask for changing the attribute connectionUrl in jboss-beans.xml inside a war and than deploy this war to tomcat. )
                Ciao,
                Carsten