6 Replies Latest reply on May 20, 2002 7:26 AM by Andy Blanchard

    Specify DB connection info in EAR?

    Andy Blanchard Newbie

      I'm using JBoss 3.0 RC2.

      Is it possible to specify a database connection pool within an EAR? I have everything working now using /deploy/oracle-service.xml. I'd really love to be able to embed the connection spec within the app's EAR and not have to worry about configuring the container.

      Possible? Impossible?

      Thanks,
      Andy

        • 1. Re: Specify DB connection info in EAR?
          David Jencks Master

          I haven't tried it, but it should be possible to make a .sar containing no classes, just META-INF/jboss-service.xml (the renamed oracle-service.xml) and put it in the .ear. It may be necessary to put it in an ejb-jar file in order to make it deploy before the ejb's that use it.

          Please report on how this works.

          • 2. Re: Specify DB connection info in EAR?
            Andy Blanchard Newbie

            OK, I tried this. Unfortunately it looks like JBoss is deploying the EJB JAR before binding the services specified in jboss-service.xml. I even tried to include the /META-INF/jboss-service.xml in the EJB JAR file, but it seems like JBoss ignores it there.

            My SAR looks like this:

            jboss-example-ejb.jar
            mm.mysql-2.0.13-bin.jar
            META-INF/jboss-service.xml
            META-INF/Manifest.mf

            The error I get is:

            javax.naming.NameNotFoundException: MySqlDS not bound

            How can I force JBoss to load the MySqlDS service before the EJB JAR?

            • 3. Re: Specify DB connection info in EAR?
              David Jencks Master

              packages are loaded inside-out.

              You could use mbean dependencies from each ejb to the connection manager to make them wait, but I think it is simpler to do this, at least if you have only one ejb-jar:

              jboss-example-ejb.jar
              (ejb classes)
              embedded-service.sar
              mm.mysql-s.0.13-bin.jar
              META-INF
              jboss-service.xml
              META-INF
              ejb-jar.xml
              jboss.xml
              etc.

              This would have worked the last time I worked on the deployment code. Hopefully it still will.

              • 4. Re: Specify DB connection info in EAR?
                Darryl Thompson Newbie

                Hi Andy,
                I have JBoss3 RC2 and I have not been able to get a good oracle-service.xml file (mine's gets exception because it find JassSecurityManagerService). I have read a lot of threads where many people seem to be having problems finding a working oracle-service.xml file and there appears to be more than one "flavor" of oracle-service.xml file circulating on the threads posted. Could I have a look at yours (a real working version minus the user/pswd etc.), it would really help cut through the drama of connecting to an oracle database.
                It would be great if the downloads contained a working xml file for the more popular databases out there.


                Thanks

                • 5. Re: Specify DB connection info in EAR?
                  David Jencks Master

                  Did you look at docs/examples/jca? If these don't work with rc2 I would like to know about it. Generally the problems I have seen are when people take a rc2 file and try to use it with 3.0 alpha or vice versa.

                  • 6. Re: Specify DB connection info in EAR?
                    Andy Blanchard Newbie

                    Sure. Here's a copy of my oracle-services.xml file:

                    <?xml version="1.0" encoding="UTF-8"?>

                    <!-- ===================================================================== -->
                    <!-- -->
                    <!-- JBoss Server Configuration -->
                    <!-- -->
                    <!-- ===================================================================== -->



                    <!-- ==================================================================== -->
                    <!-- ConnectionManager setup for Oracle dbs -->
                    <!-- Build jmx-api (build/build.sh all) and view for config documentation -->
                    <!-- Thanks to Steven Coy -->
                    <!-- ==================================================================== -->




                    <!-- Include a login module configuration named OracleDbRealm.
                    Update your login-conf.xml, here is an example for a
                    ConfiguredIdentityLoginModule:

                    <application-policy name = "OracleDbRealm">

                    <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
                    <module-option name = "principal">yourprincipal</module-option>
                    <module-option name = "userName">yourusername</module-option>
                    <module-option name = "password">yourpassword</module-option>
                    <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=OracleDS</module-option>
                    </login-module>

                    </application-policy>

                    NOTE: the application-policy name attribute must match SecurityDomainJndiName, and the
                    module-option name = "managedConnectionFactoryName"
                    must match the object name of the ConnectionManager you are configuring here.
                    -->
                    <!--comment out this line if you want component managed security or want
                    to use the default values in the ManagedConnectionFactoryProperties -->
                    <!--
                    OracleDbRealm
                    -->

                    <depends optional-attribute-name="ManagedConnectionFactoryName">
                    <!--embedded mbean-->


                    OracleDS



                    <config-property name="ConnectionURL" type="java.lang.String">jdbc:oracle:thin:@123.123.123.123:1521:test</config-property>
                    <config-property name="DriverClass" type="java.lang.String">oracle.jdbc.driver.OracleDriver</config-property>
                    <!--set these only if you want only default logins, not through JAAS -->
                    <config-property name="UserName" type="java.lang.String">andy</config-property>
                    <config-property name="Password" type="java.lang.String">mypassword</config-property>




                    <!--Below here are advanced properties -->
                    <!--hack-->
                    <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper



                    <depends optional-attribute-name="ManagedConnectionPool">
                    <!--embedded mbean-->


                    2
                    10
                    5000
                    15
                    <!--criteria indicates if Subject (from security domain) or app supplied
                    parameters (such as from getConnection(user, pw)) are used to distinguish
                    connections in the pool. Choices are
                    ByContainerAndApplication (use both),
                    ByContainer (use Subject),
                    ByApplication (use app supplied params only),
                    ByNothing (all connections are equivalent, usually if adapter supports
                    reauthentication)-->
                    ByContainer



                    <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager

                    <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:name=JaasSecurityManager

                    java:/TransactionManager

                    <!--make the rar deploy! hack till better deployment-->
                    jboss.jca:service=RARDeployer