2 Replies Latest reply on Sep 21, 2005 7:52 AM by ccaprar

    Understanding HA-JNDI... What am I missing?

    seanboltman

      Trying to understand and configure for HA-JNDI

      Background: Imagine a simplistic web application that 1) retrieves a JNDI DataSource definition and 2) uses the DataSource to get a database connection and query a table. Easy beans. I have this setup and working, using a mysql-ds.xml (plus related config changes), goes against the database just fine. BTW, I have the JDBC URL info that is in the mysql-ds.xml using the explicit machine name:

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

      <local-tx-datasource>
      <jndi-name>jdbc/EpokDB</jndi-name>
      <connection-url>jdbc:mysql://my.machine-1.com:3306/epokeis?autoReconnect=true&amp;maxReconnects=1&amp;initialTimeout=2</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>root</user-name>
      password
      </local-tx-datasource>


      Now lets say I have the same EXACT JBOSS server and web application setup on machine number 2. Same cluster-service.xml exactly! Only thing different is the mysql-ds.xml on machine number 2 uses "localhost" in the JDBC URLs i the mysql-ds.xml:

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

      <local-tx-datasource>
      <jndi-name>jdbc/EpokDB</jndi-name>
      <connection-url>jdbc:mysql://localhost:3306/epokeis?autoReconnect=true&amp;maxReconnects=1&amp;initialTimeout=2</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>root</user-name>
      password
      </local-tx-datasource>



      MY GOAL is that in the web application's JNDI DataSource lookup (as it is running on machine 2), that it INSTEAD gets the JNDI entry from machine 1, and not itself. Mind you that this JNDI DataSource has the same JNDI name on both machines.

      Here is what I know (right or wrong):

      - ProviderURL of "jnp://localhost:1099" is the local JNDI
      - ProviderURL of "localhost:1100" is the local HA-JNDI
      - ProviderURL of "my.machine-1.com:100" *should be* the HA-JNDI running on machine 1.
      - When you are asking the HA-JNDI for an item by name, it ALWAYS proxies the call down to its LOCAL JNDI. If NameNotFound there, THEN it will go ask other HA-JNDI's it knows about.
      - The way one HA-JNDI knows of other HA-JNDI's is via the auto-discovery settings under the HA-JNDI 'area' of cluster-service.xml
      - I DO NOT KNOW if this ability for one HA-JNDI to talk to another HA-JNDI breaks down IF the Partition condfiuration they declare has different Mul;ticast address or port... just not sure... BUT IN MY CASE, they are the same values!

      Okay, there is the ground work.

      Problem: On Machine 2, no matter what ProviderURL value I try, I *always* get the JNDI DataSource defined locally (ie; the one with "localhost" in the JDBC URL).
      - I have tried creating the InitialContext with ProviderURL = "my.machine-1.com:1100", but no luck.
      - I have tried setting it to "jnp://my.machine-1.com:1099" (not sure if I can even really do this, right... talk to a JBOSS local JNDI service from within a different JVM... correct me if I am wrong please!!!), but no luck.

      It seems this should work right? Especially when I specifically say "use the HA-JNDI on machine 1"... but in both cases above, I end up with the Local JNDI entry for this JNDI name.

      Help!!! Is my config wrong? If so, where are my misunderstandings? Please please, if you say RTFM, please be specific on page. I do have the 4.X latest admin guide downloaded. Ive been through lots of docs and think I understand. thanks!

      NOTE!!! That my JBOSS /server layout is a trimmed down version of /all, and has cluster-service.xml in it. I am using the DefaultPartition. So it's Partition configuration, specifically the Muslticast address and port are the same. JBOSS 4.0.1 on Redhat Linux.


      (Also, if this is Scott Stark, please see my additional comment I just added on my second JBOSS issue I am working thru, the APP-INF/classes issue. I left a question there for you. Thanks!!)