ibatis-user-java mailing list archives

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

My DAO and DAOImlp classes were generated by Ibator.  The only generated constructor for AliasesDAOImpl
is below:
 
---snip---
 /**  * This method was generated by Abator for iBATIS. This method corresponds to the database
table aliases  * @abatorgenerated  Fri Sep 05 23:35:30 EST 2008  */ public AliasesDAOImpl
( SqlMapClient sqlMapClient ) {  super ();  this.sqlMapClient = sqlMapClient; }
---snip---
Is there a config option for abatorConfig.xml that tells Ibator to build classes including
a constructor that takes a DaoManager object?
 
Thanks,
 
Paul



Subject: RE: java.lang.InstantiationException using Ibatis DAODate: Mon, 8 Sep 2008 08:56:37
+0200From: n.beekman@wis.nlTo: user-java@ibatis.apache.org






Your AliasesDaoImpl should have a public constructor that takes a DaoManager as its single
argument. Can you check that this is the case?
 
Hth,
 
Niels




From: Paul Ski [mailto:paulski82@hotmail.com] Sent: Sunday, September 07, 2008 3:47 AMTo:
user-java@ibatis.apache.orgSubject: java.lang.InstantiationException using Ibatis DAO
 
Hi list, Environment: - Windows XP- Java(TM) SE Runtime Environment (build 1.6.0_10-rc-b28)-
Eclipse Version: 3.4.0 Build id: I20080617-2000- Ibatis 2.3.0.677 Project Jars:mysql-connector-java-5.1.6-bin.jaribatis-2.3.0.677.jaribatis-dao-2.jar
I've created a class to return me a DaoManager object ---snip---import java.io.Reader;import
com.ibatis.common.resources.Resources;import com.ibatis.dao.client.DaoManager;import com.ibatis.dao.client.DaoManagerBuilder;
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;
}}---snip--- Test stub to call the code is: ---snip---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 (); }}---snip--- DAO Config: ---snip---<?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>---snip--- ---snip---<?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"
/>...</sqlMapConfig>---snip--- Exception: ---snip---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---snip---
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. Thanks, Paul



Enter today! Win a Hotmail Go-Kart to race at Bathurst.
_________________________________________________________________
Are you paid what you're worth? Find out: SEEK Salary Centre
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eseek%2Ecom%2Eau%2Fcareer%2Dresources%2Fsalary%2Dcentre%2F%3Ftracking%3Dsk%3Ahet%3Asc%3Anine%3A0%3Ahot%3Atext&_t=764565661&_r=OCT07_endtext_salary&_m=EXT
Mime
View raw message