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
repository.

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"
    "http://www.ibatis.com/dtd/dao-2.dtd">
<daoConfig>
  <properties resource="com/lancaster/ibatis/dao/dao.properties"/>
  <context>
    <transactionManager type="JDBC">
      <property name="DataSource" value="JNDI"/>
      <property name="DBJndiContext" value="java:DefaultDS"/>
    </transactionManager>
    <dao interface="com.ibatis.dao.iface.AccountDao"
implementation="com.ibatis.dao.impl.jdbc.JdbcAccountDao"/>
  </context>
</daoConfig>
-----------------------


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);
			initScript("scripts/account-init.sql");
		} catch (Exception e) {
			e.printStackTrace();
		}
		assertNotNull(daoManager);
	}


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,

  Fabiano.

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
>
>

Mime
View raw message