Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate mapping exception: Could not get constructor for org.hibernate.entity.SingleTableEntityPersister
    primarykey
    data
    text
    <p>The post <a href="https://stackoverflow.com/questions/9104221/hibernate-buildsessionfactory-exception">Hibernate buildSessionFactory() Exception</a> and <a href="https://stackoverflow.com/questions/18042247/could-not-get-constructor-for-org-hibernate-persister-entity-singletableentitype">Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister</a> discusses the similar situation, however I still can't resolve why following code is generating <strong>org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister</strong> error. I am creating a login, using JSP, Servlet and Hibernate. Please help me resol</p> <p>Tomcat log:</p> <pre><code>Aug 08, 2013 5:07:58 PM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\DMIX;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;. Aug 08, 2013 5:07:58 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Assignment5' did not find a matching property. Aug 08, 2013 5:07:58 PM org.apache.coyote.AbstractProtocolHandler init INFO: Initializing ProtocolHandler ["http-bio-8080"] Aug 08, 2013 5:07:58 PM org.apache.coyote.AbstractProtocolHandler init INFO: Initializing ProtocolHandler ["ajp-bio-8009"] Aug 08, 2013 5:07:58 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 479 ms Aug 08, 2013 5:07:58 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Aug 08, 2013 5:07:58 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.12 Aug 08, 2013 5:08:00 PM org.apache.coyote.AbstractProtocolHandler start INFO: Starting ProtocolHandler ["http-bio-8080"] Aug 08, 2013 5:08:00 PM org.apache.coyote.AbstractProtocolHandler start INFO: Starting ProtocolHandler ["ajp-bio-8009"] Aug 08, 2013 5:08:00 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 1186 ms Aug 08, 2013 5:08:04 PM org.hibernate.annotations.common.Version &lt;clinit&gt; INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final} Aug 08, 2013 5:08:04 PM org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.2.3.Final} Aug 08, 2013 5:08:04 PM org.hibernate.cfg.Environment &lt;clinit&gt; INFO: HHH000205: Loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.h2.Driver, hibernate.dialect=org.hibernate.dialect.H2Dialect, hibernate.max_fetch_depth=5, hibernate.format_sql=true, hibernate.generate_statistics=true, hibernate.connection.username=sa, hibernate.connection.url=jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE, hibernate.bytecode.use_reflection_optimizer=false, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=5} Aug 08, 2013 5:08:04 PM org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist Aug 08, 2013 5:08:04 PM org.hibernate.cfg.Configuration configure INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml Aug 08, 2013 5:08:04 PM org.hibernate.cfg.Configuration getConfigurationInputStream INFO: HHH000040: Configuration resource: /hibernate.cfg.xml Aug 08, 2013 5:08:04 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide! Aug 08, 2013 5:08:04 PM org.hibernate.cfg.Configuration doConfigure INFO: HHH000041: Configured SessionFactory: null Aug 08, 2013 5:08:04 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!) Aug 08, 2013 5:08:04 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000115: Hibernate connection pool size: 5 Aug 08, 2013 5:08:04 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000006: Autocommit mode: false Aug 08, 2013 5:08:04 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/Assignment5] Aug 08, 2013 5:08:04 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000046: Connection properties: {user=root, password=****} Aug 08, 2013 5:08:05 PM org.hibernate.dialect.Dialect &lt;init&gt; INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLInnoDBDialect Aug 08, 2013 5:08:05 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4 Aug 08, 2013 5:08:05 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService INFO: HHH000399: Using default transaction strategy (direct JDBC transactions) Aug 08, 2013 5:08:05 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory &lt;init&gt; INFO: HHH000397: Using ASTQueryTranslatorFactory Initializing session factory failed: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister java.lang.ExceptionInInitializerError </code></pre> <p>My POJO class for User is:</p> <pre><code>@Entity @Table(name = "Users") public class User implements Serializable { private static final long serialVersionUID = 1986328586398921108L; @Id @GeneratedValue @Column(name="ID") private Long id; @NotNull @Column(name="NAME", unique = true) private String name; @NotNull @Column(name="PASSWORD") private String password; public User() {} public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } } </code></pre> <p>Corresponding MySQL database table is:</p> <pre><code>create table Users ( ID bigint not null auto_increment primary key, NAME varchar(20) not null unique, PASSWORD varchar(20) not null ); </code></pre> <p>hibernate.cfg.xml (placed in src folder)</p> <pre><code>&lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt; &lt;hibernate-configuration&gt; &lt;session-factory&gt; &lt;!-- hibernate dialect --&gt; &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLInnoDBDialect&lt;/property&gt; &lt;!-- Logging all generated SQL to console --&gt; &lt;property name="show_sql"&gt;true&lt;/property&gt; &lt;property name="format_sql"&gt;true&lt;/property&gt; &lt;!-- Database connection settings: MySQL --&gt; &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt; &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://localhost:3306/RnD&lt;/property&gt; &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt; &lt;property name="hibernate.connection.password"&gt;*******&lt;/property&gt; &lt;!--&lt;property name="transaction.factory_class"&gt;org.hibernate.transaction.JDBCTransactionFactory&lt;/property&gt; --&gt; &lt;!-- Enable Hibernate's automatic session context management --&gt; &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt; &lt;!-- Name the annotated User class --&gt; &lt;mapping class = "pojo.User"/&gt; &lt;/session-factory&gt; &lt;/hibernate-configuration&gt; </code></pre> <p>Please also comment is it beneficial to serialize class. Thanks in advance!</p> <p><strong>Edit 1:</strong> Class, I'm initializing SessionFactory within:</p> <pre><code>public class HibernateUtil { private static final SessionFactory sessionFactory; static { try { Configuration configuration = new Configuration(); configuration.configure(); ServiceRegistry serviceRegistry = new ServiceRegistryBuilder() .applySettings(configuration.getProperties()) .buildServiceRegistry(); sessionFactory = configuration.buildSessionFactory(serviceRegistry); } catch (Throwable e) { System.err.println("Initializing session factory failed: " + e); throw new ExceptionInInitializerError(e); } } public static SessionFactory getSessionFactory() { return sessionFactory; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload