10 Replies Latest reply on Feb 7, 2003 3:47 PM by Michael Schoning

    getting an oracle datasource

    Michael Schoning Newbie

      Hi I am trying to lookup an oracle datasource, there are several listing here on how to set it up. But I must be missing something as I can make it work. I am using JBoss 3.0.3 on W2K.

      First I added my oracle connection url and username password to the oracle-service.xml that I found in <jboss-home>/docs/examples/jca. I copied this file to <jboss-home>/server/default/deploy

      Then I copied my classes12.zip to <jboss-home>/server/default/lib I have tried having this file named both classes12.zip and classes12.jar without any difference (using ntfilemon I can see that the file is read when I start Jboss using either name)


      When looking at this page http://localhost:8080/jmx-console/index.jsp
      I can find my datasource and its jndi name which is the default i.e. OracleDS

      I am trying to access my datasource from a standalone application so I get my initial context like this:

      Hashtable props = new Hashtable();
      props.put(InitialContext.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      props.put(InitialContext.PROVIDER_URL,"jnp://127.0.0.1:1099");
      initialContext = new InitialContext(props);

      If I lookup like this:
      DataSource ds = (DataSource) initialContext.lookup("java:/OracleDS");

      I get this exception:
      javax.naming.ConfigurationException: Name space accessor for the java: name space has not been set. Possible cause is that the user is specifying a java: URL name in a JNDI Context method call but is not running in a J2EE client or server environment.
      at com.ibm.ws.naming.java.javaURLContextFactory.isNameSpaceAccessable(javaURLContextFactory.java:98) ...

      If I lookup like this:
      DataSource ds = (DataSource) getContext().lookup("OracleDS");

      I get this exception:
      javax.naming.NameNotFoundException: OracleDS not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
      ....

      My oracle-service.xml file looks like this:
      <?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">oracle:thin:@oracleserver:1521:XXXX</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">donald</config-property>
      <config-property name="Password" type="java.lang.String">duck</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






      Sorry for such a long listing,
      Michael