You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Sai Arunachalam <sa...@gmail.com> on 2004/08/27 20:42:20 UTC

JDBCDataSource in Geronimo

Hi,
     What do I do to bind a JNDI Name to a datasource in Geronimo? I
have a couple of EJB modules that refer to the datasource using the
resource reference descriptor. In weblogic 6.1 there is a separate
file called config.xml alongwith each application that is deployed
which has various tags like <JDBCConnectionPool> and <JDBCDataSource>.

Now if the EJB refers to a datasource using the reference name (like
jdbc/EstoreDataSource), how do I specify a DataSource and bind it to a
JNDI Name in Geronimo?

In WebLogic 6.1 this is done as follows in the config.xml:

<JDBCDataSource JNDIName="jdbc.InventoryDB" Name="InventoryDB"
PoolName="petStorePool" Targets="petstoreServer">

Thanks in advance,
Sai

Re: JDBCDataSource in Geronimo

Posted by Sai Arunachalam <sa...@gmail.com>.
Hi,
   Thanks for that Gianny. You made a lot of things clear and it's lot
better now. About that petstore thing, I am trying to do the same
thing.. so I have someone to ask in case I have doubts. BTW, which
database are you using? Is it the one that is there when I download
the binary (the Axion with the DefaultDatasource)?
     I am planning to use Cloudscape. However, before I get that
running, I have to get the connector (that Jeremy spoke about)
working. I have posted a question on that already and once that is
done, I can hopefully proceed.
     
Thanks a lot again.
Regards,
Sai

Re: JDBCDataSource in Geronimo

Posted by Sai Arunachalam <sa...@gmail.com>.
Gianny (and all), 
      I am having a problem in making cloudscape work. I think it's
rather my configuration with geronimo-ra.xml that is playing the
mischief. (Recap: I am trying to port the PetStore that was there on
WebLogic6.1 to Geronimo. WebLogic6.1 has it's own config.xml that has
a few tags and attributes that I have to communicate using the
geronimo-ra.xml). The scenario is as follows:

The weblogic petstore app has a number of ejbs with each one having a
weblogic-ejb-jar.xml like the following (this one corresponds to
openejb-jar.xml on Geronimo).
...
<reference-descriptor>
      <reference-description>
             <res-ref-name>jdbc/EstoreDataSource</res-ref-name>
                   <jndi-name>jdbc.EstoreDB</jndi-name>
      </reference-description>
</reference-descriptor>
.... 
That is the case for a number of EJBs there.

Then there is a config.xml file that has the following properties:
...
<JDBCConnectionPool CapacityIncrement="1"
DriverName="COM.cloudscape.core.JDBCDriver" InitialCapacity="1"
MaxCapacity="1" Name="petstorepool" Properties="user=none;
password=none;server=none" Targets="petStoreServer"
URL="jdbc:cloudscape:petStore"/>
...
<JDBCDataSource JNDIName="jdbc.SignOnDB" Name="SignOnDB"
PoolName="petStorePool" Targets="petStoreServer"/>
<Realm FileRealm="myFileRealm" Name="myRealm"/>
<JDBCDataSource JNDIName="jdbc.InventoryDB" Name="InventoryDB"
PoolName="petStorePool" Targets="petStoreServer"/>
<JDBCDataSource JNDIName="jdbc.EstoreDB" Name="EstoreDB"
PoolName="petStorePool" Targets="petStoreServer"/>
...

Now I wanted to make this app run with Cloudscape. So I did the following:
I took the cloudscape jars (cloudscape.jar, tools.jar, client.jar and
four more...)
I checked out the latest version of TranQL from
http://cvs.tranql.codehaus.org/connector, built it to get the rar
file. Opened the rar file, removed the axion jars, put the cloudscape
jars there. Then I made the following changes to
META-INF/geronimo-ra.xml

1. configId="org/tranql/connector/axion" ->
configId="org/tranql/connector/cloudscape"
2. Then I changed the following:
     <connectiondefinition-instance>
               <name>DefaultDatasource</name>
      ....

to
     <connectiondefinition-instance>
               <name>jdbc.EstoreDB</name>
      ....
3.  <config-property-setting
name="JdbcDriver">org.axiondb.jdbc.AxionDriver</config-setting-name>
to
    <config-property-setting
