-->
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.  [ 7 posts ] 
Author Message
 Post subject: Simple HelloWorld -> Error
PostPosted: Thu Feb 11, 2010 1:32 pm 
Newbie

Joined: Thu Jul 20, 2006 5:00 pm
Posts: 16
I am running simple HellWorld example and getting below error.

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
java.lang.AbstractMethodError: org.slf4j.impl.Log4jLoggerAdapter.isTraceEnabled()Z
at org.hibernate.type.NullableType.<clinit>(NullableType.java:59)
at org.hibernate.Hibernate.<clinit>(Hibernate.java:103)
at org.hibernate.type.TypeFactory.<clinit>(TypeFactory.java:69)
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:283)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:276)
at org.hibernate.mapping.Property.isValid(Property.java:207)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:458)
at org.hibernate.mapping.RootClass.validate(RootClass.java:215)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1149)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1334)
at hello.FirstExample.main(FirstExample.java:15)
Exception in thread "main" java.lang.NullPointerException
at hello.FirstExample.main(FirstExample.java:30)


Any help is appreciated


Top
 Profile  
 
 Post subject: Re: Simple HelloWorld -> Error
PostPosted: Fri Feb 12, 2010 3:01 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
I guess that the slf4j-log4j bridge version you are using (usually a jar named slf4j-log4j<version>.jar)
is incompatible with the version of slf4j you are using (usually a jar named slf4j-api<version>.jar).


Top
 Profile  
 
 Post subject: Re: Simple HelloWorld -> Error
PostPosted: Fri Feb 12, 2010 3:27 pm 
Newbie

Joined: Thu Jul 20, 2006 5:00 pm
Posts: 16
Thanks, yes that was the problem. I had two different version of jar in my path and I need to add both slf4j-log4j12-1.5.8.jar and slf4j-api-1.5.8.jar in the classpath.

I think Hibernate team should consider adding slf4j-log4j12-1.5.8.jar in the hibernate-distribution-3.3.2.GA distribuition. Currently, slf4j-api-1.5.8.jar is part of the distribution but not slf4j-log4j12-1.5.8.jar.


Top
 Profile  
 
 Post subject: Re: Simple HelloWorld -> Error
PostPosted: Sat Feb 13, 2010 12:14 pm 
Newbie

Joined: Mon Jan 18, 2010 6:44 pm
Posts: 11
Hello!

I also can't run HelloWorld application, but i have another error.

This is structure of my project Image

And this is my build.xml file, and I'm trying with running it to generate data base schema. But, I'm getting arrors.

This is my build.xml file
Code:
<project name="HelloWorld" default="compile" basedir=".">
   <!-- Name of project and version -->
   <property name="proj.name" value="HelloWorld"/>
   <property name="proj.version" value="1.0"/>
   <!-- Global properties for this build -->
   <property name="src.java.dir" value="src"/>
   <property name="lib.dir" value="lib"/>
   <property name="build.dir" value="bin"/>
   <!-- Classpath declaration -->
   <path id="project.classpath">
      <fileset dir="${lib.dir}">
         <include name="**/*.jar"/>
         <include name="**/*.zip"/>
      </fileset>
   </path>
   <!-- Useful shortcuts -->
   <patternset id="meta.files">
      <include name="**/*.xml"/>
      <include name="**/*.properties"/>
   </patternset>
   <!-- Clean up -->
   <target name="clean">
      <delete dir="${build.dir}"/>
      <mkdir dir="${build.dir}"/>
   </target>
   <!-- Compile Java source -->
   <target name="compile" depends="clean">
      <mkdir dir="${build.dir}"/>
      <javac srcdir="${src.java.dir}" destdir="${build.dir}" nowarn="on">
         <classpath refid="project.classpath"/>
      </javac>
   </target>
   <!-- Copy metadata to build classpath -->
   <target name="copymetafiles">
      <copy todir="${build.dir}">
         <fileset dir="${src.java.dir}">
            <patternset refid="meta.files"/>
         </fileset>
      </copy>
   </target>
   <target name="schemaexport" depends="compile, copymetafiles" description="Exports a generated schema to DB and file">
      <hibernatetool destdir="${basedir}">
         <classpath path="${build.dir}"/>
         <configuration
         configurationfile="${build.dir}/hibernate.cfg.xml"/>
         <hbm2ddl
         drop="true"
         create="true"
         export="true"
         outputfilename="helloworld-ddl.sql"
         delimiter=";"
         format="true"/>
      </hibernatetool>
   </target>
