0 Replies Latest reply on Sep 27, 2005 12:04 PM by wizzu

    Upgrade 3.2.5 to 3.2.7 results in broken DataSources (Naming

    wizzu

      Hello,

      We have a server application that runs under JBoss 3.2. We've been using 3.2.5 successfully for a year now, but thought it would be time to upgrade (don't laugh - we like things stable) to 3.2.7. The problem is, the exact same configuration which works under 3.2.5 fails to do so under 3.2.7.

      The error is that the application can't locate it's datasources:

      javax.naming.NameNotFoundException: mobicus_management_poolDS not bound
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:490)
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:498)
       at org.jnp.server.NamingServer.getObject(NamingServer.java:504)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:277)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:606)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:568)
       at javax.naming.InitialContext.lookup(InitialContext.java:347)
       at com.mobicus.core.config.jboss3_2.DBPool.<init>(DBPool.java:77)
      ...
      


      Here's the DS configuration file (yes, there's two connection pools):

      <datasources>
       <local-tx-datasource>
       <jndi-name>mobicus_messaging_poolDS</jndi-name>
       <connection-url>jdbc:oracle:thin:@ORACLE:1521:ORACLE</connection-url>
       <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
       <user-name>user</user-name>
       <password>****</password>
       <min-pool-size>5</min-pool-size>
       <max-pool-size>100</max-pool-size>
       <!-- idle-timeout-minutes>0</idle-timeout-minutes -->
       <new-connection-sql>select 1 from dual</new-connection-sql>
       <check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
       <!-- track-statements/ -->
       </local-tx-datasource>
       <local-tx-datasource>
       <jndi-name>mobicus_management_poolDS</jndi-name>
       <connection-url>jdbc:oracle:thin:@ORACLE:1521:ORACLE</connection-url>
       <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
       <user-name>user</user-name>
       <password>****</password>
       <min-pool-size>5</min-pool-size>
       <max-pool-size>30</max-pool-size>
       <!-- idle-timeout-minutes>0</idle-timeout-minutes -->
       <new-connection-sql>select 1 from dual</new-connection-sql>
       <check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
       <!-- track-statements/ -->
       </local-tx-datasource>
      </datasources>
      


      When I look at server.log, it does look like it's reading the datasource configuration file and even binding it to the JNDI:

      2005-09-27 17:36:48,477 DEBUG [org.jboss.resource.connectionmanager.RARDeployment] Created jboss.jca:service=ManagedConnectionFactory,name=mobicus_management_poolDS
      ...
      2005-09-27 17:36:48,540 DEBUG [org.jboss.resource.connectionmanager.RARDeployment] Started jboss.jca:service=ManagedConnectionFactory,name=mobicus_management_poolDS
      ...
      2005-09-27 17:37:02,828 INFO [org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.mobicus_management_poolDS] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:service=LocalTxCM,name=mobicus_management_poolDS to JNDI name 'java:/mobicus_management_poolDS'
      


      And there are no exceptions or other suspicious things that I can see in the log, before our application tries to initialise the datasource, which results in the exception shown at the top of this message.

      Here is the relevant code:

       /** Creates new DBPool */
       public DBPool(String pPoolName) throws CoreException {
       mPoolName = pPoolName;
       mDataSourceName = StringAppender.asString("java:/", mPoolName, "DS");
       Hashtable env = new Hashtable();
       env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
       env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
       Context ctx = null;
       try {
       ctx = new InitialContext(env);
       mDataSource = (DataSource) ctx.lookup(mDataSourceName);
       } catch (NamingException ex) {
       throw new CoreException(IErrorCodes.ERROR_J2EE_NAMING_EXCEPTION, ex);
       }
       }
      


      I even added debugging code to list the contents of the JNDI context, and on 3.2.5 it does show the java:/mobicus_management_poolDS whereas under 3.2.7 it doesn't. It looks like the JNDI binding doesn't seem to "take hold", even though the log file says it's bound.

      I have also tried using <use-java-context>false</use-java-context>, and then accessing the datasource without the "java:/" prefix, but this didn't work any better under 3.2.7 (didn't even test under 3.2.5).

      My question is, what's going wrong here? Did something change in how the datasource should be configured or accessed between JBoss 3.2.5 and 3.2.7? Any suggested solutions, or even hints on how to debug this?


      Thanks,
      Mikko Hänninen