1

I am using GlassFish server in Eclipse and am trying to intergerate the hibernate-release-5.1.0.Final into the JSF project. I have tried several steps but without seccuss.

  • I have Placed the Hibernate Jars inside the GlassFisch directrory glassfish4\bin and restarted the server.
  • I placed them inside the following foloder glassfish4\glassfish\bin and restarted the GlassFisch server.
  • I placed the Hibernate jars inside the WEB-INF/lib
  • I added this part .addResource("/resources/person.hbm.xml") to the CreatePersonDemo class.
  • I replaced the jboss-logging.jar inside the glassfish4\glassfish\modules directory with jboss-logging-3.3.0.Final.jar

CreatePersonDemo

package com.backing;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import com.model.Person;



public class CreatePersonDemo {

    public static void main(String[] args) {
        // create session factory.
//      SessionFactory factory = new Configuration()
//              .configure("/resources/hibernate.cfg.xml")
//              .addAnnotatedClass(Person.class)
//              .buildSessionFactory();
        SessionFactory factory = new Configuration().configure("/resources/hibernate.cfg.xml")
                .addResource("/resources/person.hbm.xml")
                .addAnnotatedClass(Person.class)
                .buildSessionFactory();

        // create a session.
        Session session = factory.getCurrentSession();
        System.out.println("CreateStudentDemo");

    }
}

hibernate.cfg.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM 
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://localhost:3306/GMapsYahooMeshup</property>
        <property name="connection.username">root</property>
        <property name="connection.password"></property>

        <property name="connection.pool_size">1</property>
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="current_session_context_class">thread</property>
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
        <property name="show_sql">true</property>
        <property name="current_session_context_class">thread</property>
        <mapping resource="resources/person.hbm.xml" /> 
        <!-- <mapping class ="com.Model.Person" /> -->

    </session-factory>
</hibernate-configuration>

person.hbm.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
 "-//Hibernate/Hibernate Mapping DTD//EN"
 "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
    <class name="Person" table="person">
        <meta attribute="class-description">
            This class contains the person detail.
        </meta>
        <id name="id" type="int" column="id">
            <generator class="native" />
        </id>
        <property name="full_name" column="full_name" type="string" />
        <property name="email " column="email " type="string" />
        <property name="location" column="location" type="string" />
        <property name="pwd" column="pwd" type="string" />
    </class>
</hibernate-mapping>

Person.Java

package com.model;   

public class Person {
    private int id;
    private String full_name;
    private String email;
    private String location;
    private String pwd;
    public Person(int id, String full_name, String email, String location, String pwd) {
        super();
        this.id = id;
        this.full_name = full_name;
        this.email = email;
        this.location = location;
        this.pwd = pwd;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getFull_name() {
        return full_name;
    }
    public void setFull_name(String full_name) {
        this.full_name = full_name;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    public String getLocation() {
        return location;
    }
    public void setLocation(String location) {
        this.location = location;
    }
    public String getPwd() {
        return pwd;
    }
    public void setPwd(String pwd) {
        this.pwd = pwd;
    }
}

Error

org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001001: Connection properties: {user=root, password=****}
Jul 17, 2016 10:24:52 AM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001003: Autocommit mode: false
Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.internal.CoreMessageLogger.debugf(Ljava/lang/String;I)V
    at org.hibernate.engine.jdbc.connections.internal.PooledConnections.<init>(PooledConnections.java:34)
    at org.hibernate.engine.jdbc.connections.internal.PooledConnections.<init>(PooledConnections.java:19)
    at org.hibernate.engine.jdbc.connections.internal.PooledConnections$Builder.build(PooledConnections.java:138)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:110)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:74)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
    at com.backing.CreatePersonDemo.main(CreatePersonDemo.java:22)

Project structure

enter image description here

The Time
  • 697
  • 5
  • 12
  • 26
  • Why do you want to add legacy and standalone Hibernate to a Java EE 5+ server which already offers JPA out the box? Why not just using standard JPA and if necessary swap out GlassFish's EclipseLink JPA implementation with Hibernate JPA implementation? All that struggle is unnecessary. Are you sure you're reading the right and up to date books/tutorials/resources on the subject? – BalusC Jul 17 '16 at 08:39
  • @BalusC: I installed the JBoos Tools to Access the hibernate perspective in eclipse. Do u know a good example to integerate Hibernate into the Project from the Hibernate perspectiv? – The Time Jul 17 '16 at 09:33
  • @BalusC:if i want to wrok with EclipseLink and JPA in JSF project. should I create JPA Project or normal web dynamic Project and then add all required jars? – The Time Jul 17 '16 at 19:55
  • You don't need to add any Java EE related JARs if you already target a Java EE server such as GlassFish. Adding JARs is only necessary when you target a barebones servletcontainer such as Tomcat. Related: http://stackoverflow.com/q/7295096 and http://stackoverflow.com/tags/jsf/info – BalusC Jul 18 '16 at 12:30
  • did you find a solution? – G. Ciardini Sep 19 '21 at 13:50

0 Answers0