</project>

    And errors
    Feb 13, 2010 4:56:28 PM org.hibernate.cfg.Environment <clinit>
    INFO: Hibernate 3.3.2.GA
    Feb 13, 2010 4:56:28 PM org.hibernate.cfg.Environment <clinit>
    INFO: hibernate.properties not found
    Feb 13, 2010 4:56:28 PM org.hibernate.cfg.Environment buildBytecodeProvider
    INFO: Bytecode provider name : javassist
    Feb 13, 2010 4:56:28 PM org.hibernate.cfg.Environment <clinit>
    INFO: using JDK 1.4 java.sql.Timestamp handling
    Feb 13, 2010 4:56:28 PM org.hibernate.cfg.Configuration configure
    INFO: configuring from resource: /hibernate.cfg.xml
    Feb 13, 2010 4:56:28 PM org.hibernate.cfg.Configuration getConfigurationInputStream
    INFO: Configuration resource: /hibernate.cfg.xml
    Feb 13, 2010 4:56:28 PM org.hibernate.cfg.Configuration doConfigure
    INFO: Configured SessionFactory: null
    Feb 13, 2010 4:56:28 PM org.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Using Hibernate built-in connection pool (not for production use!)
    Feb 13, 2010 4:56:28 PM org.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Hibernate connection pool size: 1
    Feb 13, 2010 4:56:28 PM org.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: autocommit mode: false
    Feb 13, 2010 4:56:28 PM org.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@localhost:1521:XE
    Feb 13, 2010 4:56:28 PM org.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: connection properties: {user=employeer, password=****}
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: RDBMS: Oracle, version: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: JDBC driver: Oracle JDBC driver, version: 10.2.0.1.0XE
    Feb 13, 2010 4:56:29 PM org.hibernate.dialect.Dialect <init>
    INFO: Using dialect: org.hibernate.dialect.Oracle10gDialect
    Feb 13, 2010 4:56:29 PM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
    INFO: Using default transaction strategy (direct JDBC transactions)
    Feb 13, 2010 4:56:29 PM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
    INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Automatic flush during beforeCompletion(): disabled
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Automatic session close at end of transaction: disabled
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: JDBC batch size: 15
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: JDBC batch updates for versioned data: disabled
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Scrollable result sets: enabled
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: JDBC3 getGeneratedKeys(): disabled
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Connection release mode: auto
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Default batch fetch size: 1
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Generate SQL with comments: disabled
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Order SQL updates by primary key: disabled
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Order SQL inserts for batching: disabled
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
    INFO: Query translator: org.hibernate.hql.classic.ClassicQueryTranslatorFactory
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Query language substitutions: {}
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: JPA-QL strict compliance: disabled
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Second-level cache: enabled
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Query cache: disabled
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory createRegionFactory
    INFO: Cache region factory : org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge
    Feb 13, 2010 4:56:29 PM org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge <init>
    INFO: Cache provider: org.hibernate.cache.NoCacheProvider
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Optimize cache for minimal puts: disabled
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Structured second-level cache entries: disabled
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Echoing all SQL to stdout
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Statistics: disabled
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Deleted entity synthetic identifier rollback: disabled
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Default entity-mode: pojo
    Feb 13, 2010 4:56:29 PM org.hibernate.cfg.SettingsFactory buildSettings
    INFO: Named query checking : enabled
    Feb 13, 2010 4:56:29 PM org.hibernate.impl.SessionFactoryImpl <init>
    INFO: building session factory
    Feb 13, 2010 4:56:29 PM org.hibernate.impl.SessionFactoryObjectFactory addInstance
    INFO: Not binding factory to JNDI, no JNDI name configured
    Exception in thread "main" org.hibernate.MappingException: Unknown entity: hello.Message
    at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:628)
    at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1366)
    at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
    at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
    at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
    at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:563)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:551)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:547)
    at hello.HelloWorld.main(HelloWorld.java:17)

What I should do?

Please, help me!!!

Thanks a lot!!! :)


Top
 Profile  
 
 Post subject: Re: Simple HelloWorld -> Error
PostPosted: Sat Feb 13, 2010 7:47 pm 
Newbie

Joined: Mon Jan 18, 2010 6:44 pm
Posts: 11
Actually, I made a mistake. The previous error is when I run HelloWorld.java, and when I run build.xml I got this error

    Buildfile: C:\HelloWorld\src\build.xml
    clean:
    [delete] Deleting directory C:\HelloWorld\src\bin
    [mkdir] Created dir: C:\HelloWorld\src\bin
    compile:

    BUILD FAILED
    C:\HelloWorld\src\build.xml:29: srcdir "C:\HelloWorld\src\src" does not exist!

    Total time: 203 milliseconds

and this is compile part

Code:
   <!-- Compile Java source -->
   <target name="compile" depends="clean">
      <mkdir dir="${build.dir}"/>
      [b]<javac srcdir="${src.java.dir}" destdir="${build.dir}" nowarn="on">[/b]
         <classpath refid="project.classpath"/>
      </javac>
   </target>


What's wrong here??

please help


Top
 Profile  
 
 Post subject: Re: Simple HelloWorld -> Error
PostPosted: Sat Feb 13, 2010 8:05 pm 
Beginner
Beginner

Joined: Wed Nov 21, 2007 8:02 am
Posts: 48
try with this
<property name="src.java.dir" value="."/>


Top
 Profile  
 
 Post subject: Re: Simple HelloWorld -> Error
PostPosted: Sat Feb 13, 2010 8:12 pm 
Newbie

Joined: Mon Jan 18, 2010 6:44 pm
Posts: 11
I've found one more mistake, i put build.xml in the project, not in the src file.

So now is running fine.

I got next mistake, when I run HeloWorld.java

Code:
Feb 14, 2010 1:09:00 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.3.2.GA
Feb 14, 2010 1:09:00 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Feb 14, 2010 1:09:00 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : javassist
Feb 14, 2010 1:09:00 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Feb 14, 2010 1:09:01 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Feb 14, 2010 1:09:01 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
   at persistence.HibernateUtil.<clinit>(Unknown Source)
   at hello.HelloWorld.main(Unknown Source)
Caused by: org.hibernate.HibernateException: /hibernate.cfg.xml not found
   at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170)
   at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1453)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1475)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
   ... 2 more



I put hibernate.cfg.xml in src folder? Is it correct?

thnx


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.