ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fabiano Ferrari" <fcferr...@gmail.com>
Subject Re: running iBATIS test cases with JNDI
Date Mon, 21 Jul 2008 22:59:17 GMT
Hi, Christopher, all.

Sorry by not being clearer in the previous email. The problem I've
been facing is the following: I'm trying to run the test cases
provided with iBATIS using a data source retrieved from a JNDI

My question is: how can I retrieve a data source that is available
from a running JBoss Application Server?

My DAO configuration file (jdbc-dao.xml) is listed below:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE daoConfig
    PUBLIC "-//iBATIS.com//DTD DAO Configuration 2.0//EN"
  <properties resource="com/lancaster/ibatis/dao/dao.properties"/>
    <transactionManager type="JDBC">
      <property name="DataSource" value="JNDI"/>
      <property name="DBJndiContext" value="java:DefaultDS"/>
    <dao interface="com.ibatis.dao.iface.AccountDao"

I've got the JBoss 4.2.2 installed, which is listening on port 8081.
When I invoke the listXML() operation in the JBoss web interface, I
can find the "java:DefaultDS" data source. However, when I run the
test case below:

	public void testJNDIDataSource () {

		String resource = "com/ibatis/dao/jdbc-dao.xml";

		Reader reader;
		try {
			reader = Resources.getResourceAsReader(resource);
			daoManager = DaoManagerBuilder.buildDaoManager(reader);
		} catch (Exception e) {

I get the following exception:

	com.ibatis.dao.client.DaoException: Error while configuring
DaoManager.  Cause: com.ibatis.dao.client.DaoException: There was an
error configuring the DataSource from JNDI.  Cause:
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file:  java.naming.factory.initial

Any help is very welcome!
Many thanks,


On Mon, Jul 21, 2008 at 5:45 PM, Christopher Lamey
<clamey@localmatters.com> wrote:
> On 7/21/08 9:11 AM, "Fabiano Ferrari" <fcferrari@gmail.com> wrote:
>> However, I have never implemented any JNDI-based application. Does
>> anybody have an example of implementation of this MyDataSource class?
>> If so, could you provide me with the basic steps to "install" such
>> class and run the test cases?
> Hello,
> I've used Spring's SimpleNamingContextBuilder to put a DBCP BasicDataSource
> into JNDI for standalone apps and testing.
> Cheers,
> topher

View raw message