I was trying to use container managed datasources (JBoss
4.0.5.GA) for
both embs and as2.
I made the following configuration changes to make it work:
- copy the corvus webapps directory to the server/default/deploy
directory and rename to corvus.war (no need to make an actual war
file).
- add a jboss-web.xml file to the corvus.war/WEB-INF directory with
the following contents:
<jboss-web>
<resource-ref>
<res-ref-name>jdbc/as2db</res-ref-name>
<jndi-name>java:hermesAs2DS</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>jdbc/ebms</res-ref-name>
<jndi-name>java:hermesEbmsDS</jndi-name>
</resource-ref>
<security-domain>java:/jaas/jmx-console</security-domain>
</jboss-web>
(I'm using the default jmx-security setup here)
- add the datasources to corvus.war/WEB-INF/web.xml:
<?xml version="1.0" ?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "
http://java.sun.com/dtd/web-app_2_3.dtd">
<!-- Copyright (c) 2002 by ObjectLearn. All Rights Reserved. -->
<web-app>
<display-name>Corvus</display-name>
.
.
.
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Corvus Restricted Area</realm-name>
</login-config>
<security-role>
<role-name>admin</role-name>
</security-role>
<resource-ref>
<res-ref-name>jdbc/as2db</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<res-ref-name>jdbc/ebms</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
(I also simplified security a bit)
- modified ebms.module.xml to use the new datasource:
<component id="daofactory" name="System DAO Factory">
<!--
class>hk.hku.cecid.piazza.commons.dao.ds.SimpleDSDAOFactory</class>
<parameter name="driver" value="org.postgresql.Driver"/>
<parameter name="url" value="jdbc:postgresql://
127.0.0.1:5432/ebms"/
>
<parameter name="username" value="corvus"/>
<parameter name="password" value="corvus"/>
<parameter name="pooling" value="true"/>
<parameter name="maxActive" value="30"/>
<parameter name="maxIdle" value="10"/>
<parameter name="maxWait" value="-1"/-->
<class>hk.hku.cecid.piazza.commons.dao.ds.DataSourceDAOFactory</class>
<parameter name="datasource" value="java:/comp/env/jdbc/ebms" />
<parameter name="config">
hk/hku/cecid/ebms/spa/conf/DAOMessage.xml,
hk/hku/cecid/ebms/spa/conf/DAORepository.xml,
hk/hku/cecid/ebms/spa/conf/DAOOutbox.xml,
hk/hku/cecid/ebms/spa/conf/DAOInbox.xml,
hk/hku/cecid/ebms/spa/conf/DAOMessageServer.xml,
hk/hku/cecid/ebms/spa/conf/DAOPartnership.xml
</parameter>
</component>
- modified as2.module.core.xml to use the new datasource:
<component id="daofactory" name="AS2 DAO Factory">
<!--
class>hk.hku.cecid.piazza.commons.dao.ds.SimpleDSDAOFactory</class>
<parameter name="driver" value="org.postgresql.Driver"/>
<parameter name="url" value="jdbc:postgresql://
127.0.0.1:5432/as2"/>
<parameter name="username" value="corvus"/>
<parameter name="password" value="corvus"/>
<parameter name="pooling" value="true"/>
<parameter name="maxActive" value="30"/>
<parameter name="maxIdle" value="10"/>
<parameter name="maxWait" value="-1"/-->
<class>hk.hku.cecid.piazza.commons.dao.ds.DataSourceDAOFactory</
class>
<parameter name="datasource" value="java:/comp/env/jdbc/as2db" />
<parameter name="config" value="hk/hku/cecid/edi/as2/conf/
as2.dao.xml"/>
</component>
- I added the datasource definition files to the server/default/deploy
directory
And yes, it does work fine this way, but now my log files are rapidly
growing with the following warning messages
17:25:23,479 WARN [WrappedConnection] Closing a result set you left
open! Please close it yourself.
java.lang.Throwable: STACKTRACE
at
org.jboss.resource.adapter.jdbc.WrappedStatement.registerResultSet(WrappedStatement.java:
617)
at
org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:
237)
at
hk.hku.cecid.piazza.commons.dao.ds.DataSourceQuery.doTransaction(DataSourceQuery.java:
88)
at
hk.hku.cecid.piazza.commons.dao.ds.DataSourceProcess.start(DataSourceProcess.java:
89)
at
hk.hku.cecid.piazza.commons.dao.ds.DataSourceDAO.executeQuery(DataSourceDAO.java:
413)
at
hk.hku.cecid.piazza.commons.dao.ds.DataSourceDAO.executeQuery(DataSourceDAO.java:
392)
at
hk.hku.cecid.piazza.commons.dao.ds.DataSourceDAO.find(DataSourceDAO.java:
324)
at
hk.hku.cecid.ebms.spa.dao.MessageDataSourceDAO.findMessagesByMessageBoxAndStatus(MessageDataSourceDAO.java:
97)
at
hk.hku.cecid.ebms.spa.task.OutboxCollector.getTaskList(OutboxCollector.java:
51)
at
hk.hku.cecid.piazza.commons.module.ActiveTaskModule.execute(ActiveTaskModule.java:
137)
at
hk.hku.cecid.piazza.commons.module.ActiveModule.run(ActiveModule.java:
213)
at java.lang.Thread.run(Thread.java:613)
17:25:23,480 WARN [WrappedConnection] Closing a result set you left
open! Please close it yourself.
java.lang.Throwable: STACKTRACE
at
org.jboss.resource.adapter.jdbc.WrappedStatement.registerResultSet(WrappedStatement.java:
617)
at
org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:
237)
at
hk.hku.cecid.piazza.commons.dao.ds.DataSourceQuery.doTransaction(DataSourceQuery.java:
88)
at
hk.hku.cecid.piazza.commons.dao.ds.DataSourceProcess.start(DataSourceProcess.java:
89)
at
hk.hku.cecid.piazza.commons.dao.ds.DataSourceDAO.executeQuery(DataSourceDAO.java:
413)
at
hk.hku.cecid.piazza.commons.dao.ds.DataSourceDAO.executeQuery(DataSourceDAO.java:
392)
at
hk.hku.cecid.piazza.commons.dao.ds.DataSourceDAO.find(DataSourceDAO.java:
324)
at
hk.hku.cecid.ebms.spa.dao.MessageDataSourceDAO.findMessagesByMessageBoxAndStatus(MessageDataSourceDAO.java:
97)
at
hk.hku.cecid.ebms.spa.task.InboxCollector.getTaskList(InboxCollector.java:
46)
at
hk.hku.cecid.piazza.commons.module.ActiveTaskModule.execute(ActiveTaskModule.java:
137)
at
hk.hku.cecid.piazza.commons.module.ActiveModule.run(ActiveModule.java:
213)
at java.lang.Thread.run(Thread.java:613)
17:25:23,727 INFO [as2] Total number of messages recovered: 0
17:25:23,740 WARN [WrappedConnection] Closing a result set you left
open! Please close it yourself.
java.lang.Throwable: STACKTRACE
at
org.jboss.resource.adapter.jdbc.WrappedStatement.registerResultSet(WrappedStatement.java:
617)
at
org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:
237)
at
hk.hku.cecid.piazza.commons.dao.ds.DataSourceQuery.doTransaction(DataSourceQuery.java:
88)
at
hk.hku.cecid.piazza.commons.dao.ds.DataSourceProcess.start(DataSourceProcess.java:
89)
at
hk.hku.cecid.piazza.commons.dao.ds.DataSourceDAO.executeQuery(DataSourceDAO.java:
413)
at
hk.hku.cecid.piazza.commons.dao.ds.DataSourceDAO.executeQuery(DataSourceDAO.java:
392)
at
hk.hku.cecid.piazza.commons.dao.ds.DataSourceDAO.find(DataSourceDAO.java:
324)
at
hk.hku.cecid.edi.as2.dao.MessageDataSourceDAO.findMessagesByStatus(MessageDataSourceDAO.java:
39)
at
hk.hku.cecid.edi.as2.module.IncomingMessageList.getTaskList(IncomingMessageList.java:
34)
at
hk.hku.cecid.piazza.commons.module.ActiveTaskModule.execute(ActiveTaskModule.java:
137)
at
hk.hku.cecid.piazza.commons.module.ActiveModule.run(ActiveModule.java:
213)
at java.lang.Thread.run(Thread.java:613)
17:25:23,734 INFO [as2] AS2 server started up successfully
This is the result of a minor error in DataSourceQuery.java, in the
doTransaction method the statement is closed before closing the
resultset, see below:
finally {
if (pStmt!=null) {
try {
pStmt.close();
}
catch (Exception ex) {
throw new DAOException("Error in closing prepared
statement: ", ex);
}
}
if (rs!=null) {
try {
rs.close();
}
catch (Exception ex) {
throw new DAOException("Error in closing result set: ",
ex);
}
}
Regards,
Martin Borgman.