4 Replies Latest reply on Jun 8, 2003 11:02 AM by irfan_a

    Jboss 3.0 Oracle 8i Connection Issue

    irfan_a

      I am new to jboss, working on deploying and running a small test application using Jboss 3.0 and Oracle 8i. It simply consists of one session bean and a client class to test session bean. I have copied the classes12.zip file in %JBOSSHOME%\server\default\lib and appropriately edited oracle-service.xml, login-config.xml files for my Oracle database. The session bean (named Contact) creates an instance of dataSource and attempts to create a connection with following function call:

      con = dataSource.getConnection();

      This results in following error:

      20:46:03,513 INFO [STDOUT] SQLException: Could not create connection; - nested
      throwable: (java.sql.SQLException: invalid arguments in call); - nested throwabl
      e: (org.jboss.resource.JBossResourceException: Could not create connection; - ne
      sted throwable: (java.sql.SQLException: invalid arguments in call)):null
      20:46:03,523 INFO [STDOUT] from ContactBean

      In desperation, I tried to connect with following call and it worked
      con = dataSource.getConnection(username, password);

      I am not using jboss.xml because i have read somewhere that this file is not required unless there is vendor specific configuration.

      I am using following (ejb-jar.xml) descriptor for the session bean

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

      <ejb-jar>
      Simple application
      <display-name>Data Access Application</display-name>
      <enterprise-beans>

      <ejb-name>Contact</ejb-name>
      com.javapro.ejb.ContactHome
      com.javapro.ejb.Contact
      <ejb-class>com.javapro.ejb.ContactBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Bean</transaction-type>

      </enterprise-beans>
      </ejb-jar>

      I would appreciate if any one can give me some clues why my connection is not established without passing username and password as parameters.

      Thanks,
      Irfan

        • 1. Re: Jboss 3.0 Oracle 8i Connection Issue
          jonlee

          Most likely the issue is somewhere in the *-service.xml or the login-config.xml. Post these so the folks here can analyse the datasource definitions.

          • 2. Re: Jboss 3.0 Oracle 8i Connection Issue
            irfan_a

            Here are the two files, oracle-service.xml and login-config.xml

            1) oracle-service.xml

            <?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.
            -->

            <!--uncomment out this line if you are using the OracleDbRealm above
            OracleDbRealm
            -->

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


            OracleDS



            <config-property name="ConnectionURL" type="java.lang.String">jdbc:oracle:thin:@localhost:1521:orcl8i</config-property>
            <!--

            Here are a couple of the possible OCI configurations.
            For more information, see http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/toc.htm

            <config-property name="ConnectionURL" type="java.lang.String">jdbc:oracle:oci:@youroracle-tns-name</config-property>
            or
            <config-property name="ConnectionURL" type="java.lang.String">jdbc:oracle:oci:@(description=(address=(host=youroraclehost)(protocol=tcp)(port=1521))(connect_data=(SERVICE_NAME=yourservicename)))</config-property>

            Clearly, its better to have TNS set up properly.
            -->
            <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"></config-property>
            <config-property name="Password" type="java.lang.String"></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-->


            0
            50
            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:service=JaasSecurityManager

            java:/TransactionManager

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








            2) login-config.xml

            <?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.
            -->

            <!--uncomment out this line if you are using the OracleDbRealm above
            OracleDbRealm
            -->

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


            OracleDS



            <config-property name="ConnectionURL" type="java.lang.String">jdbc:oracle:thin:@localhost:1521:orcl8i</config-property>
            <!--

            Here are a couple of the possible OCI configurations.
            For more information, see http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/toc.htm

            <config-property name="ConnectionURL" type="java.lang.String">jdbc:oracle:oci:@youroracle-tns-name</config-property>
            or
            <config-property name="ConnectionURL" type="java.lang.String">jdbc:oracle:oci:@(description=(address=(host=youroraclehost)(protocol=tcp)(port=1521))(connect_data=(SERVICE_NAME=yourservicename)))</config-property>

            Clearly, its better to have TNS set up properly.
            -->
            <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"></config-property>
            <config-property name="Password" type="java.lang.String"></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-->


            0
            50
            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:service=JaasSecurityManager

            java:/TransactionManager

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





            • 3. Re: Jboss 3.0 Oracle 8i Connection Issue
              jonlee

              From your example, it doesn't seem like you are using JAAS to define the username and password for your pools. If you want just default logins for your connection pool, set them up in your *-service.xml.

              e.g.
              <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">mydbusername</config-property>
              <config-property name="Password" type="java.lang.String">mydbpassword</config-property>


              Fill these in, and all your connections in the pool will be pre-logged in with this username/password combination.

              3.2.x is less confusing with respect to this configuration.

              • 4. Re: Jboss 3.0 Oracle 8i Connection Issue
                irfan_a

                Yes you are right, I am not using JAAS. I tried the change suggested by you and it worked. So the issue is solved and I thank you very much for your advice and your time.