The essence of the problem:
SEVERE: Servlet.service () for servlet [dispatcher] in context with path [/ Air] threw exception [Request processing failed; nested exception is org.hibernate.InstantiationException: No default constructor for entity: chpt.db.model.Students] with root cause org.hibernate.InstantiationException: No default constructor for entity: chpt.db.model.Students
application-Context.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <context:annotation-config/> <context:component-scan base-package="chpt"/> <context:component-scan base-package="chpt.db.model"/> <!-- import the dataSource definition <import resource="applicationContext-dataSource.xml"/>--> <import resource="applicationContext-dataSource.xml"/> <bean class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" id="sessionFactory"> <property name="dataSource" ref="dataSource"/> <property name="mappingResources"> <list> <!-- <value>/chpt/db/hibernate-mapping.hbm.xml</value> --> </list> </property> <property name="annotatedClasses"> <list> <value>chpt.db.model.Airport</value> <value>chpt.db.model.Flight</value> <value>chpt.db.model.Movement_flights</value> <value>chpt.db.model.Passenger</value> <value>chpt.db.model.Plane</value> <value>chpt.db.model.Students</value> </list> </property> <property name="hibernateProperties"> <value> hibernate.dialect=org.hibernate.dialect.HSQLDialect hibernate.show_sql=true </value> </property> </bean> <bean class="org.springframework.orm.hibernate3.HibernateTransactionManager" id="transactionManager" p:sessionFactory-ref="sessionFactory"/> <bean class="chpt.Controller.IndexController" id="dbUtil"/> </beans>
DbUtil.java
package chpt.db; import java.util.*; import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataAccessException; import org.springframework.orm.hibernate3.HibernateTemplate; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; import chpt.db.model.*; //import chpt.db.model.*; @Repository @Transactional public class DBUtil { Configuration config; private SessionFactory sf; private Session session; @Autowired public DBUtil(SessionFactory sessionFactory) { sf = sessionFactory; session = sf.openSession(); } public void save(Object obj) { session.beginTransaction(); session.clear(); session.save(obj); session.getTransaction().commit(); } public void update(Object obj) { session.beginTransaction(); session.clear(); session.update(obj); session.getTransaction().commit(); } public void dell(Object obj) { session.beginTransaction(); session.clear(); session.delete(obj); session.getTransaction().commit(); } public List<Students> getStudents(){ return session.createQuery("from chpt.db.model.Students").list(); }
IndexController.java
package chpt.Controller; import java.util.List; import javax.servlet.http.*; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import chpt.db.*; import chpt.elements.TableHtml; import chpt.db.model.*; import chpt.elements.*; @Controller @RequestMapping("/index.htm") public class IndexController { ModelAndView modelAndView; private final DBUtil dbUtil; TableHtml adapterManager; String namePage; String attributeTabelName; @Autowired public IndexController(DBUtil dbUtil) { this.dbUtil = dbUtil; adapterManager = null; namePage = "index"; attributeTabelName = "tabel"; } @RequestMapping(params="Lab3", method=RequestMethod.GET) protected void viewStudents(HttpServletRequest request, HttpServletResponse response) throws Exception { List<Students> data = dbUtil.getStudents(); adapterManager = new TableStudents(data); response.setContentType("text/plain"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(adapterManager.CreateView()); } }
Students.java
package chpt.db.model; import java.text.ParseException; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; import chpt.db.Tabels; @Entity @Table(name = "students") public class Students extends chpt.db.AbstractTableModel { @Id @GeneratedValue @Column(name = "id") int id; @Column(name = "first_name") String first_name; @Column(name = "last_name") String last_name; @Column(name = "birthday") Date birthday; @Column(name = "faculty") int faculty; public Students(Tabels typeTabel) { typeTabel = Tabels.Students; } public String getFirst_name() { return first_name; } public void setFirst_name(String first_name) { this.first_name = first_name; } public String getLast_name() { return last_name; } public void setLast_name(String last_name) { this.last_name = last_name; } public Date getBirthday() { return birthday; } public void setBirthday(Date birthday) { this.birthday = birthday; } public int getFaculty() { return faculty; } public void setFaculty(int facult) { this.faculty = facult; } public int getId() { return id; } public void setId(int id) { this.id = id; } @Override public void setAll(Object[] obj) throws ParseException { id = Integer.parseInt((String) obj[0]); } }
I do not know what to do, because I would not post here. All paths are spelled correctly, for several days I cannot deal with this problem.