4 Replies Latest reply on Mar 17, 2004 11:31 AM by kmarcos

    Getting Datasource from application client (en español)

    kmarcos

      Hello,
      I have installed jboss-3.0.4.

      I am trying to develop a JCA connection under JBoss.

      I have this -ds.xml file in deploy directory:

      ******************* mprm-ds.xml **************************
      <connection-factories>

      <tx-connection-factory>

      <jndi-name>mPRMResAdapter</jndi-name>

      <adapter-display-name>mPRM resource adapter</adapter-display-name>

      <max-pool-size>64</max-pool-size>

      </tx-connection-factory>

      </connection-factories>

      *************************************************

      In the same deploy directory, I have the folder mprmra.rar. This folder contains several jar files and another folder called META-INF with a ra.xml inside of it. This ra.xml file looks like this:


      ********************** ra.xml **********************

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE connector PUBLIC "-//Sun Microsystems, Inc.//DTD Connector 1.0//EN" "http://java.sun.com/dtd/connector_1_0.dtd">


      <display-name>mPRM resource adapter</display-name>
      Resource adapeter for mPRM
      <vendor-name>ProSyst</vendor-name>
      <spec-version>1.0</spec-version>
      <eis-type>mPRM</eis-type>
      1.0

      No License Required
      <license-required>false</license-required>


      <managedconnectionfactory-class>com.prosyst.mprm.adapter.impl.jca.ManagedConnectionFactoryImpl</managedconnectionfactory-class>
      <connectionfactory-interface>com.prosyst.mprm.adapter.jca.ConnectionFactory</connectionfactory-interface>
      <connectionfactory-impl-class>com.prosyst.mprm.adapter.impl.jca.ConnectionFactoryImpl</connectionfactory-impl-class>
      <connection-interface>com.prosyst.mprm.adapter.jca.Connection</connection-interface>
      <connection-impl-class>com.prosyst.mprm.adapter.impl.jca.ConnectionImpl</connection-impl-class>
      <transaction-support>NoTransaction</transaction-support>
      <config-property id="J2EEResourceProperty_1">
      mPRM server uri
      <config-property-name>URI</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>socket://192.168.131.41:11449</config-property-value>
      </config-property>
      <config-property id="J2EEResourceProperty_2">
      Default user name
      <config-property-name>UserName</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>system</config-property-value>
      </config-property>
      <config-property id="J2EEResourceProperty_3">
      Default user password
      <config-property-name>Password</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>system</config-property-value>
      </config-property>
      <authentication-mechanism>
      BasicPassword authentication
      <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
      <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
      </authentication-mechanism>
      <reauthentication-support>false</reauthentication-support>



      *************************************************

      In the jboss log I get the following error:

      *************************************************
      14:11:02,004 INFO [MainDeployer] Starting deployment of package: file:/opt/HP/jboss/server/default/deploy/mprm-ds.xml
      14:11:02,011 INFO [MainDeployer] deployment waiting for deployer: file:/opt/HP/jboss/server/default/deploy/mprm-ds.xml
      14:11:02,011 INFO [MainDeployer] Deployment of package: file:/opt/HP/jboss/server/default/deploy/mprm-ds.xml is waiting for an appropriate deployer.
      14:11:02,015 ERROR [URLDeploymentScanner] MBeanException: Exception in MBean operation 'checkIncompleteDeployments()'
      Cause: Incomplete Deployment listing:
      Packages waiting for a deployer:
      [org.jboss.deployment.DeploymentInfo@601f0880 { url=file:/opt/HP/jboss/server/default/deploy/mprm-ds.xml }
      deployer: null
      status: null
      state: INIT_WAITING_DEPLOYER
      watch: file:/opt/HP/jboss/server/default/deploy/mprm-ds.xml
      lastDeployed: 1079615462011
      lastModified: 1079615462000
      mbeans:
      ]Incompletely deployed packages:
      [org.jboss.deployment.DeploymentInfo@601f0880 { url=file:/opt/HP/jboss/server/default/deploy/mprm-ds.xml }
      deployer: null
      status: null
      state: INIT_WAITING_DEPLOYER
      watch: file:/opt/HP/jboss/server/default/deploy/mprm-ds.xml
      lastDeployed: 1079615462011
      lastModified: 1079615462000
      mbeans:
      ]MBeans waiting for classes:

      MBeans waiting for other MBeans:

      *************************************************

      So I can´t use the jndi reference java:/mPRMResAdapter. I don´t know where could be the mistake.

      Please, can anybody help me?

      Thank you in advance. Eduardo

        • 1. Re: Getting Datasource from application client (en españo
          darranl

          Where is your client code executing? Is the client executing in the same JVM as JBoss or somewhere different?

          Your log messages seem so sugest that you may be providing some properties to the InitialContext when it is constructed java.naming.provider.url=localhost:1099

          To access the datasource the client code needs to be in the same JVM as JBoss and no properties should be passed to the InitialContext

          Also have a look at http://www.freetranslation.com/, if you can post your questions in English there will hopefully be a lot more people able to understand them.

          • 2. Re: Getting Datasource from application client (en espaÃ&#40
            kmarcos

            Hi darranl, tks for answer... (i'm trying in english)

            This is my client code, and yes, it is executing in other jvm (in that way must be or not?)

            public static void main (String[] args) throws Exception {
            Properties env = new Properties();
            env.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
            env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
            env.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
            env.setProperty("j2ee.clientName", "test-client");
            Context ctx = new InitialContext(env);
            System.out.println(ctx.getEnvironment().toString());
            
            Object obj=ctx.lookup("java:comp/env/PostgresDS");
            Class[] inte =obj.getClass().getInterfaces();
            for (int i= 0 ; i <inte.length ; i++){
            System.out.println(inte.getName()+" "+inte.getClassLoader());
            }
            /* In this point raise ClassCastException/*
            DataSource ds = (DataSource) ctx.lookup("java:comp/env/PostgresDS");
            ...



            I did all that understand that suposee to do... and in my jmx-console i have

            GLOBAL NAMESPACE

            +- test-client (class: org.jnp.interfaces.NamingContext)
            | +- PostgresDS[link -> java:/PostgresDS] (class: javax.naming.LinkRef)
            | +- ejb (class: org.jnp.interfaces.NamingContext)
            | | +- PruebaSession[link -> PruebaSession] (class: javax.naming.LinkRef)



            and in java: namespace is the data source

            +- PostgresDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)



            In other client a get the ejb succesfull, but the same code doesnt work to get the Datasource... however the error is not by jndi... is cause the cast...

            My .ear doesnt have any jar or something where javax.sql.DataSource is been reloaded, and not is in the postgresql-jdb.jar... so i dont know why is lost...



            • 3. Re: Getting Datasource from application client (en españo
              darranl

              The JDBC datasources are only supposed to be accessible from within the JBoss JVM, that is the reason that they are bound to the java: namespace.

              I am confused that you have been able to obtain a reference to an object bound to the java: namespace. I would have expected a NameNotBound exception to be throws before the ClassCastException could be thrown.

              I will have a look to see if I can recreate your problem, I only have access to JBoss 3.2.2RC4 today so will have to look at 3.2.3 tomorrow.



              • 4. Re: Getting Datasource from application client (en espaÃ&#40
                kmarcos

                Oky.

                Well there's not much documentation about it... but i did this:


                1. application-client.xml

                <application-client>
                 <display-name>J2EE Client Tests</display-name>
                 <description>A sample application client descriptor</description>
                
                
                 <ejb-ref>
                 <ejb-ref-name>ejb/PruebaSession</ejb-ref-name>
                 <ejb-ref-type>Session</ejb-ref-type>
                 <home>co.com.mazda.pruplat.PruebaSessionHome</home>
                 <remote>co.com.mazda.pruplat.PruebaSession</remote>
                 </ejb-ref>
                
                
                 <resource-ref>
                 <res-ref-name>PostgresDS</res-ref-name>
                 <res-type>javax.sql.DataSource</res-type>
                 <res-auth>Container</res-auth>
                 <!--res-sharing-scope>Shareable</res-sharing-scope-->
                 </resource-ref>
                </application-client>


                2. jboss-client.xml

                <jboss-client>
                
                 <jndi-name>test-client</jndi-name>
                
                 <ejb-ref>
                 <ejb-ref-name>ejb/PruebaSession</ejb-ref-name>
                 <jndi-name>PruebaSession</jndi-name>
                 </ejb-ref>
                
                 <resource-ref>
                 <res-ref-name>PostgresDS</res-ref-name>
                 <jndi-name>java:/PostgresDS</jndi-name>
                 </resource-ref>
                
                </jboss-client>


                3. application.xml

                <application>
                
                 <display-name>Prueba Plataforma</display-name>
                
                 <description> Prueba de plataforma </description>
                
                 <module>
                 <ejb>prueba.jar</ejb>
                 </module>
                
                 <module>
                 <java>app-client.jar</java>
                 </module>
                </application>


                and the client code is already in other post...

                thanks in advice!

                Kata