name="JdbcDriver">COM.cloudscape.core.JDBCDriver</config-property-setting>

4. <config-property-setting
name="JdbcUrl">jdbc:axiondb:DefaultDatabase</config-property-setting>
to
   <config-property-setting
name="JdbcUrl">jdbc:cloudscape:EstoreDB</config-property-setting>
    
   [In some of the geronimo-ra.xml's that I saw, the attribute name
inside here was ConnectionURL instead of JdbcUrl. Does this matter?
Besides, how do I specify the other two DBs namely InventoryDB and
SignOnDB? Should I simply replicate the tags in the same fle or is
there a different way to do it? ]

Rest of the properties, I left as they were in geronimo-ra.xml.

Now I tried deploying this rar file on geronimo and it got deployed
without any errors. When I ran petstore this time alongwith the
configId of both the things (petstore and tranql rar), it gave me a
long error. So I put the rar file inside the petstore.ear file and
redployed it and ran it this time. This time I gave only petstore's
configId on starting the server. It got started and I saw the first
page (index.html that has a link saying "enter the store"). When I
tried going to the next page by pressing the link, it says "Unable to
connect to database. Connection not open. Make sure the connection is
open").

I don't know where the error is... Just then I found the following
file in weblogic's petstore directory called estore_runtimeejb.xml
that has portions like the following for each of the ejbs..

<j2ee-ri-specific-information>
  <server-name></server-name>
  <rolemapping />

  <enterprise-beans>
    <ejb>
      <ejb-name>TheOrder</ejb-name>
      <jndi-name>estore/order</jndi-name>
      <resource-ref>
        <res-ref-name>jdbc/EstoreDataSource</res-ref-name>
        <jndi-name>jdbc/Cloudscape</jndi-name>
        <default-resource-principal>
          <name>estoreuser</name>
          <password>estore</password>
        </default-resource-principal>
      </resource-ref>
      <ejb-ref>
        <ejb-ref-name>ejb/account/Account</ejb-ref-name>
        <jndi-name>estore/account</jndi-name>
      </ejb-ref>
    </ejb>

.....

Does this have something to do with the problem?

There are two more things I wanna know related to this problem. When I
looked up the index.properties inside config-store for the already
deployed axion database, the configId is given as
org/apache/geronimo/DefaultDatabase whereas the geronimo-ra.xml gives
the configId as org/openejb/connector/axion. How is this?

And then, how exactly do I deploy a stand-alone geronimo-ra.xml?

Thanks a lot for your help. 

Thanks and regards,
Sai

Re: JDBCDataSource in Geronimo

Posted by Gianny Damour <gi...@optusnet.com.au>.
On 28/08/2004 10:51 PM, Sai Arunachalam wrote:

>Hi,
>     Thanks a lot Gianny and Jeremy. I decided to download the
>connector (TranQL) since Jeremy says that CMR support and the PK
>problem can be solved easily as the low level things are already in
>place. Now I tried to run maven, but it gives me the following error:
>
>--------------------------------
>Attempting to download geronimo-spec-j2ee-1.0-M2.jar.
>WARNING: Failed to download geronimo-spec-j2ee-1.0-M2.jar.
>The build cannot continue because of the following unsatisfied dependency:
>
>geronimo-spec-j2ee-1.0-M2.jar
>  
>
This is a minor issue in the project.xml file. The version should be 
1.4-rc2.

Thanks,
Gianny

Re: JDBCDataSource in Geronimo

Posted by Sai Arunachalam <sa...@gmail.com>.
Hi,
     Thanks a lot Gianny and Jeremy. I decided to download the
connector (TranQL) since Jeremy says that CMR support and the PK
problem can be solved easily as the low level things are already in
place. Now I tried to run maven, but it gives me the following error:

--------------------------------
Attempting to download geronimo-spec-j2ee-1.0-M2.jar.
WARNING: Failed to download geronimo-spec-j2ee-1.0-M2.jar.
The build cannot continue because of the following unsatisfied dependency:

geronimo-spec-j2ee-1.0-M2.jar

Total time: 4 seconds
Finished at: Sat Aug 28 18:17:15 IST 2004
------------------------------------
I ain't able to get this jar in my geronimo version. I checked out the
latest version as well and couldn't spot it. How do I get this
connector working?

