Всех приветствую.
Я написал небольшое CRUD-приложение на Spring + Hibernate + MySQL.
Настроил все нужные зависимости (вроде как), написал маппинг, котроллер, DAO и сервис.
Но у меня проблема с БД. Саму базу данных я создал с помощью MySQL Workbench, подключил её к среде (я использую Intelij IDEA). Написал парочку JSP-страниц.
Вот они:
Главная
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Proselyte</title>
</head>
<body>
<h3>Proselyte presents</h3>
<br/>
<a href="<c:url value="/books"/>" target="_blank">Books list</a>
<br/>
</body>
</html>
JSP, которая показывает результат
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ page session="false" %>
<html>
<head>
<title>BookData</title>
<style type="text/css">
.tg {
border-collapse: collapse;
border-spacing: 0;
border-color: #ccc;
}
.tg td {
font-family: Arial, sans-serif;
font-size: 14px;
padding: 10px 5px;
border-style: solid;
border-width: 1px;
overflow: hidden;
word-break: normal;
border-color: #ccc;
color: #333;
background-color: #fff;
}
.tg th {
font-family: Arial, sans-serif;
font-size: 14px;
font-weight: normal;
padding: 10px 5px;
border-style: solid;
border-width: 1px;
overflow: hidden;
word-break: normal;
border-color: #ccc;
color: #333;
background-color: #f0f0f0;
}
.tg .tg-4eph {
background-color: #f9f9f9
}
</style>
</head>
<body>
<h1>Book Details</h1>
<table class="tg">
<tr>
<th width="80">ID</th>
<th width="120">Title</th>
<th width="120">Author</th>
<th width="120">Price</th>
</tr>
<tr>
<td>${book.id}</td>
<td>${book.bookTitle}</td>
<td>${book.bookAuthor}</td>
<td>${book.price/100}${book.price%100}</td>
</tr>
</table>
</body>
</html>
Добавление записи в БД
(Как раз тут и происходит проблема)
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib prefix="from" uri="http://www.springframework.org/tags/form" %>
<%@ page session="false" %>
<html>
<head>
<title>Books Page</title>
<style type="text/css">
.tg {
border-collapse: collapse;
border-spacing: 0;
border-color: #ccc;
}
.tg td {
font-family: Arial, sans-serif;
font-size: 14px;
padding: 10px 5px;
border-style: solid;
border-width: 1px;
overflow: hidden;
word-break: normal;
border-color: #ccc;
color: #333;
background-color: #fff;
}
.tg th {
font-family: Arial, sans-serif;
font-size: 14px;
font-weight: normal;
padding: 10px 5px;
border-style: solid;
border-width: 1px;
overflow: hidden;
word-break: normal;
border-color: #ccc;
color: #333;
background-color: #f0f0f0;
}
.tg .tg-4eph {
background-color: #f9f9f9
}
</style>
</head>
<body>
<a href="../../index.jsp">Back to main menu</a>
<br/>
<br/>
<h1>Book List</h1>
<c:if test="${!empty listBooks}">
<table class="tg">
<tr>
<th width="80">ID</th>
<th width="120">Title</th>
<th width="120">Author</th>
<th width="120">Price</th>
<th width="60">Edit</th>
<th width="60">Delete</th>
</tr>
<c:forEach items="${listBooks}" var="book">
<tr>
<td>${book.id}</td>
<td><a href="/bookdata/${book.id}" target="_blank">${book.bookTitle}</a></td>
<td>${book.bookAuthor}</td>
<td>${book.price/100}${book.price%100}</td>
<td><a href="<c:url value='/edit/${book.id}'/>">Edit</a></td>
<td><a href="<c:url value='/remove/${book.id}'/>">Delete</a></td>
</tr>
</c:forEach>
</table>
</c:if>
<h1>Add a Book</h1>
<c:url var="addAction" value="/books/add"/>
<form:form action="${addAction}" commandName="book">
<table>
<c:if test="${!empty book.bookTitle}">
<tr>
<td>
<form:label path="id">
<spring:message text="ID"/>
</form:label>
</td>
<td>
<form:input path="id" readonly="true" size="8" disabled="true"/>
<form:hidden path="id"/>
</td>
</tr>
</c:if>
<tr>
<td>
<form:label path="bookTitle">
<spring:message text="Title"/>
</form:label>
</td>
<td>
<form:input path="bookTitle"/>
</td>
</tr>
<tr>
<td>
<form:label path="bookAuthor">
<spring:message text="Author"/>
</form:label>
</td>
<td>
<form:input path="bookAuthor"/>
</td>
</tr>
<tr>
<td>
<form:label path="price">
<spring:message text="Price"/>
</form:label>
</td>
<td>
<form:input path="price"/>
</td>
</tr>
<tr>
<td colspan="2">
<c:if test="${!empty book.bookTitle}">
<input type="submit"
value="<spring:message text="Edit Book"/>"/>
</c:if>
<c:if test="${empty book.bookTitle}">
<input type="submit"
value="<spring:message text="Add Book"/>"/>
</c:if>
</td>
</tr>
</table>
</form:form>
</body>
</html>
При загрузке этой страницы - получаю ошибку 500.
Вот это:
Type Exception Report
Message Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is java.lang.NoClassDefFoundError: org/hibernate/engine/transaction/spi/TransactionContext
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
И вот лог всего:
Type Exception Report
Message Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is java.lang.NoClassDefFoundError: org/hibernate/engine/transaction/spi/TransactionContext
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
Что я делаю не так, если сама БД функционирует, а хибернет отказывается её подключать (все зависимости есть)?