4 Replies Latest reply on Oct 10, 2003 1:38 AM by Bernd Zeitler

    Problem with MYSQL OR JNDI ??

    nitz_tech Newbie

      Hello friends,

      I am new to JBOSS environment. I have put all my efforts trying to configure MYSQL4.x with JBOSS 3.x. I can very well get my ejb's from the Naming Server but when I try to get any other object such as String, Datasource objects I get a exception javax.naming.NameNotFoundException.

      According to me there are two possibilities :
      1. Problem with JNDI : Can be. But I can get my ejbs back from JNDI. But not Datasource or any other say String object.
      2. Problem with MYSQL Configuration : - no comments -


      When I cut and paste the mysql-service.xml file I get the message :
      ======================================
      JBOSS Console :
      14:09:45,312 INFO [MainDeployer] Starting deployment of package: file:/E:/jboss/jboss-tomcat/server/default/deploy/mysql-service.xml
      14:09:45,328 INFO [JBossManagedConnectionPool] Creating
      14:09:45,328 INFO [JBossManagedConnectionPool] Created
      14:09:45,328 INFO [LocalTxConnectionManager] Creating
      14:09:45,328 INFO [LocalTxConnectionManager] Created
      14:09:45,328 INFO [JBossManagedConnectionPool] Starting
      14:09:45,328 INFO [JBossManagedConnectionPool] Started
      14:09:45,343 INFO [LocalTxConnectionManager] Starting
      14:09:45,359 INFO [MySqlDS] Bound connection factory for resource adapter 'JBoss LocalTransaction JDBC Wrapper' to JNDI name 'java:/MySqlDS'
      14:09:45,359 INFO [LocalTxConnectionManager] Started
      14:09:45,359 INFO [MainDeployer] Deployed package: file:/E:/jboss/jboss-tomcat/server/default/deploy/mysql-service.xml
      ======================================
      Client Code :
      Hashtable hashTable = new Hashtable();
      hashTable.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      hashTable.put(Context.PROVIDER_URL,"jnp://happy:1099");

      Context context = new InitialContext(hashTable);

      DataSource dataSource = (DataSource) context.lookup("java:/MySqlDS");
      ======================================
      login-config.xml
      <!-- Testing for MYSQL Database Starts here -->
      <application-policy name = "MySQLDbRealm">

      <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
      <module-option name = "principal">root</module-option>
      <module-option name = "userName">root</module-option>
      <module-option name = "password"></module-option>
      <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=MySqlDS</module-option>
      </login-module>

      </application-policy>
      <!-- Testing for MYSQL Database Ends here -->
      ======================================
      mysql-service.xml
      <?xml version="1.0" encoding="UTF-8"?>

      <!-- ===================================================================== -->
      <!-- -->
      <!-- JBoss Server Configuration -->
      <!-- -->
      <!-- ===================================================================== -->



      <!-- ==================================================================== -->
      <!-- New ConnectionManager setup for mysql using 2.0.11 driver -->
      <!-- Build jmx-api (build/build.sh all) and view for config documentation -->
      <!-- ==================================================================== -->




      <!-- Include a login module configuration named MySqlDbRealm.
      Update your login-conf.xml, here is an example for a
      ConfiguredIdentityLoginModule:

      <application-policy name = "MySqlDbRealm">

      <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=MySqlDS</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 MySqlDbRealm above -->
      MySqlDbRealm
      <!---->

      <depends optional-attribute-name="ManagedConnectionFactoryName">
      <!--embedded mbean-->


      MySqlDS



      <config-property name="ConnectionURL" type="java.lang.String">jdbc:mysql://happy:3306/test</config-property>
      <config-property name="DriverClass" type="java.lang.String">org.gjt.mm.mysql.Driver</config-property>
      <!--set these only if you want only default logins, not through JAAS -->
      <config-property name="UserName" type="java.lang.String">root</config-property>
      <config-property name="Password" type="java.lang.String"></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



      ======================================

        • 1. Re: Problem with MYSQL OR JNDI ??
          Juha Lindfors Master

          You cannot lookup datasources from the client. The 'java:' namespace the datasources are bound under is local to the JVM process. Only components running inside the application server may access it.

          -- Juha

          • 2. Re: Problem with MYSQL OR JNDI ??
            nitz_tech Newbie

            Thanx for your reply Juha.

            I think I am getting wrong somewhere. Let me put my thinking in words.

            JBoss is a app server with a inbuilt naming registry. Now this registry runs on port 1099 (that can be changed). Being a Naming Registry it should give objects to the lookups it receives from client irrespective of its location.

            For Datasource. I feel its been introduced coz the connections could not be sent to other maching's JVM in earlier JDBC versions. If I get a datasource object I should be able to register it with Naming Registry and get it on another JVM running. Isn't it correct ??

            We should be able to register and retrieve any objects irrespective of whether the Naming Server is part of a App server or not. Being a Naming Server it should listen to requests promptly and send it to the client.

            Please guide me..

            thanx,


            nitin

            • 3. Re: Problem with MYSQL OR JNDI ??
              nitz_tech Newbie

              I got the JMX console and I could see the Bean loaded in JNDI server..

              I would be thankful if anyone helps me out of getting this situation ..

              regards,


              nitin

              • 4. Re: Problem with MYSQL OR JNDI ??
                Bernd Zeitler Expert

                JBoss is using the NonSerializableFactory for registering datasources with jndi. With this factory, objects are registered only within the java: namespace. JNDI is handing out a reference to the registered object, that's all.
                IMHO, it's nonsense to hand out datasources. I need application servers to build thin clients, I want to implement all the business logic on the server, I want to reuse the same logic for different purpose and I want to hide the source of my data (database or whatever) for my accessing client.

                Greetings,
                Frito