-->
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.  [ 5 posts ] 
Author Message
 Post subject: Error occured while doinng EventManager application...
PostPosted: Tue Mar 03, 2009 1:54 am 
Newbie

Joined: Fri Sep 05, 2008 2:08 am
Posts: 7
Hello,
I am doing Hibernate example Eventmanager given in Hibernate reference documentation.
My Environment is : Hibernate 3,oracle 9i , IntelliJ 8.0.1

I got below error while runnaing main class, please help in this regard.
If you need any information I can provide as you need to understand.
*************************************************************
Mar 3, 2009 11:05:13 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.6
Mar 3, 2009 11:05:13 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Mar 3, 2009 11:05:13 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
Mar 3, 2009 11:05:13 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Mar 3, 2009 11:05:13 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Mar 3, 2009 11:05:13 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Mar 3, 2009 11:05:14 AM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : events/Event.hbm.xml
Mar 3, 2009 11:05:14 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: events.Event -> EVENTS
Mar 3, 2009 11:05:14 AM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Mar 3, 2009 11:05:15 AM org.hibernate.util.NamingHelper getInitialContext
INFO: JNDI InitialContext properties:{}
Mar 3, 2009 11:05:15 AM org.hibernate.connection.DatasourceConnectionProvider configure
SEVERE: Could not find datasource: DataSource4Hiber
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2073)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1298)
at util.HibernateUtil.<clinit>(HibernateUtil.java:22)
at events.EventManager.createAndStoreEvent(EventManager.java:48)
at events.EventManager.main(EventManager.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Initial sessionfactory creation failed....sridharorg.hibernate.HibernateException: Could not find datasource
java.lang.ExceptionInInitializerError
at util.HibernateUtil.<clinit>(HibernateUtil.java:26)
at events.EventManager.createAndStoreEvent(EventManager.java:48)
at events.EventManager.main(EventManager.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: org.hibernate.HibernateException: Could not find datasource
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2073)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1298)
at util.HibernateUtil.<clinit>(HibernateUtil.java:22)
... 7 more
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
... 14 more
Exception in thread "main"
Process finished with exit code 1
*************************************************************


thanks and regards
Sri


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 03, 2009 4:56 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
Quote:
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Initial sessionfactory creation failed....sridharorg.hibernate.HibernateException: Could not find datasource
java.lang.ExceptionInInitializerError

This means hibernate is not able to find the datasource which you have specified in the hibernate.cfg.xml file. I think there is one entry in ur cfg xml like:
Code:
<property
name="connection.datasource">DataSource4Hiber</property>

Make sure DataSource4Hiber datasource is available with the app server and that is the right jndi name of the datasource.

If you dont want to use a DS then just remove that property from cfg.xml and specify the connection parameters like:
Code:
      <!-- Database connection settings -->
      <property name="connection.driver_class">
         oracle.jdbc.driver.OracleDriver
      </property>
      <property name="connection.url">
         jdbc:oracle:thin:@localhost:1521:XE
      </property>
      <property name="connection.username">hr</property>
      <property name="connection.password">hr</property>

      <!-- JDBC connection pool (use the built-in) -->
      <property name="connection.pool_size">1</property>

      <!-- SQL dialect -->
      <property name="dialect">
         org.hibernate.dialect.Oracle9Dialect
      </property>

_________________
Regards,
Litty Preeth


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 03, 2009 8:29 am 
Newbie

Joined: Fri Sep 05, 2008 2:08 am
Posts: 7
Thanks for the valuable reply.
after doing some thing I got below error :
**********************************************************
org.hibernate.HibernateException: No session currently bound to execution context
at org.hibernate.context.ManagedSessionContext.currentSession(ManagedSessionContext.java:50)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:544)
at events.EventManager.createAndStoreEvent(EventManager.java:48)
at events.EventManager.main(EventManager.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Exception in thread "main"
Process finished with exit code 1
**********************************************************
I tried to add in hibernate.cfg.xml
**********************************
<property name="hibernate.current_session_context_class">
org.hibernate.context.ManagedSessionContext
</property>
**********************************************************
but also getting above exception

Please suggest me in this regarding....

regards
sri


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 03, 2009 9:06 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
Sorry sreedhar. I have never used any session context other than thread. So i have no idea on this.

_________________
Regards,
Litty Preeth


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 04, 2009 1:42 am 
Newbie

Joined: Fri Sep 05, 2008 2:08 am
Posts: 7
Beforely I used Hibernate 3.2.6 and 3.3.0 GA ,I got erross .After that I modified to Hibernate 3.2.4 GA , and modified in Hibernate.cfg.xml

<property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>

<property name="hibernate.current_session_context_class">
thread
</property>

Now it does not show any errors.


thanks & regards
Sri


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