首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • JSP+struts+hibernate开发在线考试管理系统时出错,请高手帮忙!!! [已结贴,结贴人:java2000_net]
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • syk0208
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    • 揭贴率:
    发表于:2007-12-08 18:13:20 楼主
    现在程序能进入运行界面,当相应的用户进入各用户功能界面后,进行下一步的功能操作时出错下面的错误:
    type Exception report

    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    javax.servlet.ServletException: Couldn't find the role!
    cn.hxex.exam.filter.HibernateFilter.doFilter(HibernateFilter.java:71)


    root cause

    cn.hxex.exam.exception.ExamSystemException: Couldn't find the role!
    cn.hxex.exam.struts.HxexRequestProcessor.processRoles(HxexRequestProcessor.java:96)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:197)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    cn.hxex.exam.filter.HibernateFilter.doFilter(HibernateFilter.java:49)
    请问各位高手出错的原因是什么原因,是不是因为创建的数据表出错的原因!!

    50  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • wrong1111
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2007-12-08 22:36:531楼 得分:25
    是因为你没有在配置文件中给这个角色赋权限.
    在你的.XML配置文件中,有一个ACTION方法没有注册这个方法权限吧
    cn.hxex.exam.filter.HibernateFilter.doFilter(HibernateFilter.java:71)
     在这个方法里,是你们自己封装了.没有给这些用户权限.所以都进不去
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • syk0208
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2007-12-10 20:08:122楼 得分:0
    在Struts_config.xml中对Action的定义如下:
    <action-mappings>
        <action      path="/manage/classes"
                    type="cn.hxex.exam.action.ClassesAction"
                    name="classesForm"      scope="request"
        input="/manage/classes_add.jsp"      parameter="p"      unknown="false"      validate="false"    >
          <forward        name="add"        path="/manage/classes_add.jsp"        redirect="false"      />
          <forward        name="list"        path="/manage/classes_list.jsp"        redirect="false"      />
          <forward        name="update"        path="/manage/classes_update.jsp"        redirect="false"      />
          <forward        name="classes_teacher"        path="/manage/classes_teacher.jsp"        redirect="false"      />
        </action>
        <action      path="/manage/student"      type="cn.hxex.exam.action.StudentAction"      name="studentForm"      scope="request"      input="/manage/student_add.jsp"      parameter="p"      unknown="false"      validate="false"    >
          <forward        name="add"        path="/manage/student_add.jsp"        redirect="false"      />
          <forward        name="update"        path="/manage/student_update.jsp"        redirect="false"      />
          <forward        name="list"        path="/manage/student_list.jsp"        redirect="false"      />
        </action>
        <action      path="/exam/testpaper"      type="cn.hxex.exam.action.TestPaperAction"      name="testPaperForm"      scope="request"      input="/exam/testpaper_list.jsp"      parameter="p"      unknown="false"      validate="false"    >            <forward        name="add"        path="/exam/testpaper_add.jsp"        redirect="false"      />
          <forward        name="list"        path="/exam/testpaper_list.jsp"        redirect="false"      />
          <forward        name="update"        path="/exam/testpaper_update.jsp"        redirect="false"      />
          <forward        name="stulist"        path="/exam/testpaper_stulist.jsp"        redirect="false"      />
          <forward        name="result"        path="/exam/testpaper_result.jsp"        redirect="false"      />
        </action>
        <action      path="/exam/yesnoquestion"      type="cn.hxex.exam.action.YesNoQuestionAction"      name="yesnoQuestionForm"      scope="request"      input="/exam/question_list.jsp"      parameter="p"      unknown="false"      validate="false"    >
          <forward        name="add"        path="/exam/yesnoquestion_add.jsp"        redirect="false"      />
          <forward        name="update"        path="/exam/yesnoquestion_update.jsp"        redirect="false"      />
          <forward        name="list"        path="/exam/question_list.jsp"        redirect="false"      />
          <forward        name="exam"        path="/exam/question_exam.jsp"        redirect="false"      />
        </action>
        <action      path="/exam/question"      type="cn.hxex.exam.action.YesNoQuestionAction"      name="questionForm"      scope="request"      input="/exam/question_list.jsp"      parameter="p"      unknown="false"      validate="false"    >
          <forward        name="add"        path="/exam/yesnoquestion_add.jsp"        redirect="false"      />
          <forward        name="update"        path="/exam/yesnoquestion_update.jsp"        redirect="false"      />
          <forward        name="list"        path="/exam/question_list.jsp"        redirect="false"      />
          <forward        name="exam"        path="/exam/question_exam.jsp"        redirect="false"      />
        </action>
        <action      path="/manage/teacher"      type="cn.hxex.exam.action.TeacherAction"      name="teacherForm"      scope="request"      input="/manage/teacher_add.jsp"      parameter="p"      unknown="false"      validate="false"    >
          <forward        name="add"        path="/manage/teacher_add.jsp"        redirect="false"      />
          <forward        name="update"        path="/manage/teacher_update.jsp"        redirect="false"      />
          <forward        name="list"        path="/manage/teacher_list.jsp"        redirect="false"      />
          <forward        name="classes"        path="/manage/teacher_classes.jsp"        redirect="false"      />
        </action>    <action      path="/exam/question"      type="cn.hxex.exam.action.QuestionAction"      name="questionForm"      scope="request"      input="/exam/question_list.jsp"      parameter="p"      unknown="false"      validate="false"    >        <forward        name="list"        path="/exam/question_list.jsp"        redirect="false"      />
          <forward        name="exam"        path="/exam/question_exam.jsp"        redirect="false"      />
        </action>
        <action      path="/logon"      type="cn.hxex.exam.action.LogonAction"      name="userForm"      scope="request"      input="/logon.jsp"      roles="unspecified,logon"      parameter="p"      unknown="false"      validate="false"    >          <forward        name="admin"        path="/admin.jsp"        redirect="false"      />
          <forward        name="student"        path="/student.jsp"        redirect="false"      />
          <forward        name="teacher"        path="/teacher.jsp"        redirect="false"      />
          <forward        name="password"        path="/manage/password.jsp"        redirect="false"      />
        </action>
        <action      path="/exam/selectquestion"      type="cn.hxex.exam.action.SelectQuestionAction"      name="selectQuestionForm"      scope="request"      input="/exam/question_list.jsp"      parameter="p"      unknown="false"      validate="false"    >
          <forward        name="add"        path="/exam/selectquestion_add.jsp"        redirect="false"      />
          <forward        name="list"        path="/exam/question_list.jsp"        redirect="false"      />
          <forward        name="update"        path="/exam/selectquestion_update.jsp"        redirect="false"      />
          <forward        name="list"        path="/exam/question_list.jsp"        redirect="false"      />
          <forward        name="exam"        path="/exam/question_exam.jsp"        redirect="false"      />
        </action>
        <action      path="/exam/question"      type="cn.hxex.exam.action.SelectQuestionAction"      name="questionForm"      scope="request"      input="/exam/question_list.jsp"      parameter="p"      unknown="false"      validate="false"    >
          <forward        name="add"        path="/exam/selectquestion_add.jsp"        redirect="false"      />
          <forward        name="list"        path="/exam/question_list.jsp"        redirect="false"      />
          <forward        name="update"        path="/exam/selectquestion_update.jsp"        redirect="false"      />
          <forward        name="list"        path="/exam/question_list.jsp"        redirect="false"      />
          <forward        name="exam"        path="/exam/question_exam.jsp"        redirect="false"      />
        </action>
        <!-- If you have non XDoclet actions, define them in a file called struts-actions.xml and place it in your merge directory. -->
      </action-mappings>
    但是在运行的过程还会出现和以上所说的错误
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • syk0208
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2007-12-10 20:10:313楼 得分:0
    附加信息:以下有关程序数据库表的创建,是不是我建的数据库表有什么问题啊!
    create table ACTION(ACTION_ID varchar(3) not null primary key, TITLE varchar(100) not null,PATH varchar(100) not null,PARAMETTER varchar(100) not null);

    create table class(CLASS_ID varchar(8) not null primary key,TITLE varchar(30) not null);

    create table FUNCTIONS(FUNCTION_ID varchar(3) not null primary key,NAME varchar(50) not null, TITLE varchar(50) not null);

    create table ROLES(ROLE_ID varchar(3) not null primary key,NAME varchar(50) not null,TITLE varchar(50) not null);

    create table TEACHER_CLASS(TEACHER_ID varchar(8) not null,CLASS_ID varchar(8) not null);

    create table SELECTED(QUESTION_ID varchar(5) not null,CONTENT varchar(200) not null,ITEM varchar(200) not null);

    create table FUNCTION_ACTION(function_id varchar(3) not null,action_id varchar(3) not null);

    create table ROLE_FUNCTION(role_id varchar(3) not null,function_id varchar(3) not null);

    create table SELECT_QUESTION(PAPER_ID varchar(3) not null,QUESTION_ID varchar(5) not null primary key,TITLE varchar(200) not null,ANSWER varchar(2) not null, SCORE int not null);

    create table STUDENT(NAME varchar(20) not null,PASSWORD varchar(20) not null,FULLNAME varchar(20) not null,CLASS_ID varchar(8) not null);

    create table TEACHER(TEACHER_ID varchar(8) not null primary key,NAME varchar(20) not null,PASSWORD varchar(20) not null,FULLNAME varchar(20) not null);

    create table TEST_PAPER(PAPER_ID varchar(3) not null primary key,TITLE varchar(200) not null, EXAM_TIME int not null);

    create table USERINFO(NAME varchar(20) not null,PASSWORD varchar(20) not null,FULLNAME varchar(20) not null);

    create table YESNO_QUESTION(TITLE varchar(200) not null,ANSWER varchar(4) not null, SCORE int not null,PAPER_ID varchar(3) not null);

    还请各位高手朋友,多多帮忙!
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • fengyifei11228
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2007-12-10 20:18:444楼 得分:25
    最好把代码格式一下
    XML code
    <action-mappings> <action path="/manage/classes" type="cn.hxex.exam.action.ClassesAction" name="classesForm" scope="request" input="/manage/classes_add.jsp" parameter="p" unknown="false" validate="false" > <forward name="add" path="/manage/classes_add.jsp" redirect="false" /> <forward name="list" path="/manage/classes_list.jsp" redirect="false" /> <forward name="update" path="/manage/classes_update.jsp" redirect="false" /> <forward name="classes_teacher" path="/manage/classes_teacher.jsp" redirect="false" /> </action> <action path="/manage/student" type="cn.hxex.exam.action.StudentAction" name="studentForm" scope="request" input="/manage/student_add.jsp" parameter="p" unknown="false" validate="false" > <forward name="add" path="/manage/student_add.jsp" redirect="false" /> <forward name="update" path="/manage/student_update.jsp" redirect="false" /> <forward name="list" path="/manage/student_list.jsp" redirect="false" /> </action> <action path="/exam/testpaper" type="cn.hxex.exam.action.TestPaperAction" name="testPaperForm" scope="request" input="/exam/testpaper_list.jsp" parameter="p" unknown="false" validate="false" > <forward name="add" path="/exam/testpaper_add.jsp" redirect="false" /> <forward name="list" path="/exam/testpaper_list.jsp" redirect="false" /> <forward name="update" path="/exam/testpaper_update.jsp" redirect="false" /> <forward name="stulist" path="/exam/testpaper_stulist.jsp" redirect="false" /> <forward name="result" path="/exam/testpaper_result.jsp" redirect="false" /> </action> <action path="/exam/yesnoquestion" type="cn.hxex.exam.action.YesNoQuestionAction" name="yesnoQuestionForm" scope="request" input="/exam/question_list.jsp" parameter="p" unknown="false" validate="false" > <forward name="add" path="/exam/yesnoquestion_add.jsp" redirect="false" /> <forward name="update" path="/exam/yesnoquestion_update.jsp" redirect="false" /> <forward name="list" path="/exam/question_list.jsp" redirect="false" /> <forward name="exam" path="/exam/question_exam.jsp" redirect="false" /> </action> <action path="/exam/question" type="cn.hxex.exam.action.YesNoQuestionAction" name="questionForm" scope="request" input="/exam/question_list.jsp" parameter="p" unknown="false" validate="false" > <forward name="add" path="/exam/yesnoquestion_add.jsp" redirect="false" /> <forward name="update" path="/exam/yesnoquestion_update.jsp" redirect="false" /> <forward name="list" path="/exam/question_list.jsp" redirect="false" /> <forward name="exam" path="/exam/question_exam.jsp" redirect="false" /> </action> <action path="/manage/teacher" type="cn.hxex.exam.action.TeacherAction" name="teacherForm" scope="request" input="/manage/teacher_add.jsp" parameter="p" unknown="false" validate="false" > <forward name="add" path="/manage/teacher_add.jsp" redirect="false" /> <forward name="update" path="/manage/teacher_update.jsp" redirect="false" /> <forward name="list" path="/manage/teacher_list.jsp" redirect="false" /> <forward name="classes" path="/manage/teacher_classes.jsp" redirect="false" /> </action> <action path="/exam/question" type="cn.hxex.exam.action.QuestionAction" name="questionForm" scope="request" input="/exam/question_list.jsp" parameter="p" unknown="false" validate="false" > <forward name="list" path="/exam/question_list.jsp" redirect="false" /> <forward name="exam" path="/exam/question_exam.jsp" redirect="false" /> </action> <action path="/logon" type="cn.hxex.exam.action.LogonAction" name="userForm" scope="request" input="/logon.jsp" roles="unspecified,logon" parameter="p" unknown="false" validate="false" > <forward name="admin" path="/admin.jsp" redirect="false" /> <forward name="student" path="/student.jsp" redirect="false" /> <forward name="teacher" path="/teacher.jsp" redirect="false" /> <forward name="password" path="/manage/password.jsp" redirect="false" /> </action> <action path="/exam/selectquestion" type="cn.hxex.exam.action.SelectQuestionAction" name="selectQuestionForm" scope="request" input="/exam/question_list.jsp" parameter="p" unknown="false" validate="false" > <forward name="add" path="/exam/selectquestion_add.jsp" redirect="false" /> <forward name="list" path="/exam/question_list.jsp" redirect="false" /> <forward name="update" path="/exam/selectquestion_update.jsp" redirect="false" /> <forward name="list" path="/exam/question_list.jsp" redirect="false" /> <forward name="exam" path="/exam/question_exam.jsp" redirect="false" /> </action> <action path="/exam/question" type="cn.hxex.exam.action.SelectQuestionAction" name="questionForm" scope="request" input="/exam/question_list.jsp" parameter="p" unknown="false" validate="false" > <forward name="add" path="/exam/selectquestion_add.jsp" redirect="false" /> <forward name="list" path="/exam/question_list.jsp" redirect="false" /> <forward name="update" path="/exam/selectquestion_update.jsp" redirect="false" /> <forward name="list" path="/exam/question_list.jsp" redirect="false" /> <forward name="exam" path="/exam/question_exam.jsp" redirect="false" /> </action> <!-- If you have non XDoclet actions, define them in a file called struts-actions.xml and place it in your merge directory. --> </action-mappings>
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • fengyifei11228
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2007-12-10 20:22:115楼 得分:0
    cn.hxex.exam.filter.HibernateFilter.doFilter(HibernateFilter.java:71)
    方法中没有相应的权限进入
    你的struts中没有权限的配置啊
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • syk0208
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2007-12-10 20:54:116楼 得分:0
    以下是HibernateFilte.java中的doFilter 的方法,用于实现Hibernate事务的开始和提交
    public void doFilter(ServletRequest request,
                            ServletResponse response,
                            FilterChain chain)
                throws IOException, ServletException
        {
        // 得到SessionFactory对象的实例
        SessionFactory sf = HibernateUtil.getSessionFactory();

            try
            {
            // 开始一个新的事务
                log.debug("Starting a database transaction");
                sf.getCurrentSession().beginTransaction();

                log.debug( "Request Path:\t" + ((HttpServletRequest)request).getServletPath() );
                // Call the next filter (continue request processing)
                chain.doFilter(request, response);

                // 提交事务
                log.debug("Committing the database transaction");
                sf.getCurrentSession().getTransaction().commit();

            }
            catch (Throwable ex)
            {
            ex.printStackTrace();
                try
                {
                // 会滚事务
                    log.debug("Trying to rollback database transaction after exception");
                    sf.getCurrentSession().getTransaction().rollback();
                }
                catch (Throwable rbEx)
                {
                    log.error("Could not rollback transaction after exception!", rbEx);
                }

                // 抛出异常
                throw new ServletException(ex);
            }
        }
    难道这个方法在定义上有什么不对的地方吗?请各位高手给出指点!谢谢了~!
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • syk0208
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2007-12-11 09:21:557楼 得分:0
    以下是有关用户权限的认证方法,
    public class HxexRequestProcessor extends RequestProcessor
    {
    protected final Log log = LogFactory.getLog(HxexRequestProcessor.class);

    /**
    * 用户认证方法
    */
    @Override
    protected boolean processRoles(HttpServletRequest request,
    HttpServletResponse response, ActionMapping mapping)
    throws IOException, ServletException
    {
    // 得到映射的路径
    String path = mapping.getPath();
    // 得到用户所要调用的Action方法的名字
    String method = request.getParameter(mapping.getParameter());
    if (HxexStringUtils.isEmpty(method))
    {
    method = StrutsConstants.DEFAULT_METHOD;
    }

    // 取得不需要校验权限的Action方法
    String[] roles = mapping.getRoleNames();
    if (roles != null && roles.length > 0)
    {
    // 进行方法的判断
    for (String role : roles)
    {
    if (method.equals(role))
    {
    request.setAttribute(StrutsConstants.REQUEST_CHECK_FLAG,
    true);
    return true;
    }
    }
    }

    // 得到Session对象和用户对象
    HttpSession session = request.getSession();
    User u = (User) session.getAttribute(StrutsConstants.SESSION_USER);

    // 如果用于对象不存在,那么说明用户没有登录
    if (u == null)
    {
    // 用户没有执行的权限,跳转到错误页面
    processLocale( request, response );
    RequestDispatcher rd =
    request.getRequestDispatcher( "/errors/noauthority.jsp" );
    rd.forward( request, response );
    return false;
    }

    // 判断用户是否为超级用户
    String superusers = ExamConfigUtil
    .getSysConfigValue(ConfigConstants.SUPER_USER);
    String[] users = HxexStringUtils.splitString(superusers,
    ConfigConstants.USER_DELIM);
    if (HxexStringUtils.contains(users, u.getName()))
    {
    request.setAttribute(StrutsConstants.REQUEST_CHECK_FLAG, true);
    return true;
    }

    // 得到用户的角色信息
    Cache cache = CacheFactory.getCache();
    Role role = (Role) cache.get(u.getUserType());
    if (role == null)
    {
    throw new ExamSystemException("Couldn't find the role!");
    }

    // 进行用户执行功能的判断
    Set <Function> functions = role.getFunctions();
    for (Function function : functions)
    {
    Set <Action> actions = function.getActions();
    for (Action action : actions)
    {
    if (path.equals(action.getPath())
    && method.equals(action.getParameter()))
    {
    request.setAttribute(StrutsConstants.REQUEST_CHECK_FLAG,
    true);
    return true;
    }
    }
    }

    // 用户没有执行的权限,跳转到错误页面
    processLocale( request, response );
    RequestDispatcher rd =
    request.getRequestDispatcher( "/errors/noauthority.jsp" );
    rd.forward( request, response );
    return false;
    }

    同时在相应的映射文件中也有相应关的ACTION定义,但是在运行时却出错上面的所说的报错信息,不知道是那里的原因!请各位高手帮忙!
    修改 删除 举报 引用 回复

    网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
    北京创新乐知广告有限公司 版权所有 京 ICP 证 070598 号
    世纪乐知(北京)网络技术有限公司 提供技术支持
    Copyright © 2000-2008, CSDN.NET, All Rights Reserved