Здравствуйте. Помогите, пожалуйста решить проблему. Пишу Servlet, который считывает параметры запроса и создает на основе их объект.
package controllers;
import manipulating.ClientDAO;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(name = "registration", urlPatterns = {"/registration"})
public class registration extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String userPath = request.getServletPath();
System.out.println("Get");
request.getRequestDispatcher("/WEB-INF/views" + userPath + ".jsp").forward(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("Post");
String userPath = request.getServletPath();
ClientDAO clientDAO = new ClientDAO();
String name = request.getParameter("name");
String secondName = request.getParameter("secondName");
String birthdayData = request.getParameter("birthdayDate");
String passport = request.getParameter("passport");
String adress = request.getParameter("adress");
String eMail = request.getParameter("email");
String password = request.getParameter("password");
System.out.println(name + " " + secondName + " " + birthdayData + " " + passport + " " + adress + " " + eMail + " " + password);
clientDAO.addClient("Artyom", "Karnov", "08.02.1995", "data", "spb", "artyom @karnov.ru", "1122");
// clientDAO.addClient(
// name, secondName,
// birthdayData, passport,
// adress, eMail,
// password
// );
}
}
Судя по выводу, параметры считываюся верно, но вот когда дело доходит до
clientDAO.addClient(
name, secondName,
birthdayData, passport,
adress, eMail,
password
);
Причем не из сервлета этот код работает, а в сервлете выдает на страницу
javax.servlet.ServletException: Servlet execution threw an exception
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
root cause
java.lang.NoClassDefFoundError: org/hibernate/metamodel/source/XsdException
org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:97)
org.hibernate.ejb.HibernatePersistence.getEntityManagerFactoryBuilderOrNull(HibernatePersistence.java:93)
org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:88)
org.hibernate.ejb.HibernatePersistence.getEntityManagerFactoryBuilderOrNull(HibernatePersistence.java:101)
org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:69)
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
manipulating.MainDAO.<clinit>(MainDAO.java:12)
manipulating.ClientDAO.isUserExist(ClientDAO.java:40)
manipulating.ClientDAO.addClient(ClientDAO.java:32)
controllers.registration.doPost(registration.java:39)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Погуглил, нашел подобную
проблему , однако ее решение представлено в eclipse, я же использую idea. Как мне быть в такой ситуации?
UPD
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>newBD</groupId>
<artifactId>new</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>new Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<!-- [url]https://mvnrepository.com/artifact/junit/junit[/url] -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- [url]https://mvnrepository.com/artifact/org.hibernate.common/hibernate-commons-annotations[/url] -->
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>5.0.1.Final</version>
</dependency>
<!-- [url]https://mvnrepository.com/artifact/org.hibernate/hibernate-core[/url] -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.2.Final</version>
</dependency>
<!-- [url]https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager[/url] -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.2.Final</version>
</dependency>
<!-- [url]https://mvnrepository.com/artifact/org.hibernate.javax.persistence/hibernate-jpa-2.0-api[/url] -->
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<!-- [url]https://mvnrepository.com/artifact/org.hibernate/hibernate-validator[/url] -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.2.4.Final</version>
</dependency>
<!-- [url]https://mvnrepository.com/artifact/org.hibernate/hibernate-validator-annotation-processor[/url] -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-annotation-processor</artifactId>
<version>5.2.4.Final</version>
</dependency>
<!-- [url]https://mvnrepository.com/artifact/mysql/mysql-connector-java[/url] -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
</dependency>
<!-- [url]https://mvnrepository.com/artifact/javax.validation/validation-api[/url] -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<!-- [url]https://mvnrepository.com/artifact/org.javassist/javassist[/url] -->
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.20.0-GA</version>
</dependency>
<!-- [url]https://mvnrepository.com/artifact/antlr/antlr[/url] -->
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<!--<finalName>new</finalName>-->
<plugins>
<plugin>
<artifactId>com.My</artifactId>
<groupid>com.My</groupid>
<artifactid>tomcat-maven-plugin</artifactid>
<configuration>
<!-- id-шник из settings.xml -->
<server>apache-tomcat-9.0.0.M9</server>
<url>http://localhost:8080/manager</url>
<path>/mywebapp</path>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>