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