-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: [Long][newbie] Hibernate try load class which not exist.
PostPosted: Sun Dec 25, 2005 12:38 pm 
Newbie

Joined: Sun Dec 25, 2005 12:03 pm
Posts: 12
Hibernate version:
Hibernate 3.1_rc3
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
  <class name="events.Event" table="EVENTS">
    <id name="id" column="id">
      <generator class="native"/>
    </id>
    <property name="date" type="timestamp" column="EVENT_DATE"/>
    <property name="title"/>
  </class>
</hibernate-mapping>

Code:
package events;

import java.util.Date;

public class Event {
     private Long id;
     private String title;
     private Date date;

     public Event() {}

     public Long getId() {
          return id;
     }

     public void setId(Long id) {
          this.id = id;
     }

     public Date getDate() {
          return date;
     }

     public void setDate(Date date) {
          this.date = date;
     }

     public String getTitle() {
          return title;
     }

     public void setTitle(String title) {
          this.title = title;
     }
}

Code between sessionFactory.openSession() and session.close():
Full class
Code:
package events;
import org.hibernate.Session;

import java.util.Date;

import util.HibernateUtil;

public class EventManager {

     public static void main(String[] args) {
          EventManager mgr = new EventManager();

          if (args[0].equals("store")) {
               mgr.createAndStoreEvent("My Event", new Date());
          }

          HibernateUtil.getSessionFactory().close();
     }

     private void createAndStoreEvent(String title, Date theDate) {

          Session session = HibernateUtil.getSessionFactory().getCurrentSession();

          session.beginTransaction();

          Event theEvent = new Event();
          theEvent.setTitle(title);
          theEvent.setDate(theDate);

          session.save(theEvent);

          session.getTransaction().commit();
     }

}


Full stack trace of any exception that occurs:
Code:
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: javax/transaction/SystemException
Exception in thread "main" java.lang.ExceptionInInitializerError
        at util.HibernateUtil.<clinit>(HibernateUtil.java:17)
        at events.EventManager.createAndStoreEvent(EventManager.java:22)
        at events.EventManager.main(EventManager.java:14)
Caused by: java.lang.NoClassDefFoundError: javax/transaction/SystemException
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:164)
        at org.hibernate.id.IdentifierGeneratorFactory.class$(IdentifierGeneratorFactory.java:25)
        at org.hibernate.id.IdentifierGeneratorFactory.<clinit>(IdentifierGeneratorFactory.java:76)
        at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:152)
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:181)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1152)
        at util.HibernateUtil.<clinit>(HibernateUtil.java:13)
        ... 2 more

Name and version of the database you are using:
MySQL 5.0.17
The generated SQL (show_sql=true):
Nothing
Debug level Hibernate log excerpt:
nothing

Full log:
Code:
% java events.EventManager store
2005-12-25 17:15:40 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.1 rc3
2005-12-25 17:15:40 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
2005-12-25 17:15:40 org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
2005-12-25 17:15:40 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
2005-12-25 17:15:40 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
2005-12-25 17:15:40 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
2005-12-25 17:15:41 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource: events/Event.hbm.xml
2005-12-25 17:15:42 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: events.Event -> EVENTS
2005-12-25 17:15:42 org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
2005-12-25 17:15:42 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
2005-12-25 17:15:42 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
2005-12-25 17:15:42 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
2005-12-25 17:15:42 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
2005-12-25 17:15:43 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
2005-12-25 17:15:43 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
2005-12-25 17:15:43 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
2005-12-25 17:15:43 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://192.168.0.1/hibernate
2005-12-25 17:15:43 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=hibernate, password=****}
2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.0.17-log
2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.12 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
2005-12-25 17:15:44 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
2005-12-25 17:15:44 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
2005-12-25 17:15:44 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
2005-12-25 17:15:45 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: POJO
2005-12-25 17:15:45 org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: javax/transaction/SystemException
Exception in thread "main" java.lang.ExceptionInInitializerError
        at util.HibernateUtil.<clinit>(HibernateUtil.java:17)
        at events.EventManager.createAndStoreEvent(EventManager.java:22)
        at events.EventManager.main(EventManager.java:14)
Caused by: java.lang.NoClassDefFoundError: javax/transaction/SystemException
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:164)
        at org.hibernate.id.IdentifierGeneratorFactory.class$(IdentifierGeneratorFactory.java:25)
        at org.hibernate.id.IdentifierGeneratorFactory.<clinit>(IdentifierGeneratorFactory.java:76)
        at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:152)
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:181)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1152)
        at util.HibernateUtil.<clinit>(HibernateUtil.java:13)
        ... 2 more


This class not exists in documentation of sun:
Sun 1.5.0
Sun 1.4.2
Gnu Classpath

