Я получаю эту ошибку, когда пытаюсь запустить код и открыть сервер Glassfish:
java.lang.NoSuchMethodError: org.hibernate.integrator.internal.IntegratorServiceImpl.<init>(Ljava/util/LinkedHashSet;Lorg/hibernate/boot/registry/classloading/spi/ClassLoaderService;)V
Вот мой код:
public class SessionFact {
static SessionFactory sf;
private static ServiceRegistry serviceRegistry;
public static SessionFactory getSessionFact() {
Configuration cfg = new Configuration();
cfg.configure("Resources/hibernate.cfg.xml");
serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
cfg.getProperties()).build();
sf = cfg.buildSessionFactory(serviceRegistry);
System.out.println("build session factory ---------");
return sf;
}
}
и мой сервлет:
public class Testing extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
SessionFactory sf = HelpingClasses.SessionFact.getSessionFact();
PrintWriter pr = resp.getWriter();
pr.print("looks like is done");
}
}
и xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/exam</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">admin</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping class="Bean.Student"/>
</session-factory>
</hibernate-configuration>