5 Replies Latest reply on Sep 19, 2002 10:43 AM by augustynr

    Can not get Oracle Connection NO ERRORS!

    augustynr

      Hi,
      I have looked through this forum and through all docs ( I got a yearly subscription :) ) and I still can not get to get a connection from oracle.
      Hope that one of you can help.
      I am running JBoss and Oracle 8.1.7 on a different servers.
      This is what I did so far:
      1. Copy the "classes12.jar" to the "jboss/server/default/lib" catalog. (the Oracle JDBC driver)

      2. Copy the "nls_charset12.jar" to the "jboss/server/default/lib" catalog. (Oralce language package)

      4. Copy the "jboss/docs/examples/jca/oracle-service.xml" file into the "jboss/server/default/deploy" catalog.

      5. Edit the file "jboss/server/default/deploy/oracle-service.xml":
      In the "OracleRealm" block
      <blabla..."UserName">yourOralceLogin</module-option>
      <blabla..."password">yourOraclePass</module-option>

      In the "ManagedConnectionFactoryProperties" block:
      <config-property name="ConnectionURL" type="java.lang.String">jdbc:oracle:thin@129.225.88.88:1521:MySid</configure-property>

      <blabla...UserName"...>yourOracleLogin</config-property>
      <blabla...password"...>yourOraclePass</config-property>


      6. Edit the the first lines in the file "jboss/server/default/conf/standardjaws.xml":


      java:/OracleDS
      <type-mapping>Oracle8</type-mapping>
      false
      .
      .
      . public CM3RM1 getCm()
      {
      Context jndiContext ;
      DataSource datasource=null;


      try{
      Context ic = getInitialContext();
      datasource = (DataSource) ic.lookup("java:/OracleDS");
      } catch(NamingException name) { System.out.println(name.toString());}
      try{
      Connection conn = datasource.getConnection();
      System.out.println("Got datasource "+conn.getCatalog());

      cm.setNUMBERPRGN(1423);
      cm.setConnection(conn);
      cm.getRow();

      System.out.print("Done.");
      cm.setConnection(null);

      }catch(SQLException sqlex){
      sqlex.printStackTrace();
      cm.setCATEGORY(sqlex.toString());
      }
      return cm;
      }


      private static Context getInitialContext() throws NamingException
      {
      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.put(Context.SECURITY_PRINCIPAL, "admin");
      env.put(Context.SECURITY_CREDENTIALS, "welcome");
      env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
      return new InitialContext(env);
      }

      Now when I execute getCm from my client app I go not get any error but I get NO connection either!
      I do not get any errors in the server logs when app server starts and it looks like it inits the pool ( I may be wrong )
      What possibly may be wrong? I should get some kind of an error but I do not! I have no problem accessing a bean from the remote client.
      Thanks in advance for your help.

        • 1. Re: Can not get Oracle Connection NO ERRORS!
          joelvogt

          So you can deploy and use ejbs using your datasource but not get a connection to it manually? Is this correct?

          • 2. Re: Can not get Oracle Connection NO ERRORS!
            augustynr

            Joel,
            I am able to deploy ejbs. No I would like to access the Oracle from that deployed ejb.
            I am able to access my ejb but my ejb cannot find Oracle :)
            This is a piece of a client I use to test this:

            public static void main(String [] args)
            {
            hrAppClient HrAppClient = new hrAppClient();
            try
            {
            Context context = getInitialContext();
            hrAppHome HrAppHome = (hrAppHome)PortableRemoteObject.narrow(context.lookup("hrApp"), hrAppHome.class);
            hrApp HrApp;

            // Use one of the create() methods below to create a new instance
            HrApp = HrAppHome.create( );
            HrApp.setCompany( "Company");
            System.out.println(HrApp.getCompany( ));
            CM3RM1 cm = HrApp.getCm();

            System.out.println(cm.getNUMBERPRGN());
            System.out.println(cm.getCATEGORY());
            System.out.println(HrApp.getCompany( ));
            }
            catch(Throwable ex)
            {
            ex.printStackTrace();
            }
            }

            private static Context getInitialContext() throws NamingException
            {
            Hashtable env = new Hashtable();
            env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
            env.put(Context.SECURITY_PRINCIPAL, "admin");
            env.put(Context.SECURITY_CREDENTIALS, "welcome");
            //env.put(Context.PROVIDER_URL, "ormi://localhost:23891/hr");
            env.put(Context.PROVIDER_URL, "jnp://192.61.102.44:1099/");

            return new InitialContext(env);
            }

            • 3. Re: Can not get Oracle Connection NO ERRORS!
              augustynr

              Update,
              I have a debug statement in the server.log:
              2002-09-19 01:37:39,644 DEBUG [org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory] Driver not yet registered for url: jdbc:oracle:thin:@129.225.82.78:1521:unnservd

              How to resolv this?
              This happend after I added back a hsqldb-service.xml to ./deploy directory.
              Thanks.
              robert

              • 4. Re: Can not get Oracle Connection NO ERRORS!
                joelvogt

                In your "ManagedConnectionFactoryProperties" block: do you have something like

                <config-property name="DriverClass" type = "java.lang.String">
                com.oracle.JDBCDriver(your driver class)</config-property>

                ?

                • 5. Re: Can not get Oracle Connection NO ERRORS!
                  augustynr

                  Joel,
                  Yes I do.
                  I am attaching a copy of oracle-service.xml.
                  Thanks again for taking the time.


                  <?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:@129.225.82.78:1521:unnservd</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">scadmin</config-property>
                  <config-property name="Password" type="java.lang.String">service</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
                  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