I'm doing a basic user registration with Servlet
.
When I click the register button I get the following error page (everything has been reviewed and is working perfectly, I believe it is something related to Hibernate, but nothing I have resolved):
HTTP Status 500 – Internal Server Error
Type Exception Report
Message Servlet execution threw an exception
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
javax.servlet.ServletException: Servlet execution threw an exception
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root Cause
java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:88)
org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:61)
org.hibernate.ejb.HibernatePersistence.getEntityManagerFactoryBuilderOrNull(HibernatePersistence.java:101)
org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:50)
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
servlet.CadastroServlet.doPost(CadastroServlet.java:87)
javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Note The full stack trace of the root cause is available in the server logs.
Apache Tomcat/8.5.33
This is my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:
xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="prova3bPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>model.entities.Users</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.cache.provider_class"
value="org.hibernate.cache.NoCacheProvider"/>
<property name="javax.persistence.jdbc.url"
value="jdbc:mysql://localhost:3306/prova3b"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.driver"
value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.password" value="t759m1546"/>
<property name="javax.persistence.schema-generation.database.action"
value="create"/>
</properties>
</persistence-unit>
</persistence>
This is my servlet:
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String nome = request.getParameter("username");
String email = request.getParameter("email");
String senha = request.getParameter("password");
String confirm_senha = request.getParameter("confirm_senha");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("prova3bPU");
UsersJpaController objJpa = new UsersJpaController(emf);
Users user = new Users();
user.setUsername(nome);
user.setEmail(email);
user.setPassword(senha);
if(senha == confirm_senha){
objJpa.create(user);
request.setAttribute("resp", "efetuado");
request.getRequestDispatcher("cadastro_response.jsp").forward(request, response);
} else {
request.setAttribute("resp", "negado");
request.getRequestDispatcher("cadatro_response.jsp").forward(request, response);
}
processRequest(request, response);
}