ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 梁炳場 <pc.le...@gmail.com>
Subject Fail to find JNDI ?
Date Mon, 12 Sep 2005 01:19:16 GMT
My present java program can get the JNDI, no problem at all.
	DataSource ds =
(DataSource)ctx.lookup("java:comp/env/jdbc/erp");	conn =
ds.getConnection();

However getting thru iBatis, it fails. 
Can anyone tell where goes wrong?
Thnx



My UserProfileService goes like this
public class UserProfileService {

  /* Constants */

  private static final UserProfileService instance = new UserProfileService();

  /* Private Fields */

  private DaoManager daoManager = DaoConfig.getDaomanager();

  private UserProfileDAO userProfileDao;

  /* Constructors */

  public UserProfileService() {
	  userProfileDao = (UserProfileDAO) daoManager.getDao(UserProfileDAO.class);
  }

  /* Public Methods */

  public static UserProfileService getInstance() {
    return instance;
  }


My DaoConfig.java like this.

public class DaoConfig {

  private static final DaoManager daoManager;

  static {

    try {
      String resource = "com/erp/user/dao/DAO.xml";
      Reader reader = Resources.getResourceAsReader(resource);
      daoManager = DaoManagerBuilder.buildDaoManager(reader);
    } catch (Exception e) {
      throw new RuntimeException("Could not initialize DaoConfig. 
Cause: " + e);
    }
  }
  public static DaoManager getDaomanager() {
    return daoManager;
  }
}

My DAO.xml likes this

<?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>
	<context id="jdbc">
		<transactionManager type="JDBC">
          <property name="DataSource" value="JNDI"/>
          <property name="DBJndiContext" value="java:comp/env/jdbc/erp"/>
		</transactionManager>
		<dao interface="com.erp.user.dao.UserProfileDAO" 
		     implementation="com.erp.user.dao.jdbc.JDBCUserProfileDAO" />		     
	</context> 
</daoConfig>

Mime
View raw message