You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by JohnSimpson <jo...@bankofamerica.com> on 2007/08/13 14:45:08 UTC

Re: DataSource, JNDI and EJB module ...

Hi,

did you managed to resolve this issue?  
I've got a similar problem where an application-client can't access a
datasource which is defined as server-wide.  Strangely a web-app deployed
seperately can access the datasource.

Thanks,

john

-- 
View this message in context: http://www.nabble.com/DataSource%2C-JNDI-and-EJB-module-...-tf4090122s134.html#a12125557
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: DataSource, JNDI and EJB module ...

Posted by Gianny Damour <gi...@optusnet.com.au>.
On 13/08/2007, at 11:33 PM, JohnSimpson wrote:

>
> Hi,
>
> No.  I didn't realise I needed to set it as a dependency as the  
> datasource
> is deployed seperately, I will give it a go.
> Currently, I included the datasource as a resource in the
> geronimo-application-client.xml, like this:
>
>     <naming:resource-ref>
>         <naming:ref-name>jdbc/DataSource</naming:ref-name>
>         <naming:domain>geronimo.server</naming:domain>
>         <naming:server>geronimo</naming:server>
>         <naming:application>null</naming:application>
>         <naming:module>console-db-pool-MDMDB2</naming:module>
>         <naming:type>JCAManagedConnectionFactory</naming:type>
>         <naming:name>MDMDB2</naming:name>
>     </naming:resource-ref>
>
> It's basically a straight cut and past from the usage panel.  I then
> reference it in the application-client.xml, like this:
>
>     <resource-ref>
>       <description>DB2 datasource</description>
>       <res-ref-name>jdbc/DataSource</res-ref-name>
>       <res-type>javax.sql.DataSource</res-type>
>       <res-auth>Container</res-auth>
>     </resource-ref>
>
>
> So I need to put in a dependency as well?

Yes. You need to declare a dependency. Also, if you are using JEE5,  
you can benefit from the Resource injection annotation:

     @Resource(name="MDMDB2")
     private static DataSource ds;

Thanks,
Gianny


>
> Thanks,
>
> John
>
> -- 
> View this message in context: http://www.nabble.com/DataSource%2C- 
> JNDI-and-EJB-module-...-tf4090122s134.html#a12126274
> Sent from the Apache Geronimo - Users mailing list archive at  
> Nabble.com.
>


Re: DataSource, JNDI and EJB module ...

Posted by JohnSimpson <jo...@bankofamerica.com>.

Thanks for the help, I have made some progress in that the app now deploys. 
However, when I try and access the datasource from the app it throws an
exception.
The lookup code is:

InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:/comp/env/jdbc/DataSource");

The stack trace is:

javax.naming.NamingException: Could not look up : env/jdbc/DataSource [Root
exception is java.lang.IllegalStateException: Could not get proxy]
        at
org.apache.geronimo.naming.enc.CachingReference.resolveReference(CachingReference.java:59)
        at
org.apache.geronimo.naming.enc.CachingReference.get(CachingReference.java:45)
        at
org.apache.geronimo.naming.enc.AbstractReadOnlyContext.lookup(AbstractReadOnlyContext.java:86)
        at
org.apache.geronimo.naming.java.RootContext.lookup(RootContext.java:55)
        at javax.naming.InitialContext.lookup(InitialContext.java:347)
        at boa.isd.mdm.batch.BatchTest.main(BatchTest.java:49)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at
org.apache.geronimo.client.AppClientContainer.main(AppClientContainer.java:143)
        at
org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
        at
org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:118)
        at
org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:835)
        at
org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:178)
        at
org.apache.geronimo.system.main.CommandLine.invokeMainGBean(CommandLine.java:90)
        at
org.apache.geronimo.system.main.ClientCommandLine.<init>(ClientCommandLine.java:71)
        at
org.apache.geronimo.system.main.ClientCommandLine.main(ClientCommandLine.java:46)
Caused by: java.lang.IllegalStateException: Could not get proxy        at
org.apache.geronimo.naming.reference.ResourceReference.getContent(ResourceReference.java:55)
        at
org.apache.geronimo.naming.enc.CachingReference.resolveReference(CachingReference.java:55)
        ... 14 more
Caused by: org.apache.geronimo.kernel.GBeanNotFoundException:
geronimo.server:J2
EEApplication=null,J2EEServer=geronimo,JCAResource=console/MDMDB2/1.0/jar,j2eeTy
pe=JCAManagedConnectionFactory,name=MDMDB2 not found
        at
org.apache.geronimo.kernel.basic.BasicRegistry.getGBeanInstance(BasicRegistry.java:110)
        at
org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:177)
        at
org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:173)
        at
org.apache.geronimo.naming.reference.ResourceReference.getContent(ResourceReference.java:53)
        ... 15 more

The GBeanNotFoundException seems to imply that either the datasource does
not exist on the server or the client can't access it.  Given that the
datasource shows up on all the appropriate panels in the server admin area
and is used successfully by a web-app, I think that the second case applies. 
However, I don't know how to go about allowing access from the client app or
whether it is possible.
Sorry to keep going on about this, but it's got me totally stumped. 

Thanks,

john

-- 
View this message in context: http://www.nabble.com/DataSource%2C-JNDI-and-EJB-module-...-tf4090122s134.html#a12181535
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: DataSource, JNDI and EJB module ...

Posted by Gianny Damour <gi...@optusnet.com.au>.
On 14/08/2007, at 9:05 PM, JohnSimpson wrote:
>
>     <dependency>
>       <groupId>console</groupId>
>       <artifactId>MDMDB2</artifactId>
>       <version>1.0</version>
>     </dependency>


>
> However, when I try and deploy the ear I get the following error:
>
> org.apache.geronimo.kernel.repository.MissingDependencyException: uri
> console/MDMDB2/1.0/jar not found in repository
> uri console/MDMDB2/1.0/jar not found in repository
>
> but the uri shows up under the J2EE Connectors tab.  Any ideas?

I believe you should use the clientParentId attribute of application- 
client as you want to depend on another configuration/module:

<application-client
     ....
     clientConfigId="MDMBatch"
     configId="MDMBatchConfig"
     parentId="console/MDMDB2/1.0/jar">

Also, I would verify the type of the configuration by listing the  
available modules (list-modules command) as the type (last string in  
console/MDMDB2/1.0/jar) may actually be "car" and not "jar".

Thanks,
Gianny

>
> Thanks,
>
> John
>
> -- 
> View this message in context: http://www.nabble.com/DataSource%2C- 
> JNDI-and-EJB-module-...-tf4090122s134.html#a12142397
> Sent from the Apache Geronimo - Users mailing list archive at  
> Nabble.com.
>


Re: DataSource, JNDI and EJB module ...

Posted by JohnSimpson <jo...@bankofamerica.com>.
Hi,

OK, I'm still not making any progress with this.  I've added the dependency,
so that my geronimo-application-client.xml now looks like this :

<application-client 
xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-client"
    xmlns:naming="http://geronimo.apache.org/xml/ns/naming"
    xmlns:security="http://geronimo.apache.org/xml/ns/security"
    clientConfigId="MDMBatch"
    configId="MDMBatchConfig">
    
    <dependency>
      <groupId>console</groupId>
      <artifactId>MDMDB2</artifactId>
      <version>1.0</version>
    </dependency>
   
    <naming:resource-ref>
       <naming:ref-name>jdbc/DataSource</naming:ref-name>
        <naming:domain>geronimo.server</naming:domain>
        <naming:server>geronimo</naming:server>
        <naming:application>null</naming:application>
        <naming:module>console/MDMDB2/1.0/jar</naming:module>
        <naming:type>JCAManagedConnectionFactory</naming:type>
        <naming:name>MDMDB2</naming:name>
    </naming:resource-ref>


</application-client>

However, when I try and deploy the ear I get the following error:

org.apache.geronimo.kernel.repository.MissingDependencyException: uri
console/MDMDB2/1.0/jar not found in repository
uri console/MDMDB2/1.0/jar not found in repository

but the uri shows up under the J2EE Connectors tab.  Any ideas?

Thanks,

John

-- 
View this message in context: http://www.nabble.com/DataSource%2C-JNDI-and-EJB-module-...-tf4090122s134.html#a12142397
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: DataSource, JNDI and EJB module ...

Posted by JohnSimpson <jo...@bankofamerica.com>.
Hi,

No.  I didn't realise I needed to set it as a dependency as the datasource
is deployed seperately, I will give it a go.
Currently, I included the datasource as a resource in the
geronimo-application-client.xml, like this:

    <naming:resource-ref>
        <naming:ref-name>jdbc/DataSource</naming:ref-name>
        <naming:domain>geronimo.server</naming:domain>
        <naming:server>geronimo</naming:server>
        <naming:application>null</naming:application>
        <naming:module>console-db-pool-MDMDB2</naming:module>
        <naming:type>JCAManagedConnectionFactory</naming:type>
        <naming:name>MDMDB2</naming:name>
    </naming:resource-ref>

It's basically a straight cut and past from the usage panel.  I then
reference it in the application-client.xml, like this:

    <resource-ref>
      <description>DB2 datasource</description>
      <res-ref-name>jdbc/DataSource</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
    </resource-ref>  


So I need to put in a dependency as well?

Thanks,

John

-- 
View this message in context: http://www.nabble.com/DataSource%2C-JNDI-and-EJB-module-...-tf4090122s134.html#a12126274
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: DataSource, JNDI and EJB module ...

Posted by Gianny Damour <gi...@optusnet.com.au>.
Hi,

I just gave it a try with an app-client packaged within an EAR and it  
works for me. Have you declared the relevant dependency in your  
client-environment element?

Thanks,
Gianny


On 13/08/2007, at 10:45 PM, JohnSimpson wrote:

>
> Hi,
>
> did you managed to resolve this issue?
> I've got a similar problem where an application-client can't access a
> datasource which is defined as server-wide.  Strangely a web-app  
> deployed
> seperately can access the datasource.
>
> Thanks,
>
> john
>
> -- 
> View this message in context: http://www.nabble.com/DataSource%2C- 
> JNDI-and-EJB-module-...-tf4090122s134.html#a12125557
> Sent from the Apache Geronimo - Users mailing list archive at  
> Nabble.com.
>