You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Paul Ski <pa...@hotmail.com> on 2008/09/07 03:47:05 UTC
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.jar
ibatis-2.3.0.677.jar
ibatis-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
_________________________________________________________________
Win a Hotmail Go-Kart to race at Bathurst. Enter today!
http://www.livelife.ninemsn.com.au/compIntro.aspx?compId=4602
RE: java.lang.InstantiationException using Ibatis DAO
Posted by Paul Ski <pa...@hotmail.com>.
Done.
http://opensource.atlassian.com/confluence/oss/x/HwApAQ
Hope that is what you are after.
Thanks for you help.
:-)
Paul
________________________________
> Subject: RE: java.lang.InstantiationException using Ibatis DAO
> Date: Mon, 15 Sep 2008 18:56:29 +0200
> From: n.beekman@wis.nl
> To: user-java@ibatis.apache.org
>
>
> At least I got that part right. I’m glad you resolved the issue. You might want to document this on the wiki, it could be of help to others
>
>
>
> Niels
>
> ________________________________
>
> From: Paul Ski [mailto:paulski82@hotmail.com]
> Sent: Monday, September 15, 2008 3:07 PM
> To: user-java@ibatis.apache.org
> Subject: RE: java.lang.InstantiationException using Ibatis DAO
>
>
>
> The problem was with my Ibator config file. I changed the line from:
>
> ---snip---
>
> ---snip---
>
> to:
>
> ---snip---
>
> ---snip---
>
> This caused my to generate AliasesDAOImpl with the correct constructor. E.g.:
>
> ---snip---
> ...
>
> public class AliasesDAOImpl extends SqlMapDaoTemplate implements AliasesDAO
> {
> /**
> * This method was generated by Abator for iBATIS. This method corresponds to the database table aliases
> * @abatorgenerated Mon Sep 15 22:48:36 EST 2008
> */
> public AliasesDAOImpl ( DaoManager daoManager )
> {
> super ( daoManager );
> }
>
> ...
> ---snip---
>
> Thanks,
>
> Paul
_________________________________________________________________
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
RE: java.lang.InstantiationException using Ibatis DAO
Posted by Niels Beekman <n....@wis.nl>.
At least I got that part right. I'm glad you resolved the issue. You
might want to document this on the wiki, it could be of help to others
Niels
________________________________
From: Paul Ski [mailto:paulski82@hotmail.com]
Sent: Monday, September 15, 2008 3:07 PM
To: user-java@ibatis.apache.org
Subject: RE: java.lang.InstantiationException using Ibatis DAO
The problem was with my Ibator config file. I changed the line from:
---snip---
<daoGenerator targetPackage="com.intient.smash.ibatis.impl"
targetProject="Smash" type="GENERIC-CI" />
---snip---
to:
---snip---
<daoGenerator targetPackage="com.intient.smash.ibatis.impl"
targetProject="Smash" type="IBATIS" />
---snip---
This caused my to generate AliasesDAOImpl with the correct constructor.
E.g.:
---snip---
...
public class AliasesDAOImpl extends SqlMapDaoTemplate implements
AliasesDAO
{
/**
* This method was generated by Abator for iBATIS. This method
corresponds to the database table aliases
* @abatorgenerated Mon Sep 15 22:48:36 EST 2008
*/
public AliasesDAOImpl ( DaoManager daoManager )
{
super ( daoManager );
}
...
---snip---
Thanks,
Paul
RE: java.lang.InstantiationException using Ibatis DAO
Posted by Paul Ski <pa...@hotmail.com>.
The problem was with my Ibator config file. I changed the line from:
---snip---<daoGenerator targetPackage="com.intient.smash.ibatis.impl" targetProject="Smash" type="GENERIC-CI" />---snip---
to:
---snip---<daoGenerator targetPackage="com.intient.smash.ibatis.impl" targetProject="Smash" type="IBATIS" />---snip---
This caused my to generate AliasesDAOImpl with the correct constructor. E.g.:
---snip---
...
public class AliasesDAOImpl extends SqlMapDaoTemplate implements AliasesDAO{
/** * This method was generated by Abator for iBATIS. This method corresponds to the database table aliases * @abatorgenerated Mon Sep 15 22:48:36 EST 2008 */ public AliasesDAOImpl ( DaoManager daoManager ) { super ( daoManager ); }
...---snip---
Thanks,
Paul
From: paulski82@hotmail.comTo: user-java@ibatis.apache.orgSubject: RE: java.lang.InstantiationException using Ibatis DAODate: Wed, 10 Sep 2008 00:54:04 +1030
Abator version is 1.1.0 for Eclipse 3.2.0 if it helps.
Subject: RE: java.lang.InstantiationException using Ibatis DAODate: Tue, 9 Sep 2008 15:55:18 +0200From: n.beekman@wis.nlTo: user-java@ibatis.apache.org
I don’t understand. If this code is generated by Ibator, I would say that somehow you have a version mismatch. Maybe Jeff can comment on this?
Niels
From: Paul Ski [mailto:paulski82@hotmail.com] Sent: Tuesday, September 09, 2008 10:20 AMTo: user-java@ibatis.apache.orgSubject: RE: java.lang.InstantiationException using Ibatis DAO
package com.intient.smash.ibatis.impl;import com.ibatis.sqlmap.client.SqlMapClient;import com.intient.smash.ibatis.Aliases;import com.intient.smash.ibatis.AliasesExample;import java.sql.SQLException;import java.util.List;public class AliasesDAOImpl implements AliasesDAO{ /** * This field was generated by Abator for iBATIS. This field corresponds to the database table aliases * @abatorgenerated Fri Sep 05 23:35:30 EST 2008 */ private SqlMapClient sqlMapClient; /** * 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; } /** * 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 void insert ( Aliases record ) throws SQLException { sqlMapClient.insert ( "aliases.abatorgenerated_insert", record ); } /** * 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 int updateByPrimaryKey ( Aliases record ) throws SQLException { int rows = sqlMapClient.update ( "aliases.abatorgenerated_updateByPrimaryKey", record ); return rows; } /** * 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 int updateByPrimaryKeySelective ( Aliases record ) throws SQLException { int rows = sqlMapClient.update ( "aliases.abatorgenerated_updateByPrimaryKeySelective", record ); return rows; } /** * 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 List selectByExample ( AliasesExample example ) throws SQLException { List list = sqlMapClient.queryForList ( "aliases.abatorgenerated_selectByExample", example ); return list; } /** * 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 Aliases selectByPrimaryKey ( Integer id ) throws SQLException { Aliases key = new Aliases (); key.setId ( id ); Aliases record = (Aliases)sqlMapClient.queryForObject ( "aliases.abatorgenerated_selectByPrimaryKey", key ); return record; } /** * 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 int deleteByExample ( AliasesExample example ) throws SQLException { int rows = sqlMapClient.delete ( "aliases.abatorgenerated_deleteByExample", example ); return rows; } /** * 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 int deleteByPrimaryKey ( Integer id ) throws SQLException { Aliases key = new Aliases (); key.setId ( id ); int rows = sqlMapClient.delete ( "aliases.abatorgenerated_deleteByPrimaryKey", key ); return rows; } /** * 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 int countByExample ( AliasesExample example ) throws SQLException { Integer count = (Integer)sqlMapClient.queryForObject ( "aliases.abatorgenerated_countByExample", example ); return count.intValue (); } /** * 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 int updateByExampleSelective ( Aliases record, AliasesExample example ) throws SQLException { UpdateByExampleParms parms = new UpdateByExampleParms ( record, example ); int rows = sqlMapClient.update ( "aliases.abatorgenerated_updateByExampleSelective", parms ); return rows; } /** * 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 int updateByExample ( Aliases record, AliasesExample example ) throws SQLException { UpdateByExampleParms parms = new UpdateByExampleParms ( record, example ); int rows = sqlMapClient.update ( "aliases.abatorgenerated_updateByExample", parms ); return rows; } /** * This class was generated by Abator for iBATIS. This class corresponds to the database table aliases * @abatorgenerated Fri Sep 05 23:35:30 EST 2008 */ private static class UpdateByExampleParms extends AliasesExample { private Object record; public UpdateByExampleParms ( Object record, AliasesExample example ) { super ( example ); this.record = record; } public Object getRecord () { return record; } }}
Subject: RE: java.lang.InstantiationException using Ibatis DAODate: Mon, 8 Sep 2008 11:37:14 +0200From: n.beekman@wis.nlTo: user-java@ibatis.apache.org
Please include the contents of com.intient.smash.ibatis.impl.AliasesDAOImpl, this has definitely something to do with class/member visibility.
From: Paul Ski [mailto:paulski82@hotmail.com] Sent: Monday, September 08, 2008 11:31 AMTo: user-java@ibatis.apache.orgSubject: RE: java.lang.InstantiationException using Ibatis DAO
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.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(XmlDaoManagerBuilder.java:129) at com.ibatis.dao.client.DaoManagerBuilder.buildDaoManager(DaoManagerBuilder.java:59) at com.intient.smash.DaoManagerMapper.<clinit>(DaoManagerMapper.java:17) at com.intient.smash.TestDaoManagerMapper.<init>(TestDaoManagerMapper.java:13) at com.intient.smash.TestDaoManagerMapper.main(TestDaoManagerMapper.java:39)Caused by: com.ibatis.dao.client.DaoException: Error configuring DAO. Cause: java.lang.InstantiationException: com.intient.smash.ibatis.impl.AliasesDAOImpl at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseDao(XmlDaoManagerBuilder.java:231) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseContext(XmlDaoManagerBuilder.java:160) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(XmlDaoManagerBuilder.java:102) ... 4 moreCaused by: java.lang.InstantiationException: com.intient.smash.ibatis.impl.AliasesDAOImpl at java.lang.Class.newInstance0(Class.java:340) at java.lang.Class.newInstance(Class.java:308) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseDao(XmlDaoManagerBuilder.java:225) ... 6 moreException in thread "main" java.lang.ExceptionInInitializerError at com.intient.smash.TestDaoManagerMapper.<init>(TestDaoManagerMapper.java:13) at com.intient.smash.TestDaoManagerMapper.main(TestDaoManagerMapper.java:39)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:22) ... 2 more
Subject: RE: java.lang.InstantiationException using Ibatis DAODate: Mon, 8 Sep 2008 09:55:56 +0200From: n.beekman@wis.nlTo: user-java@ibatis.apache.org
Can you post the complete stacktrace?
From: Paul Ski [mailto:paulski82@hotmail.com] Sent: Monday, September 08, 2008 9:14 AMTo: user-java@ibatis.apache.orgSubject: RE: java.lang.InstantiationException using Ibatis DAO
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
Sell your car for just $40 at CarPoint.com.au It's simple!
Find great deals on eBay Net yourself a bargain
Play now to win prizes for you and your friends! Are you a friend magnet?
_________________________________________________________________
Are you a friend magnet? Play now to win prizes for you and your friends!
http://clk.atdmt.com/GBL/go/106906016/direct/01/?href=http://www.friendmagnet.com.au
RE: java.lang.InstantiationException using Ibatis DAO
Posted by Paul Ski <pa...@hotmail.com>.
Abator version is 1.1.0 for Eclipse 3.2.0 if it helps.
Subject: RE: java.lang.InstantiationException using Ibatis DAODate: Tue, 9 Sep 2008 15:55:18 +0200From: n.beekman@wis.nlTo: user-java@ibatis.apache.org
I don’t understand. If this code is generated by Ibator, I would say that somehow you have a version mismatch. Maybe Jeff can comment on this?
Niels
From: Paul Ski [mailto:paulski82@hotmail.com] Sent: Tuesday, September 09, 2008 10:20 AMTo: user-java@ibatis.apache.orgSubject: RE: java.lang.InstantiationException using Ibatis DAO
package com.intient.smash.ibatis.impl;import com.ibatis.sqlmap.client.SqlMapClient;import com.intient.smash.ibatis.Aliases;import com.intient.smash.ibatis.AliasesExample;import java.sql.SQLException;import java.util.List;public class AliasesDAOImpl implements AliasesDAO{ /** * This field was generated by Abator for iBATIS. This field corresponds to the database table aliases * @abatorgenerated Fri Sep 05 23:35:30 EST 2008 */ private SqlMapClient sqlMapClient; /** * 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; } /** * 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 void insert ( Aliases record ) throws SQLException { sqlMapClient.insert ( "aliases.abatorgenerated_insert", record ); } /** * 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 int updateByPrimaryKey ( Aliases record ) throws SQLException { int rows = sqlMapClient.update ( "aliases.abatorgenerated_updateByPrimaryKey", record ); return rows; } /** * 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 int updateByPrimaryKeySelective ( Aliases record ) throws SQLException { int rows = sqlMapClient.update ( "aliases.abatorgenerated_updateByPrimaryKeySelective", record ); return rows; } /** * 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 List selectByExample ( AliasesExample example ) throws SQLException { List list = sqlMapClient.queryForList ( "aliases.abatorgenerated_selectByExample", example ); return list; } /** * 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 Aliases selectByPrimaryKey ( Integer id ) throws SQLException { Aliases key = new Aliases (); key.setId ( id ); Aliases record = (Aliases)sqlMapClient.queryForObject ( "aliases.abatorgenerated_selectByPrimaryKey", key ); return record; } /** * 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 int deleteByExample ( AliasesExample example ) throws SQLException { int rows = sqlMapClient.delete ( "aliases.abatorgenerated_deleteByExample", example ); return rows; } /** * 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 int deleteByPrimaryKey ( Integer id ) throws SQLException { Aliases key = new Aliases (); key.setId ( id ); int rows = sqlMapClient.delete ( "aliases.abatorgenerated_deleteByPrimaryKey", key ); return rows; } /** * 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 int countByExample ( AliasesExample example ) throws SQLException { Integer count = (Integer)sqlMapClient.queryForObject ( "aliases.abatorgenerated_countByExample", example ); return count.intValue (); } /** * 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 int updateByExampleSelective ( Aliases record, AliasesExample example ) throws SQLException { UpdateByExampleParms parms = new UpdateByExampleParms ( record, example ); int rows = sqlMapClient.update ( "aliases.abatorgenerated_updateByExampleSelective", parms ); return rows; } /** * 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 int updateByExample ( Aliases record, AliasesExample example ) throws SQLException { UpdateByExampleParms parms = new UpdateByExampleParms ( record, example ); int rows = sqlMapClient.update ( "aliases.abatorgenerated_updateByExample", parms ); return rows; } /** * This class was generated by Abator for iBATIS. This class corresponds to the database table aliases * @abatorgenerated Fri Sep 05 23:35:30 EST 2008 */ private static class UpdateByExampleParms extends AliasesExample { private Object record; public UpdateByExampleParms ( Object record, AliasesExample example ) { super ( example ); this.record = record; } public Object getRecord () { return record; } }}
Subject: RE: java.lang.InstantiationException using Ibatis DAODate: Mon, 8 Sep 2008 11:37:14 +0200From: n.beekman@wis.nlTo: user-java@ibatis.apache.org
Please include the contents of com.intient.smash.ibatis.impl.AliasesDAOImpl, this has definitely something to do with class/member visibility.
From: Paul Ski [mailto:paulski82@hotmail.com] Sent: Monday, September 08, 2008 11:31 AMTo: user-java@ibatis.apache.orgSubject: RE: java.lang.InstantiationException using Ibatis DAO
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.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(XmlDaoManagerBuilder.java:129) at com.ibatis.dao.client.DaoManagerBuilder.buildDaoManager(DaoManagerBuilder.java:59) at com.intient.smash.DaoManagerMapper.<clinit>(DaoManagerMapper.java:17) at com.intient.smash.TestDaoManagerMapper.<init>(TestDaoManagerMapper.java:13) at com.intient.smash.TestDaoManagerMapper.main(TestDaoManagerMapper.java:39)Caused by: com.ibatis.dao.client.DaoException: Error configuring DAO. Cause: java.lang.InstantiationException: com.intient.smash.ibatis.impl.AliasesDAOImpl at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseDao(XmlDaoManagerBuilder.java:231) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseContext(XmlDaoManagerBuilder.java:160) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(XmlDaoManagerBuilder.java:102) ... 4 moreCaused by: java.lang.InstantiationException: com.intient.smash.ibatis.impl.AliasesDAOImpl at java.lang.Class.newInstance0(Class.java:340) at java.lang.Class.newInstance(Class.java:308) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseDao(XmlDaoManagerBuilder.java:225) ... 6 moreException in thread "main" java.lang.ExceptionInInitializerError at com.intient.smash.TestDaoManagerMapper.<init>(TestDaoManagerMapper.java:13) at com.intient.smash.TestDaoManagerMapper.main(TestDaoManagerMapper.java:39)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:22) ... 2 more
Subject: RE: java.lang.InstantiationException using Ibatis DAODate: Mon, 8 Sep 2008 09:55:56 +0200From: n.beekman@wis.nlTo: user-java@ibatis.apache.org
Can you post the complete stacktrace?
From: Paul Ski [mailto:paulski82@hotmail.com] Sent: Monday, September 08, 2008 9:14 AMTo: user-java@ibatis.apache.orgSubject: RE: java.lang.InstantiationException using Ibatis DAO
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
Sell your car for just $40 at CarPoint.com.au It's simple!
Find great deals on eBay Net yourself a bargain
_________________________________________________________________
Are you a friend magnet? Play now to win prizes for you and your friends!
http://clk.atdmt.com/GBL/go/106906016/direct/01/?href=http://www.friendmagnet.com.au
RE: java.lang.InstantiationException using Ibatis DAO
Posted by Niels Beekman <n....@wis.nl>.
I don't understand. If this code is generated by Ibator, I would say
that somehow you have a version mismatch. Maybe Jeff can comment on
this?
Niels
________________________________
From: Paul Ski [mailto:paulski82@hotmail.com]
Sent: Tuesday, September 09, 2008 10:20 AM
To: user-java@ibatis.apache.org
Subject: RE: java.lang.InstantiationException using Ibatis DAO
package com.intient.smash.ibatis.impl;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.intient.smash.ibatis.Aliases;
import com.intient.smash.ibatis.AliasesExample;
import java.sql.SQLException;
import java.util.List;
public class AliasesDAOImpl implements AliasesDAO
{
/**
* This field was generated by Abator for iBATIS. This field
corresponds to the database table aliases
* @abatorgenerated Fri Sep 05 23:35:30 EST 2008
*/
private SqlMapClient sqlMapClient;
/**
* 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;
}
/**
* 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 void insert ( Aliases record ) throws SQLException
{
sqlMapClient.insert ( "aliases.abatorgenerated_insert", record );
}
/**
* 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 int updateByPrimaryKey ( Aliases record ) throws SQLException
{
int rows = sqlMapClient.update (
"aliases.abatorgenerated_updateByPrimaryKey", record );
return rows;
}
/**
* 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 int updateByPrimaryKeySelective ( Aliases record )
throws SQLException
{
int rows = sqlMapClient.update (
"aliases.abatorgenerated_updateByPrimaryKeySelective", record );
return rows;
}
/**
* 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 List selectByExample ( AliasesExample example ) throws
SQLException
{
List list = sqlMapClient.queryForList (
"aliases.abatorgenerated_selectByExample", example );
return list;
}
/**
* 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 Aliases selectByPrimaryKey ( Integer id ) throws SQLException
{
Aliases key = new Aliases ();
key.setId ( id );
Aliases record = (Aliases)sqlMapClient.queryForObject (
"aliases.abatorgenerated_selectByPrimaryKey", key );
return record;
}
/**
* 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 int deleteByExample ( AliasesExample example ) throws
SQLException
{
int rows = sqlMapClient.delete (
"aliases.abatorgenerated_deleteByExample", example );
return rows;
}
/**
* 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 int deleteByPrimaryKey ( Integer id ) throws SQLException
{
Aliases key = new Aliases ();
key.setId ( id );
int rows = sqlMapClient.delete (
"aliases.abatorgenerated_deleteByPrimaryKey", key );
return rows;
}
/**
* 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 int countByExample ( AliasesExample example ) throws
SQLException
{
Integer count = (Integer)sqlMapClient.queryForObject (
"aliases.abatorgenerated_countByExample", example );
return count.intValue ();
}
/**
* 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 int updateByExampleSelective ( Aliases record, AliasesExample
example )
throws SQLException
{
UpdateByExampleParms parms = new UpdateByExampleParms ( record,
example );
int rows = sqlMapClient.update (
"aliases.abatorgenerated_updateByExampleSelective", parms );
return rows;
}
/**
* 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 int updateByExample ( Aliases record, AliasesExample example )
throws SQLException
{
UpdateByExampleParms parms = new UpdateByExampleParms ( record,
example );
int rows = sqlMapClient.update (
"aliases.abatorgenerated_updateByExample", parms );
return rows;
}
/**
* This class was generated by Abator for iBATIS. This class
corresponds to the database table aliases
* @abatorgenerated Fri Sep 05 23:35:30 EST 2008
*/
private static class UpdateByExampleParms extends AliasesExample
{
private Object record;
public UpdateByExampleParms ( Object record, AliasesExample example )
{
super ( example );
this.record = record;
}
public Object getRecord ()
{
return record;
}
}
}
________________________________
Subject: RE: java.lang.InstantiationException using Ibatis DAO
Date: Mon, 8 Sep 2008 11:37:14 +0200
From: n.beekman@wis.nl
To: user-java@ibatis.apache.org
Please include the contents of
com.intient.smash.ibatis.impl.AliasesDAOImpl, this has definitely
something to do with class/member visibility.
________________________________
From: Paul Ski [mailto:paulski82@hotmail.com]
Sent: Monday, September 08, 2008 11:31 AM
To: user-java@ibatis.apache.org
Subject: RE: java.lang.InstantiationException using Ibatis DAO
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.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(X
mlDaoManagerBuilder.java:129)
at
com.ibatis.dao.client.DaoManagerBuilder.buildDaoManager(DaoManagerBuilde
r.java:59)
at
com.intient.smash.DaoManagerMapper.<clinit>(DaoManagerMapper.java:17)
at
com.intient.smash.TestDaoManagerMapper.<init>(TestDaoManagerMapper.java:
13)
at
com.intient.smash.TestDaoManagerMapper.main(TestDaoManagerMapper.java:39
)
Caused by: com.ibatis.dao.client.DaoException: Error configuring DAO.
Cause: java.lang.InstantiationException:
com.intient.smash.ibatis.impl.AliasesDAOImpl
at
com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseDao(XmlDaoMa
nagerBuilder.java:231)
at
com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseContext(XmlD
aoManagerBuilder.java:160)
at
com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(X
mlDaoManagerBuilder.java:102)
... 4 more
Caused by: java.lang.InstantiationException:
com.intient.smash.ibatis.impl.AliasesDAOImpl
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at
com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseDao(XmlDaoMa
nagerBuilder.java:225)
... 6 more
Exception in thread "main" java.lang.ExceptionInInitializerError
at
com.intient.smash.TestDaoManagerMapper.<init>(TestDaoManagerMapper.java:
13)
at
com.intient.smash.TestDaoManagerMapper.main(TestDaoManagerMapper.java:39
)
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:22)
... 2 more
________________________________
Subject: RE: java.lang.InstantiationException using Ibatis DAO
Date: Mon, 8 Sep 2008 09:55:56 +0200
From: n.beekman@wis.nl
To: user-java@ibatis.apache.org
Can you post the complete stacktrace?
________________________________
From: Paul Ski [mailto:paulski82@hotmail.com]
Sent: Monday, September 08, 2008 9:14 AM
To: user-java@ibatis.apache.org
Subject: RE: java.lang.InstantiationException using Ibatis DAO
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 DAO
Date: Mon, 8 Sep 2008 08:56:37 +0200
From: n.beekman@wis.nl
To: 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
________________________________
Sell your car for just $40 at CarPoint.com.au It's simple!
<http://a.ninemsn.com.au/b.aspx?URL=http://secure-au.imrworldwide.com/cg
i-bin/a/ci_450304/et_2/cg_801459/pi_1004813/ai_859641&_t=762955845&_r=ti
g_OCT07&_m=EXT>
________________________________
Find great deals on eBay Net yourself a bargain
<http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Frover%2Eebay%2Ecom%2Fro
ver%2F1%2F705%2D10129%2D5668%2D323%2F4%3Fid%3D10&_t=763807330&_r=hotmail
TAGLINES&_m=EXT>
RE: java.lang.InstantiationException using Ibatis DAO
Posted by Paul Ski <pa...@hotmail.com>.
package com.intient.smash.ibatis.impl;
import com.ibatis.sqlmap.client.SqlMapClient;import com.intient.smash.ibatis.Aliases;import com.intient.smash.ibatis.AliasesExample;import java.sql.SQLException;import java.util.List;
public class AliasesDAOImpl implements AliasesDAO{
/** * This field was generated by Abator for iBATIS. This field corresponds to the database table aliases * @abatorgenerated Fri Sep 05 23:35:30 EST 2008 */ private SqlMapClient sqlMapClient;
/** * 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; }
/** * 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 void insert ( Aliases record ) throws SQLException { sqlMapClient.insert ( "aliases.abatorgenerated_insert", record ); }
/** * 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 int updateByPrimaryKey ( Aliases record ) throws SQLException { int rows = sqlMapClient.update ( "aliases.abatorgenerated_updateByPrimaryKey", record ); return rows; }
/** * 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 int updateByPrimaryKeySelective ( Aliases record ) throws SQLException { int rows = sqlMapClient.update ( "aliases.abatorgenerated_updateByPrimaryKeySelective", record ); return rows; }
/** * 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 List selectByExample ( AliasesExample example ) throws SQLException { List list = sqlMapClient.queryForList ( "aliases.abatorgenerated_selectByExample", example ); return list; }
/** * 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 Aliases selectByPrimaryKey ( Integer id ) throws SQLException { Aliases key = new Aliases (); key.setId ( id ); Aliases record = (Aliases)sqlMapClient.queryForObject ( "aliases.abatorgenerated_selectByPrimaryKey", key ); return record; }
/** * 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 int deleteByExample ( AliasesExample example ) throws SQLException { int rows = sqlMapClient.delete ( "aliases.abatorgenerated_deleteByExample", example ); return rows; }
/** * 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 int deleteByPrimaryKey ( Integer id ) throws SQLException { Aliases key = new Aliases (); key.setId ( id ); int rows = sqlMapClient.delete ( "aliases.abatorgenerated_deleteByPrimaryKey", key ); return rows; }
/** * 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 int countByExample ( AliasesExample example ) throws SQLException { Integer count = (Integer)sqlMapClient.queryForObject ( "aliases.abatorgenerated_countByExample", example ); return count.intValue (); }
/** * 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 int updateByExampleSelective ( Aliases record, AliasesExample example ) throws SQLException { UpdateByExampleParms parms = new UpdateByExampleParms ( record, example ); int rows = sqlMapClient.update ( "aliases.abatorgenerated_updateByExampleSelective", parms ); return rows; }
/** * 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 int updateByExample ( Aliases record, AliasesExample example ) throws SQLException { UpdateByExampleParms parms = new UpdateByExampleParms ( record, example ); int rows = sqlMapClient.update ( "aliases.abatorgenerated_updateByExample", parms ); return rows; }
/** * This class was generated by Abator for iBATIS. This class corresponds to the database table aliases * @abatorgenerated Fri Sep 05 23:35:30 EST 2008 */ private static class UpdateByExampleParms extends AliasesExample { private Object record;
public UpdateByExampleParms ( Object record, AliasesExample example ) { super ( example ); this.record = record; }
public Object getRecord () { return record; } }}
Subject: RE: java.lang.InstantiationException using Ibatis DAODate: Mon, 8 Sep 2008 11:37:14 +0200From: n.beekman@wis.nlTo: user-java@ibatis.apache.org
Please include the contents of com.intient.smash.ibatis.impl.AliasesDAOImpl, this has definitely something to do with class/member visibility.
From: Paul Ski [mailto:paulski82@hotmail.com] Sent: Monday, September 08, 2008 11:31 AMTo: user-java@ibatis.apache.orgSubject: RE: java.lang.InstantiationException using Ibatis DAO
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.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(XmlDaoManagerBuilder.java:129) at com.ibatis.dao.client.DaoManagerBuilder.buildDaoManager(DaoManagerBuilder.java:59) at com.intient.smash.DaoManagerMapper.<clinit>(DaoManagerMapper.java:17) at com.intient.smash.TestDaoManagerMapper.<init>(TestDaoManagerMapper.java:13) at com.intient.smash.TestDaoManagerMapper.main(TestDaoManagerMapper.java:39)Caused by: com.ibatis.dao.client.DaoException: Error configuring DAO. Cause: java.lang.InstantiationException: com.intient.smash.ibatis.impl.AliasesDAOImpl at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseDao(XmlDaoManagerBuilder.java:231) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseContext(XmlDaoManagerBuilder.java:160) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(XmlDaoManagerBuilder.java:102) ... 4 moreCaused by: java.lang.InstantiationException: com.intient.smash.ibatis.impl.AliasesDAOImpl at java.lang.Class.newInstance0(Class.java:340) at java.lang.Class.newInstance(Class.java:308) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseDao(XmlDaoManagerBuilder.java:225) ... 6 moreException in thread "main" java.lang.ExceptionInInitializerError at com.intient.smash.TestDaoManagerMapper.<init>(TestDaoManagerMapper.java:13) at com.intient.smash.TestDaoManagerMapper.main(TestDaoManagerMapper.java:39)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:22) ... 2 more
Subject: RE: java.lang.InstantiationException using Ibatis DAODate: Mon, 8 Sep 2008 09:55:56 +0200From: n.beekman@wis.nlTo: user-java@ibatis.apache.org
Can you post the complete stacktrace?
From: Paul Ski [mailto:paulski82@hotmail.com] Sent: Monday, September 08, 2008 9:14 AMTo: user-java@ibatis.apache.orgSubject: RE: java.lang.InstantiationException using Ibatis DAO
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
Sell your car for just $40 at CarPoint.com.au It's simple!
_________________________________________________________________
Net yourself a bargain. Find great deals on eBay.
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Frover%2Eebay%2Ecom%2Frover%2F1%2F705%2D10129%2D5668%2D323%2F4%3Fid%3D10&_t=763807330&_r=hotmailTAGLINES&_m=EXT
RE: java.lang.InstantiationException using Ibatis DAO
Posted by Niels Beekman <n....@wis.nl>.
Please include the contents of
com.intient.smash.ibatis.impl.AliasesDAOImpl, this has definitely
something to do with class/member visibility.
________________________________
From: Paul Ski [mailto:paulski82@hotmail.com]
Sent: Monday, September 08, 2008 11:31 AM
To: user-java@ibatis.apache.org
Subject: RE: java.lang.InstantiationException using Ibatis DAO
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.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(X
mlDaoManagerBuilder.java:129)
at
com.ibatis.dao.client.DaoManagerBuilder.buildDaoManager(DaoManagerBuilde
r.java:59)
at
com.intient.smash.DaoManagerMapper.<clinit>(DaoManagerMapper.java:17)
at
com.intient.smash.TestDaoManagerMapper.<init>(TestDaoManagerMapper.java:
13)
at
com.intient.smash.TestDaoManagerMapper.main(TestDaoManagerMapper.java:39
)
Caused by: com.ibatis.dao.client.DaoException: Error configuring DAO.
Cause: java.lang.InstantiationException:
com.intient.smash.ibatis.impl.AliasesDAOImpl
at
com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseDao(XmlDaoMa
nagerBuilder.java:231)
at
com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseContext(XmlD
aoManagerBuilder.java:160)
at
com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(X
mlDaoManagerBuilder.java:102)
... 4 more
Caused by: java.lang.InstantiationException:
com.intient.smash.ibatis.impl.AliasesDAOImpl
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at
com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseDao(XmlDaoMa
nagerBuilder.java:225)
... 6 more
Exception in thread "main" java.lang.ExceptionInInitializerError
at
com.intient.smash.TestDaoManagerMapper.<init>(TestDaoManagerMapper.java:
13)
at
com.intient.smash.TestDaoManagerMapper.main(TestDaoManagerMapper.java:39
)
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:22)
... 2 more
________________________________
Subject: RE: java.lang.InstantiationException using Ibatis DAO
Date: Mon, 8 Sep 2008 09:55:56 +0200
From: n.beekman@wis.nl
To: user-java@ibatis.apache.org
Can you post the complete stacktrace?
________________________________
From: Paul Ski [mailto:paulski82@hotmail.com]
Sent: Monday, September 08, 2008 9:14 AM
To: user-java@ibatis.apache.org
Subject: RE: java.lang.InstantiationException using Ibatis DAO
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 DAO
Date: Mon, 8 Sep 2008 08:56:37 +0200
From: n.beekman@wis.nl
To: 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
________________________________
Sell your car for just $40 at CarPoint.com.au It's simple!
<http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldw
ide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F10
04813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT>
RE: java.lang.InstantiationException using Ibatis DAO
Posted by Paul Ski <pa...@hotmail.com>.
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.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(XmlDaoManagerBuilder.java:129) at com.ibatis.dao.client.DaoManagerBuilder.buildDaoManager(DaoManagerBuilder.java:59) at com.intient.smash.DaoManagerMapper.<clinit>(DaoManagerMapper.java:17) at com.intient.smash.TestDaoManagerMapper.<init>(TestDaoManagerMapper.java:13) at com.intient.smash.TestDaoManagerMapper.main(TestDaoManagerMapper.java:39)Caused by: com.ibatis.dao.client.DaoException: Error configuring DAO. Cause: java.lang.InstantiationException: com.intient.smash.ibatis.impl.AliasesDAOImpl at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseDao(XmlDaoManagerBuilder.java:231) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseContext(XmlDaoManagerBuilder.java:160) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.buildDaoManager(XmlDaoManagerBuilder.java:102) ... 4 moreCaused by: java.lang.InstantiationException: com.intient.smash.ibatis.impl.AliasesDAOImpl at java.lang.Class.newInstance0(Class.java:340) at java.lang.Class.newInstance(Class.java:308) at com.ibatis.dao.engine.builder.xml.XmlDaoManagerBuilder.parseDao(XmlDaoManagerBuilder.java:225) ... 6 moreException in thread "main" java.lang.ExceptionInInitializerError at com.intient.smash.TestDaoManagerMapper.<init>(TestDaoManagerMapper.java:13) at com.intient.smash.TestDaoManagerMapper.main(TestDaoManagerMapper.java:39)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:22) ... 2 more
Subject: RE: java.lang.InstantiationException using Ibatis DAODate: Mon, 8 Sep 2008 09:55:56 +0200From: n.beekman@wis.nlTo: user-java@ibatis.apache.org
Can you post the complete stacktrace?
From: Paul Ski [mailto:paulski82@hotmail.com] Sent: Monday, September 08, 2008 9:14 AMTo: user-java@ibatis.apache.orgSubject: RE: java.lang.InstantiationException using Ibatis DAO
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
_________________________________________________________________
It's simple! Sell your car for just $40 at CarPoint.com.au
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT
RE: java.lang.InstantiationException using Ibatis DAO
Posted by Niels Beekman <n....@wis.nl>.
Can you post the complete stacktrace?
________________________________
From: Paul Ski [mailto:paulski82@hotmail.com]
Sent: Monday, September 08, 2008 9:14 AM
To: user-java@ibatis.apache.org
Subject: RE: java.lang.InstantiationException using Ibatis DAO
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 DAO
Date: Mon, 8 Sep 2008 08:56:37 +0200
From: n.beekman@wis.nl
To: 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
RE: java.lang.InstantiationException using Ibatis DAO
Posted by Paul Ski <pa...@hotmail.com>.
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
RE: java.lang.InstantiationException using Ibatis DAO
Posted by Niels Beekman <n....@wis.nl>.
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 AM
To: user-java@ibatis.apache.org
Subject: 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.jar
ibatis-2.3.0.677.jar
ibatis-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.
<http://www.livelife.ninemsn.com.au/compIntro.aspx?compId=4602>