현재 스레드 addDepartment 컨트롤러에 대한 발견 나는이 내 XML에 추가하고 있는가상자의 예외는 org.hibernate.HibernateException입니다 : 없음 세션이 나는 새로운 부서를 등록하려고
HTTP Status 500 - Request processing failed; nested exception is org.hibernate.HibernateException: No Session found for current thread
이 오류가 파일 에러가 계속
<tx:annotation-driven transaction-manager="hibernateTransactionManager"/>
<!-- Scans within the base package of the application for @Component classes to configure as beans -->
<context:component-scan base-package="com.xxx.account.*"/>
이 예외를 발생 컨트롤러 방법
@RequestMapping(value = "/addDepartment", method = RequestMethod.GET)
public ModelAndView addCategory(@ModelAttribute("command") Department department,
BindingResult result) {
Map<String, Object> model = new HashMap<String, Object>();
model.put("department", departmentService.getDepartments());
return new ModelAndView("addDepartment");
}
,
이 나는 컨트롤러 방법
org.hibernate.HibernateException: No Session found for current thread
org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:106) org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014) m.chuma.account.dao.DepartmentDaoImpl.getDeparments(DepartmentDaoImpl.java:31)com.chuma.account.service.impl.DepartmentServiceImpl.getDepartments(DepartmentServiceImpl.java:28)
이를 액세스하려고 할 때 나는 데 오류의 전체 스택 트레이스이다는
@Service("departmentService")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class DepartmentServiceImpl implements DepartmentService{
@Autowired
private DepartmentDao departmentDao;
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public void addDepartment(Department department) {
departmentDao.addDepartment(department);
}
모든 것이 괜찮아 보인다 @Transactional 주석이 부서 DAO이다 지금까지 내 디버그에서,하지만 오류는 여전히보기를 반환하는 컨트롤러 메서드에 액세스하려고하면 유지됩니다. 무엇이 잘못되었거나 내가 누락 된 부분입니까?
당신은 당신이에있는 hibernate.cfg.xml에 <속성 이름 = "current_session_context_class"> 스레드'또는'<키 = "의 hibernate.current_session_context_class를"소품> 스레드''같은 것을 가지고 있는지 확인하는 것이 좋습니다 스프링 설정에서'SessionFactoryBean'의 정의. –
hibernate.cfg.xml 파일이 없다. – Blaze
Spring XML 설정 파일이나'@ Configuration' 주석이 달린 자바 클래스에 Hibernate 속성 집합이 있는가? –