首先你这里的代码全不全?如果不全,需要看你运行什么方法的时候出这个错,在配置上是看不出来的,你只有get find load是readonly,那确定其他方法里没有调用这3类方法吗?其次,你运行的包里是不是你这个配置文件呢?有些IDE在你配置不对,或没保存的情况下,不会将这个文件copy到运行环境下去的。

解决方案 »

  1.   

    我的包里绝对是这个配置文件再补充一下:
    这是 /ajax STRUTS 控制器
    -----------------------------------------------------------
    import java.io.IOException;
    import java.util.List;import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;import service.IUserService;
    import model.InfoContextlist;
    public class Myzone_infoAction extends Action {

    private IUserService userService;
    private InfoContextlist info;

    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) throws IOException {
    Info_UserManageForm info_UserManageForm = (Info_UserManageForm) form;// TODO Auto-generated method stub
    this.del(new Long(3));
    }

    private void del(Long _infoId){
    this.info = this.userService.getInfoContextlistDAO().findById(_infoId);
    this.info.setDeletedTime(GETDate.getTime());
    this.info.setDeleteor("自已删除");
    this.info.setStatus(new Integer(3));
    this.userService.getInfoContextlistDAO().attachDirty(this.info);
    }

    public void setUserServiceImpl(IUserService userService){
    this.userService = userService;
    }
    public IUserService getUserServiceImpl(){
    return this.userService;
    }
    }这是 InfoContextlistDAO 里面的方法package dao;import java.util.List;
    import java.util.Map;import model.InfoClasses;
    import model.InfoContextlist;
    import model.Chinaarea;import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.hibernate.Criteria;
    import org.hibernate.LockMode;
    import org.hibernate.Session;
    import org.hibernate.criterion.Order;
    import org.hibernate.criterion.Projections;
    import org.hibernate.criterion.Restrictions;
    import org.springframework.context.ApplicationContext;
    import org.springframework.orm.hibernate3.support.HibernateDaoSupport;public class InfoContextlistDAO extends HibernateDaoSupport {    private static final Log log = LogFactory.getLog(InfoContextlistDAO.class);
        
    protected void initDao() {
    //do nothing
    }
        
        public void save(InfoContextlist transientInstance) {
            log.debug("saving InfoContextlist instance");
            try {
                getHibernateTemplate().save(transientInstance);
                log.debug("save successful");
            } catch (RuntimeException re) {
                log.error("save failed", re);
                throw re;
            }
        }
        
        public void update(InfoContextlist transientInstance) {
            log.debug("update InfoContextlist instance");
            try {
             getHibernateTemplate().update(transientInstance);
                log.debug("update successful");
            } catch (RuntimeException re) {
                log.error("update failed", re);
                throw re;
            }
        }
        
        public void delete(InfoContextlist persistentInstance) {
            log.debug("deleting InfoContextlist instance");
            try {
                getHibernateTemplate().delete(persistentInstance);
                log.debug("delete successful");
            } catch (RuntimeException re) {
                log.error("delete failed", re);
                throw re;
            }
        }
        
        public InfoContextlist findById( java.lang.Long id) {
            log.debug("getting InfoContextlist instance with id: " + id);
            try {
                InfoContextlist instance = (InfoContextlist) getHibernateTemplate()
                        .get("model.InfoContextlist", id);
                return instance;
            } catch (RuntimeException re) {
                log.error("get failed", re);
                throw re;
            }
        }
        
        
        public List findByExample(InfoContextlist instance) {
            log.debug("finding InfoContextlist instance by example");
            try {
                List results = getHibernateTemplate().findByExample(instance);
                log.debug("find by example successful, result size: " + results.size());
                return results;
            } catch (RuntimeException re) {
                log.error("find by example failed", re);
                throw re;
            }
        }    

        public InfoContextlist merge(InfoContextlist detachedInstance) {
            log.debug("merging InfoContextlist instance");
            try {
                InfoContextlist result = (InfoContextlist) getHibernateTemplate()
                        .merge(detachedInstance);
                log.debug("merge successful");
                return result;
            } catch (RuntimeException re) {
                log.error("merge failed", re);
                throw re;
            }
        }    public void attachDirty(InfoContextlist instance) {
            log.debug("attaching dirty InfoContextlist instance");
            try {
                getHibernateTemplate().saveOrUpdate(instance);
                log.debug("attach successful");
            } catch (RuntimeException re) {
                log.error("attach failed", re);
                throw re;
            }
        }
        
        public void attachClean(InfoContextlist instance) {
            log.debug("attaching clean InfoContextlist instance");
            try {
                getHibernateTemplate().lock(instance, LockMode.NONE);
                log.debug("attach successful");
            } catch (RuntimeException re) {
                log.error("attach failed", re);
                throw re;
            }
        } public static InfoContextlistDAO getFromApplicationContext(ApplicationContext ctx) {
         return (InfoContextlistDAO) ctx.getBean("InfoContextlistDAO");
    }
    }