Thanks,
Sai

Re: JDBCDataSource in Geronimo

Posted by Jeremy Boynes <jb...@gluecode.com>.
Gianny Damour wrote:

> - Standard compliant: you can use the JDBC resource adapter implemented 
> as part of the OpenEJB project. This is the mechanism that I am using as 
> it is "portable" to some extent.
> 

You can also use the generic Connector that comes with TranQL 
(http://cvs.tranql.codehaus.org/connector/) which has a couple of 
advantages: it is pure Apache license and it is a J2CA 1.5 implementation.

> 
> AFAIK, the issue with this guy is that OpenEJB will not support the CMR. 
> Having said that, based on the fact that we only have OTO relations, I 
> think that I could "hack" something.
> 

CMR support is present in the lower level TranQL code but is not enabled 
by the deployer. It should be fairly simple to add this into the 
deployment code to support these. The same should also apply to the 
compound PK code. I may have a chance to get to that over the next week 
or so bur please ping me if you have any questions.

--
Jeremy


Re: JDBCDataSource in Geronimo

Posted by Gianny Damour <gi...@optusnet.com.au>.
On 28/08/2004 4:42 AM, Sai Arunachalam wrote:

>Hi,
>     What do I do to bind a JNDI Name to a datasource in Geronimo? I
>have a couple of EJB modules that refer to the datasource using the
>resource reference descriptor. In weblogic 6.1 there is a separate
>file called config.xml alongwith each application that is deployed
>which has various tags like <JDBCConnectionPool> and <JDBCDataSource>.
>
>Now if the EJB refers to a datasource using the reference name (like
>jdbc/EstoreDataSource), how do I specify a DataSource and bind it to a
>JNDI Name in Geronimo?
>  
>
Hi Sai,


To install a DataSource, you have two choices:
- Geronimo specific definition: you can define a stand-alone 
geronimo-ra.xml file describing your JDBC "capabilities" of your 
DataSource. Have a look to 
modules/assembly/src/plan/default-database-plan.xml for such an example; and
- Standard compliant: you can use the JDBC resource adapter implemented 
as part of the OpenEJB project. This is the mechanism that I am using as 
it is "portable" to some extent.

To map a <resource-ref> to this DataSource you need to define a 
corresponding <resource-ref> element in the Geronimo specific DD. In 
your specific case, the Geronimo specific <resource-ref> elements should 
have only two sub-elements, namely <ref-name> and <target-name>. 
<ref-name> is the name of the reference that you have declared in the 
ejb-jar.xml DD; <target-name> is usually the full JMX name of MBean to 
be bound to this reference. I say "usually" as in the case of a 
resource, you only need to specify the name of the 
<connectiondefinition-instance> define in geronimo-ra.xml of step one.

For instance, if you have this in your ejb-jar.xml:

    <entity>
      <ejb-name>TheAccount</ejb-name>
      ....
      <resource-ref>
        <res-ref-name>jdbc/EstoreDataSource</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
      </resource-ref>
    </entity>

then, you should declare this in your openejb-jar.xml:

        <entity>
            <ejb-name>TheAccount</ejb-name>
            <jndi-name>ejb/TheAccount</jndi-name>
            <resource-ref>
                <ref-name>jdbc/EstoreDataSource</ref-name>
                <target-name><connectiondefinition-instance> defined in 
geronimo-ra.xml</target-name>
            </resource-ref>
        </entity>

FYI, I have been able to install petstore.1.1.2, yet I have discovered a 
couple of problems. I can pass the installation of the schema required 
to support petstore, so I can see the front-page of petstore. Yet I can 
not sign-in: a <env-entry> defining a DAO (I do not remenber which one) 
is not defined in web.xml. Moreover, at least one <ejb-ref> is missing 
in web.xml. As an aside, errorpage.jsp does not compile. Based on the 
fact, that I spent a significant time to understand this latter (missing 
import directive) due to the fact that I was updating an errorpage.jsp 
in the wrong folder of the config-store, I have decided to upgrade to 
petstore 1.3.1_02.

AFAIK, the issue with this guy is that OpenEJB will not support the CMR. 
Having said that, based on the fact that we only have OTO relations, I 
think that I could "hack" something.

Thanks,
Gianny