1 Reply Latest reply on Sep 12, 2002 10:41 PM by vrotaru

    Oracle Connection Pool

    sreynol

      I am porting a web application from weblogic 5.1 to JBoss 3.0.2 that uses Oracle 8i (8.1.7). I am using the example oracle-service.xml, which I have modified to use my connection pool named PCNPool:

      <?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=PCNPool</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-->


      DefaultDS



      <config-property name="ConnectionURL" type="java.lang.String">jdbc:oracle:thin:@picard:1521:msgcdb</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">jimbob</config-property>
      <config-property name="Password" type="java.lang.String">pwjimbob</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




      I am trying to lookup the DataSource associated with the connection pool by doing the following:

      // First, get the context
      ctx = ContextFactory.getInitialContext();

      // Next, lookup the DataSource
      DataSource ds = (DataSource) ctx.lookup( "DefaultDS" );

      This gives me the following error:

      16:23:29,907 WARN [NamingContext] Failed to connect to //localhost:1099
      javax.naming.CommunicationException: Failed to connect to server //localhost:1099. Root exception is
      javax.naming.ServiceUnavailableException: Failed to connect to server //localhost:1099. Root exception is
      java.net.UnknownHostException: //localhost
      at java.net.InetAddress.getAllByName0(InetAddress.java:571)
      at java.net.InetAddress.getAllByName0(InetAddress.java:540)
      at java.net.InetAddress.getByName(InetAddress.java:449)
      at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:61)
      at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:156)
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1006)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:447)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:440)
      at javax.naming.InitialContext.lookup(InitialContext.java:350)
      at mind.pcn.common.domain.DBConnector.getDataSource(DBConnector.java:78)
      at mind.pcn.common.domain.DBConnector.getDataSource(DBConnector.java:51)
      at mind.pcn.common.domain.DBConnector.getDBConnection(DBConnector.java:101)
      at mind.pcn.common.domain.Role.(Role.java:184)
      at mind.pcn.common.domain.ScreenAccess.(ScreenAccess.java:44)
      at mind.pcn.common.struts.LoginAction.populateSession(LoginAction.java:197)
      at mind.pcn.common.struts.LoginAction.perform(LoginAction.java:124)
      at mind.pcn.common.struts.PCNAction._doPerform(PCNAction.java:351)
      at mind.pcn.common.struts.ActionServlet.processActionPerform(ActionServlet.java:41)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1536)
      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:344)
      at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:313)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:554)
      at org.mortbay.jetty.servlet.WebApplicationHandler.handle(WebApplicationHandler.java:199)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1572)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1522)
      at org.mortbay.http.HttpServer.service(HttpServer.java:795)
      at org.jboss.jetty.Jetty.service(Jetty.java:531)
      at org.mortbay.http.HttpConnection.service(HttpConnection.java:784)
      at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:941)
      at org.mortbay.http.HttpConnection.handle(HttpConnection.java:799)
      at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:186)
      at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:322)
      at org.mortbay.util.ThreadPool$JobRunner.run(ThreadPool.java:716)
      at java.lang.Thread.run(Thread.java:484)


      This code worked under Weblogic, so I am thinking that it is just a problem with the configuration in oracle-service.xml or jboss-service.xml. If I point my browser to http://localhost:1099, I can tell that the nameserver is up and running, so I don't know why it says that it can't connect to the server.

      Also, when the server is starting and it deployes oracle-service.xml, it doesn't ever say that it is bound.

      16:19:05,547 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss-3.0.2/server/default/deploy/oracle-service.xml
      16:19:05,847 WARN [ServiceController] jboss.jca:service=LocalTxDS,name=PCNPool does not implement any Service methods
      16:19:06,058 INFO [JBossManagedConnectionPool] Creating
      16:19:06,058 INFO [JBossManagedConnectionPool] Created
      16:19:06,058 INFO [JBossManagedConnectionPool] Starting
      16:19:06,058 INFO [JBossManagedConnectionPool] Started
      16:19:06,058 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.0.2/server/default/deploy/oracle-service.xml

      If I look at the jmx-console, under the jboss.jca section, I can see the connection pool (PCNPool):
      jboss.jca
      service=LocalTxPool,name=PCNPool
      service=XaTxPool,name=jmsra
      service=RARDeployment,name=JMS Adapter
      service=LocalTxDS,name=PCNPool
      service=XaTxDS,name=jmsra
      service=LocalTxCM,name=PCNPool
      service=XaTxCM,name=jmsra
      service=CachedConnectionManager
      service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper
      service=RARDeployment,name=Minerva JDBC XATransaction ResourceAdapter
      service=RARDeployer

      The database is running on a different machine than the JBoss server. I have confirmed that the DB server name, port number, DB name, username/password are correct.

      I would appreciate any help. Let me know if I didn't include enough info.

      Thanx in advance,
      steve