1. If I'll install gnu-classpath it'll be OK?
2. If(1.getAnswer()) {
Why do you use classes which is not in standart api?
} else {
What's wrong?
}

Regards.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 25, 2005 12:56 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
FAQ Nr. 1


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 25, 2005 2:35 pm 
Newbie

Joined: Sun Dec 25, 2005 12:03 pm
Posts: 12
Well.
I've read it(both FAQ and lib/_README.txt[1]).
When I use gnu-classpath evrything is OK(there are new row in mysql ect.)
Quote:
I get a ClassNotFoundException or NoClassDefFoundError

You are missing a third-party library Hibernate needs, check lib/README.txt in the Hibernate distribution. Another much more exotic reason might be a static initializer block of one of the needed classes (error during load) or a security-related issue (policy doesn't allow loading).

Quote:
% cat Sources/hibernate-3.1/lib/_README.txt

ehcache-1.1.jar (1.1)
- EHCache cache
- runtime, optional (required if no other cache provider is set)

versioncheck.jar (1.0)
- version checker
- buildtime

swarmcache-1.0rc2.jar (1.0rc2)
- runtime, optional
- runtime, optional

jboss-cache.jar (1.2.2 alpha)
- TreeCache clustered cache
- runtime, optional

jgroups-2.2.7.jar (2.2.7)
- JGroups multicast library
- runtime, optional (required by replicated caches)

jta.jar (unknown)
- Standard JTA API
- runtime, required for standalone operation (outside application server)

xml-apis.jar (unknown)
- Standard JAXP API
- runtime, some SAX parser is required

commons-logging-1.0.4.jar (1.0.4)
- Commons Logging
- runtime, required

c3p0-0.9.0.jar (0.9.0)
- C3P0 JDBC connection pool
- runtime, optional

connector.jar (unknown)
- Standard JCA API
- runtime, optional

jboss-system.jar (unknown)
- unknown name
- runtime, optional (required by TreeCache)

asm-attrs.jar (unknown)
- ASM bytecode library
- runtime, required

jacc-1_0-fr.jar (1.0-fr)
- JACC Library
- runtime, optional

checkstyle-all.jar (unknown)
- Checkstyle
- buildtime

log4j-1.2.11.jar (1.2.11)
- Log4j Library
- runtime, optional

junit-3.8.1.jar (3.8.1)
- JUnit test framework
- buildtime

dom4j-1.6.1.jar (1.6.1)
- XML configuration & mapping parser
- runtime, required

antlr-2.7.6rc1.jar (2.7.6rc1)
- ANother Tool for Language Recognition (patched with proper context classloading)
- runtime, required

cglib-2.1.3.jar (2.1.3)
- CGLIB bytecode generator
- runtime, required

jboss-common.jar (unknown)
- unknown name
- runtime, optional (required by TreeCache)

oscache-2.1.jar (2.1)
- OpenSymphony OSCache
- runtime, optional

asm.jar (unknown)
- ASM bytecode library
- runtime, required

ant-launcher-1.6.5.jar (1.6.5)
- Ant launcher
- buildtime

jaas.jar (unknown)
- Standard JAAS API
- runtime, optional (required by JCA)

jdbc2_0-stdext.jar (2.0)
- Standard Extension JDBC APIs
- runtime, required for standalone operation (outside application server)

ant-antlr-1.6.5.jar (1.6.5)
- Ant antlr support
- buildtime

jboss-jmx.jar (unknown)
- unknown name
- runtime, optional (required by TreeCache)

cleanimports.jar (unknown)
- cleanimports
- buildtime

xerces-2.6.2.jar (2.6.2)
- SAX parser
- runtime, required for JDK < 1.4

jaxen-1.1-beta-7.jar (1.1-beta-7)
- Jaxen - universal java xpath engine
- runtime, required if you want to deserialize a Configuration to improve startup performance

ant-junit-1.6.5.jar (1.6.5)
- Ant junit support
- buildtime

ant-swing-1.6.5.jar (1.6.5)
- Ant swing support
- buildtime

commons-collections-2.1.1.jar (2.1.1)
- Commons Collections
- runtime, required

ant-1.6.5.jar (1.6.5)
- Ant core
- buildtime

proxool-0.8.3.jar (0.8.3)
- Proxool JDBC connection pool
- runtime, optional

concurrent-1.3.2.jar (1.3.2)
- unknown name
- runtime, optional (required by TreeCache)

syndiag2.jar (2.0)
- antlr to bnf image generator
- buildtime


Is here anything about GNU ClassPath?

Regards

[1]there aren't lib/README.txt)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 25, 2005 3:42 pm 
Newbie

Joined: Sun Dec 25, 2005 12:03 pm
Posts: 12
Sorry.
Now evrything is ok...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.