You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Francisco Borges <fr...@x-hive.com> on 2007/07/03 11:53:18 UTC

Can't connect to ConnectionFactory, need resource-ref?

Hello,

I'm trying to port this J2EE module to Geronimo1.2, but I'm not familiar 
with EJB's, so I might be missing something obvious. 

[...]

I managed to deploy both our resource adapter to a connection factory (as 
a RAR file), and our sample session (JAR+EJB). 

I can start running the sample, but from it I can't get a connection to 
the ConnectionFactory.

From "12.3.6 Resolving References from EJBs" at  
<http://www.chariotsolutions.com/geronimo/geronimo-1.1/ejb-structure.html> 
I gather that on Geronimo (differently from JBoss) after deploying the 
RAR, in order to be able to find it from my sample app, I need to declare 
it as a resource-ref at the sample's "openejb-jar.xml" and "ejb-jar.xml".  
Is this correct? 

If so, how should I do this? I managed to declare a resource-ref on 
openejb-jar.xml, but not on the ejb-jar.xml.

On the openejb-jar.xml, I have:

""""
      <session>
         <ejb-name>XhiveSampleSessionBean</ejb-name>
         <jndi-name>com.xhive.ejb.XhiveSampleSessionEJB</jndi-name>
         <ejb-ref>
            <ref-name>ejb/XhiveDS</ref-name>
            <ejb-link>XhiveDS</ejb-link>
         </ejb-ref>
      </session>
""""

What should I add to ejb-jar.xml?

I've tried adding something like
"""
    <session>
      <ejb-name>XhiveSampleSessionBean</ejb-name>
	[....]      
      <resource-ref>
	      <res-ref-name>ejb/XhiveDS</res-ref-name>
	     <res-type>
			com.xhive.j2ee.connector.interfaces.XhiveCCIConnectionFactoryIf
	    </res-type>
     </resource-ref>
     </session>
"""
 
But with this last change the Sample EJB won't deploy. For clarity, I'm 
attaching the 4 xml files I'm using for RAR and EJB+JAR deployment.

Any hints, or tips are heartily appreciated,

Cheers,
-- 
Francisco Borges



Re: Can't connect to ConnectionFactory, need resource-ref?

Posted by Shiva Kumar H R <sh...@gmail.com>.
On 7/3/07, Francisco Borges <fr...@x-hive.com> wrote:
>
> On Tuesday 03 July 2007, Shiva Kumar H R wrote:
> > Comments inline.
>
> > JNDI namespace for datasources should ideally be jdbc. Try changing
>
> Even if I am not exposing a JDBC interface?


It's not mandatory, just a best practice - makes your code more readable.

> <res-ref-name> to "jdbc/XhiveDS" (plus update jndi lookup code in your
> > ejbs) as below, in sync with <ref-name> in openejb-jar.xml, and see if
> > it solves the problem.
>
> >      <resource-ref>
> >        <res-ref-name>jdbc/XhiveDS</res-ref-name>
> >        <res-type>
> >
> > com.xhive.j2ee.connector.interfaces.XhiveCCIConnectionFactoryIf
> > </res-type>
> >        <res-auth>Container</res-auth>
> >        <res-sharing-scope>Shareable</res-sharing-scope>
> >      </resource-ref>
> >
> > If this doesn't solve, do post the errors you are seeing while
> > deploying/running.
>
> It worked!
>
:-)


Good.

Thank you very much for the help!
>
> Cheers,
> --
> Francisco Borges
>

Re: Can't connect to ConnectionFactory, need resource-ref?

Posted by Francisco Borges <fr...@x-hive.com>.
On Tuesday 03 July 2007, Shiva Kumar H R wrote:
> Comments inline.

> JNDI namespace for datasources should ideally be jdbc. Try changing

Even if I am not exposing a JDBC interface?


> <res-ref-name> to "jdbc/XhiveDS" (plus update jndi lookup code in your
> ejbs) as below, in sync with <ref-name> in openejb-jar.xml, and see if
> it solves the problem.

>      <resource-ref>
>        <res-ref-name>jdbc/XhiveDS</res-ref-name>
>        <res-type>
>         
> com.xhive.j2ee.connector.interfaces.XhiveCCIConnectionFactoryIf
> </res-type>
>        <res-auth>Container</res-auth>
>        <res-sharing-scope>Shareable</res-sharing-scope>
>      </resource-ref>
>
> If this doesn't solve, do post the errors you are seeing while
> deploying/running.

It worked!

:-)

Thank you very much for the help!

Cheers,
-- 
Francisco Borges

Re: Can't connect to ConnectionFactory, need resource-ref?

Posted by Shiva Kumar H R <sh...@gmail.com>.
Comments inline.

On 7/3/07, Francisco Borges <fr...@x-hive.com> wrote:
>
> Hello,
>
> I'm trying to port this J2EE module to Geronimo1.2, but I'm not familiar
> with EJB's, so I might be missing something obvious.
>
> [...]
>
> I managed to deploy both our resource adapter to a connection factory (as
> a RAR file), and our sample session (JAR+EJB).
>
> I can start running the sample, but from it I can't get a connection to
> the ConnectionFactory.
>
> From "12.3.6 Resolving References from EJBs" at
> <http://www.chariotsolutions.com/geronimo/geronimo-1.1/ejb-structure.html>
> I gather that on Geronimo (differently from JBoss) after deploying the
> RAR, in order to be able to find it from my sample app, I need to declare
> it as a resource-ref at the sample's "openejb-jar.xml" and "ejb-jar.xml".
> Is this correct?


Yes

If so, how should I do this? I managed to declare a resource-ref on
> openejb-jar.xml, but not on the ejb-jar.xml.
>
> On the openejb-jar.xml, I have:
>
> """"
>       <session>
>          <ejb-name>XhiveSampleSessionBean</ejb-name>
>          <jndi-name>com.xhive.ejb.XhiveSampleSessionEJB</jndi-name>
>          <ejb-ref>
>             <ref-name>ejb/XhiveDS</ref-name>
>             <ejb-link>XhiveDS</ejb-link>
>          </ejb-ref>
>       </session>
> """"


<ejb-ref> is not the element to be used. Please use <resource-ref> as below:

      <session>
         <ejb-name>XhiveSampleSessionBean</ejb-name>
         <jndi-name>com.xhive.ejb.XhiveSampleSessionEJB</jndi-name>
         <nam:resource-ref xmlns:nam="
http://geronimo.apache.org/xml/ns/naming-1.2">
            <ref-name>jdbc/XhiveDS</ref-name>
            <ref-link>XhiveDS</ref-link>
         </nam:resource-ref>
      </session>

What should I add to ejb-jar.xml?
>
> I've tried adding something like
> """
>     <session>
>       <ejb-name>XhiveSampleSessionBean</ejb-name>
>         [....]
>       <resource-ref>
>               <res-ref-name>ejb/XhiveDS</res-ref-name>
>              <res-type>
>
> com.xhive.j2ee.connector.interfaces.XhiveCCIConnectionFactoryIf
>             </res-type>
>      </resource-ref>
>      </session>
> """


JNDI namespace for datasources should ideally be jdbc. Try changing
<res-ref-name> to "jdbc/XhiveDS" (plus update jndi lookup code in your ejbs)
as below, in sync with <ref-name> in openejb-jar.xml, and see if it solves
the problem.

     <resource-ref>
       <res-ref-name>jdbc/XhiveDS</res-ref-name>
       <res-type>
         com.xhive.j2ee.connector.interfaces.XhiveCCIConnectionFactoryIf
       </res-type>
       <res-auth>Container</res-auth>
       <res-sharing-scope>Shareable</res-sharing-scope>
     </resource-ref>

But with this last change the Sample EJB won't deploy. For clarity, I'm
> attaching the 4 xml files I'm using for RAR and EJB+JAR deployment.
>
> Any hints, or tips are heartily appreciated,


If this doesn't solve, do post the errors you are seeing while
deploying/running.

Cheers,
> --
> Francisco Borges


- Shiva