I'm a bit confused... some parts of your plans seem to imply the
connector is outside the ear and some parts imply it is in the ear.
And, why does a cmp bean need a resource-ref to the db the cmp engine
is using...??? Well, there might be reasons.
but, anyway, I recommend you replace your name specifications with
<resource-link> MysqlDataSource </resource-link> (no app, module, name
specification). Geronimo should find the datasource whether you
include it in the ear or deploy it standalone. It won't find it if you
deploy it in a different ear :-)
the alt-dd stuff has not been tested AFAIK. If the above doesn't work,
please try putting all the plans (openejb and connector) into the
geronimo-application plan and see if that helps: if so please file a
bug.
Hope this helps
david jencks
On Jun 17, 2005, at 9:30 PM, Neal Sanche wrote:
Hi All,
I'm currently having trouble with a CMP bean getting access to a MySql
database when the deployment plans for the JDBC Connector are
application scoped. Here's what I've done, can you see something wrong
with what I'm doing?
application.xml
<application
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"
version="1.4">
<module>
<ejb>phonebook-ejb.jar</ejb>
</module>
<module>
<web>
<web-uri>phonebook.war</web-uri>
<context-root>/phonebook</context-root>
</web>
</module>
<module>
<connector>tranql-connector-1.0-SNAPSHOT.rar</connector>
</module>
</application>
geronimo-application.xml
<application
xmlns="http://geronimo.apache.org/xml/ns/j2ee/application"
configId="org/acme/PhoneBook">
<module>
<connector>tranql-connector-1.0-SNAPSHOT.rar</connector>
<alt-dd>mysql-plan.xml</alt-dd>
</module>
</application>
mysql-plan.xml
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector"
version="1.5" configId="MysqlDatabase"
parentId="org/apache/geronimo/Server">
<dependency>
<uri>mysql/jars/mysql-connector-java-3.1.8-bin.jar</uri>
</dependency>
<resourceadapter>
<outbound-resourceadapter>
<connection-definition>
<connectionfactory-interface> javax.sql.DataSource
</connectionfactory-interface>
<connectiondefinition-instance>
<name>MysqlDataSource</name>
<config-property-setting name="UserName"> geronimo
</config-property-setting>
<config-property-setting name="Password"> geronimo
</config-property-setting>
<config-property-setting name="Driver">
com.mysql.jdbc.Driver </config-property-setting>
<config-property-setting name="ConnectionURL">
jdbc:mysql://localhost/geronimo </config-property-setting>
<config-property-setting
name="CommitBeforeAutocommit"> false </config-property-setting>
<config-property-setting
name="ExceptionSorterClass">
org.tranql.connector.NoExceptionsAreFatalSorter
</config-property-setting>
<connectionmanager>
<local-transaction/>
<single-pool>
<max-size>10</max-size>
<min-size>0</min-size>
<blocking-timeout-milliseconds> 5000
</blocking-timeout-milliseconds>
<idle-timeout-minutes>30</idle-timeout-minutes>
<match-one/>
</single-pool>
</connectionmanager>
<global-jndi-name> jdbc/MysqlDatabase
</global-jndi-name>
</connectiondefinition-instance>
</connection-definition>
</outbound-resourceadapter>
</resourceadapter>
</connector>
openejb-jar.xml
<openejb-jar
xmlns="http://www.openejb.org/xml/ns/openejb-jar"
configId="org/acme/PhonebookEJB"
parentId="MysqlDatabase">
<cmp-connection-factory>
<application>org/acme/PhoneBook</application>
<module>MysqlDatabase</module>
<name>MysqlDataSource</name>
</cmp-connection-factory>
<enterprise-beans>
<entity>
<ejb-name>PhoneBookEntry</ejb-name>
<jndi-name>PhoneBookEntry</jndi-name>
<local-jndi-name>java:comp/env/ejb/PhoneBookEntryLocal</local-jndi-
name>
<table-name>phone</table-name>
<cmp-field-mapping>
<cmp-field-name>name</cmp-field-name>
<table-column>name</table-column>
</cmp-field-mapping>
<cmp-field-mapping>
<cmp-field-name>phoneNumber</cmp-field-name>
<table-column>phone</table-column>
</cmp-field-mapping>
<resource-ref>
<ref-name>jdbc/basic/entityDatabase</ref-name>
<application>null</application>
<module>MysqlDatabase</module>
<name>PhonebookDBPool</name>
</resource-ref>
</entity>
<session>
<ejb-name>PhoneBookSession</ejb-name>
<jndi-name>org.acme.phonebook.ejb/PhoneBookSession/Home</jndi-name>
<local-jndi-name>java:comp/env/ejb/PhoneBookSessionLocal</local-jndi-
name>
</session>
</enterprise-beans>
</openejb-jar>
and finally, in my ejb-jar.xml inside the <entity> I have this:
<resource-ref >
<description><![CDATA[This is a reference to a JDBC
database.]]></description>
<res-ref-name>jdbc/basic/entityDatabase</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Now, the strange thing is that if I deploy the mysql-plan.xml file in
the global scoped fashion, I can write the the database by creating
CMP beans. But if I use the application scoped method, I get the
following error:
22:15:19,898 WARN [SystemExceptionInterceptor] PhoneBookSession
java.lang.NullPointerException
at
org.tranql.sql.DataSourceDelegate.getConnection(DataSourceDelegate.ja
va:36)
at
org.tranql.sql.jdbc.JDBCUpdateCommand.execute(JDBCUpdateCommand.java:
62)
at
org.tranql.cache.SimpleFlushStrategy.flush(SimpleFlushStrategy.java:5
9)
at
org.tranql.cache.SimpleFlushStrategy.flush(SimpleFlushStrategy.java:4
6)
at org.tranql.cache.InTxCache.flush(InTxCache.java:85)
at
org.apache.geronimo.transaction.context.AbstractTransactionContext.fl
ushState(AbstractTransactionContext.java:116)
at
org.apache.geronimo.transaction.context.InheritableTransactionContext
.complete(InheritableTransactionContext.java:172)
at
org.apache.geronimo.transaction.context.InheritableTransactionContext
.commit(InheritableTransactionContext.java:143)
at
org.openejb.transaction.ContainerPolicy$TxRequiresNew.invoke(Containe
rPolicy.java:246)
at
org.openejb.transaction.TransactionContextInterceptor.invoke(Transact
ionContextInterceptor.java:80)
at
org.openejb.slsb.StatelessInstanceInterceptor.invoke(StatelessInstanc
eInterceptor.java:98)
at
org.openejb.transaction.ContainerPolicy$TxRequiresNew.invoke(Containe
rPolicy.java:234)
at
org.openejb.transaction.TransactionContextInterceptor.invoke(Transact..
.
What am I doing wrong for Application scoping my database
configuration?
Thanks in advance, and sorry for all of the cut-n-pasting here.
Cheers.
-Neal