ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Ski <paulsk...@hotmail.com>
Subject java.lang.InstantiationException using Ibatis DAO
Date Sun, 07 Sep 2008 01:47:05 GMT

Hi list,
- Windows XP
- Java(TM) SE Runtime Environment (build 1.6.0_10-rc-b28)
- Eclipse Version: 3.4.0 Build id: I20080617-2000
- Ibatis
Project Jars:
I've created a class to return me a DaoManager object
import java.io.Reader;import com.ibatis.common.resources.Resources;import com.ibatis.dao.client.DaoManager;import
public class DaoManagerMapper{ private static final DaoManager daoManager;
 static {  try  {   Reader reader = Resources.getResourceAsReader ( "dao.xml" );   daoManager
= DaoManagerBuilder.buildDaoManager ( reader );  }  catch ( Exception e )  {   throw new RuntimeException
(     "Could not initialize DaoManager. Cause: " + e );  } }
 public static DaoManager getDaoManager () {  return daoManager; }}
Test stub to call the code is:
import com.ibatis.dao.client.DaoManager;import com.intient.smash.ibatis.Aliases;import com.intient.smash.ibatis.impl.AliasesDAO;
public class TestDaoManagerMapper{ public TestDaoManagerMapper () {  try  {   DaoManager daoManager
= DaoManagerMapper.getDaoManager ();   AliasesDAO aliasesDao = (AliasesDAO)daoManager    
.getDao ( AliasesDAO.class );
   try   {...  }  catch ( Exception e )  {   e.printStackTrace ();  } }
 public static void main ( String[] args ) {  new TestDaoManagerMapper (); }}
DAO Config:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE daoConfig PUBLIC "-//ibatis.apache.org//DTD
DAO Configuration 2.0//EN" "http://ibatis.apache.org/dtd/dao-2.dtd"><daoConfig> <context>
 <transactionManager type="SQLMAP">   <property name="SqlMapConfigResource" value="sqlMapConfig.xml"
/>  </transactionManager>      <!-- DAO interfaces and implementations should
be listed here -->  <dao interface="com.intient.smash.ibatis.impl.AliasesDAO"   implementation="com.intient.smash.ibatis.impl.AliasesDAOImpl"
/>... </context></daoConfig>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-config-2.dtd"><sqlMapConfig>
<settings useStatementNamespaces="true" /> <transactionManager type="JDBC">  <dataSource
type="SIMPLE">   <property name="JDBC.Driver" value="com.mysql.jdbc.Driver" />  
<property name="JDBC.ConnectionURL" value="jdbc:mysql://localhost/xxxxxxxx" />   <property
name="JDBC.Username" value="xxxxxxxx" />   <property name="JDBC.Password" value="xxxxxxxx"
/>   <property name="JDBC.DefaultAutoCommit" value="true" />  </dataSource>
</transactionManager> <sqlMap resource="com/intient/smash/ibatis/maps/aliases_SqlMap.xml"
Exception in thread "main" java.lang.ExceptionInInitializerError at com.intient.smash.TestDaoManagerMapper.<init>(TestDaoManagerMapper.java:14)
at com.intient.smash.TestDaoManagerMapper.main(TestDaoManagerMapper.java:40)Caused by: java.lang.RuntimeException:
Could not initialize DaoManager. Cause: com.ibatis.dao.client.DaoException: Error while configuring
DaoManager.  Cause: com.ibatis.dao.client.DaoException: Error configuring DAO.  Cause: java.lang.InstantiationException:
com.intient.smash.ibatis.impl.AliasesDAOImpl at com.intient.smash.DaoManagerMapper.<clinit>(DaoManagerMapper.java:24)
... 2 more
I can get the SQL Map to work against my database and pull out data but the above DAO code
throws the above exception.
Any ideas would be helpful.
Win a Hotmail Go-Kart to race at Bathurst. Enter today!
View raw message