大家来看看这个hibernate的问题,十万火急啊!!!
定义类为:
public class aa
{
private int id;
private String name;
private int sort;
public aa()
{
}
public void setId(int Id)
{
this.id = Id;
}
public int getId()
{
return this.id;
}
public void setSort(int Sort)
{
this.sort = Sort;
}
public int getSort()
{
return this.sort;
}
public void setName(String Name)
{
this.name = Name;
}
public String getName()
{
return this.name;
}
}
xml 文件配置为:
<?xml version= "1.0 "?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN "
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd " >
<hibernate-mapping package= "...... ">
<class name= "aa " table= "t_aa ">
<id name= "Id ">
<generator class= "native "/>
</id>
<property name= "Name "/>
<property name= "Sort "/>
</class>
</hibernate-mapping>
调试状态下跟踪异常为:
"Could not prase mapping document from resource aa.hbm.xml "
"class aa not found while looking for property :Id "
运行结束错误页面为:
HTTP Status 500 - type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause java.lang.NullPointerException
com.sudytech.hibernate.HibernateFactory.currentSession(HibernateFactory.java:49)
org.apache.jsp.test_jsp._jspService(org.apache.jsp.test_jsp:60)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.Apache Tomcat/5.5.9
请各位大侠指教,急!!!!
[解决办法]
<id name= "Id "> <----------------改称和pojo一样的property。(id)
[解决办法]
"Could not prase mapping document from resource aa.hbm.xml "
"class aa not found while looking for property :Id "
<id name= "Id ">
<generator class= "native "/>
</id>
如LS所说,如果还不行 改成
<id name= "Id ">
</id>
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html