问答详情
源自:3-2 SQL 基本配置与执行

请问这个什么问题

HTTP Status 500 -

type Exception report

message

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

exception

org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in com/imooc/config/sqlxml/Message.xml
### The error occurred while processing mapper_resultMap[MessageResult]
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class . Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'UserAlias'.  Cause: java.lang.ClassNotFoundException: Cannot find class: UserAlias
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:51)
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:35)
com.imooc.db.DBAccess.getSqlSession(DBAccess.java:15)
com.imooc.daoImpl.MessageDaoImpl.show(MessageDaoImpl.java:27)
com.imooc.serviceImpl.MessageServiceImpl.show(MessageServiceImpl.java:15)
com.imooc.servlet.ListServlet.doGet(ListServlet.java:25)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause

org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class . Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'UserAlias'.  Cause: java.lang.ClassNotFoundException: Cannot find class: UserAlias
org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:105)
org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:88)
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:49)
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:35)
com.imooc.db.DBAccess.getSqlSession(DBAccess.java:15)
com.imooc.daoImpl.MessageDaoImpl.show(MessageDaoImpl.java:27)
com.imooc.serviceImpl.MessageServiceImpl.show(MessageServiceImpl.java:15)
com.imooc.servlet.ListServlet.doGet(ListServlet.java:25)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause

java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class . Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'UserAlias'.  Cause: java.lang.ClassNotFoundException: Cannot find class: UserAlias
org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:113)
org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:88)
org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:311)
org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:103)
org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:88)
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:49)
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:35)
com.imooc.db.DBAccess.getSqlSession(DBAccess.java:15)
com.imooc.daoImpl.MessageDaoImpl.show(MessageDaoImpl.java:27)
com.imooc.serviceImpl.MessageServiceImpl.show(MessageServiceImpl.java:15)
com.imooc.servlet.ListServlet.doGet(ListServlet.java:25)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause

org.apache.ibatis.builder.BuilderException: Error resolving class . Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'UserAlias'.  Cause: java.lang.ClassNotFoundException: Cannot find class: UserAlias
org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:94)
org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:79)
org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:128)
org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:121)
org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:111)
org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:88)
org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:311)
org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:103)
org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:88)
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:49)
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:35)
com.imooc.db.DBAccess.getSqlSession(DBAccess.java:15)
com.imooc.daoImpl.MessageDaoImpl.show(MessageDaoImpl.java:27)
com.imooc.serviceImpl.MessageServiceImpl.show(MessageServiceImpl.java:15)
com.imooc.servlet.ListServlet.doGet(ListServlet.java:25)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause

org.apache.ibatis.type.TypeException: Could not resolve type alias 'UserAlias'.  Cause: java.lang.ClassNotFoundException: Cannot find class: UserAlias
org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:109)
org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:115)
org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:92)
org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:79)
org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:128)
org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:121)
org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:111)
org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:88)
org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:311)
org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:103)
org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:88)
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:49)
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:35)
com.imooc.db.DBAccess.getSqlSession(DBAccess.java:15)
com.imooc.daoImpl.MessageDaoImpl.show(MessageDaoImpl.java:27)
com.imooc.serviceImpl.MessageServiceImpl.show(MessageServiceImpl.java:15)
com.imooc.servlet.ListServlet.doGet(ListServlet.java:25)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause

java.lang.ClassNotFoundException: Cannot find class: UserAlias
org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:188)
org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:87)
org.apache.ibatis.io.Resources.classForName(Resources.java:250)
org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:105)
org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:115)
org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:92)
org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:79)
org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:128)
org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:121)
org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:111)
org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:88)
org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:311)
org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:103)
org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:88)
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:49)
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:35)
com.imooc.db.DBAccess.getSqlSession(DBAccess.java:15)
com.imooc.daoImpl.MessageDaoImpl.show(MessageDaoImpl.java:27)
com.imooc.serviceImpl.MessageServiceImpl.show(MessageServiceImpl.java:15)
com.imooc.servlet.ListServlet.doGet(ListServlet.java:25)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


note The full stack trace of the root cause is available in the Apache Tomcat/7.0.27 logs.

Apache Tomcat/7.0.27


提问者:19901120 2017-01-19 10:53

个回答

  • 19901120
    2017-01-19 10:55:50

    public class MessageDaoImpl implements MessageDao {


    @Override

    public List<Message> show() {

    List<Message> l=new ArrayList<Message>();

    DBAccess dbAccess=new DBAccess();

    SqlSession sqlSession=null;

    try {

    sqlSession=dbAccess.getSqlSession();

    //通过sqlSession执行SQL语句

    l = sqlSession.selectList("Message.show");

    } catch (IOException e) {

    e.printStackTrace();

    }finally{

    if(sqlSession!=null){

    sqlSession.close();

    }

    }

    return l;