-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem creating sessionFactory
PostPosted: Tue Apr 19, 2005 3:17 am 
Regular
Regular

Joined: Fri Feb 25, 2005 3:02 am
Posts: 71
Hi,

I've created a utility class from which I'll obtain my sessionFactory which look as follows:

...................
static final Configuration configuration = new Configuration().configure();
System.out.println("PRE-CONFIGURE");
sessionFactory = configuration.buildSessionFactory();
System.out.println("POST-CONFIGURE");
................

I've also created my hibernate.cfg.xml file which I've placed in the conf dir of my Jonas appln server. When I call a method from my sessionBean which looks as follows:

..................
public void createUser() throws Exception
{
Session session = HibernateUtil.currentSession();
...............
...............
}
...............

I got a null pointer exception in Jonas. When I try to debug it I found that the jonas display my msg: PRE-CONFIGURE and then throws the nullpointer exception. So, it means there is something wrong in the line:
sessionFactory = configuration.buildSessionFactory();

Here is the msg from Jonas console:
2005-04-19 11:17:49,964 : Configuration.configure : configuring from resource: /hibernate.cfg.xml
2005-04-19 11:17:49,964 : Configuration.getConfigurationInputStream : Configuration resource: /hibernate.cfg.xml
2005-04-19 11:17:50,808 : Configuration.addResource : Mapping resource: org/objectweb/alarm/beans/GlopUser.hbm.xml
2005-04-19 11:17:53,104 : HbmBinder.bindRootPersistentClassCommonValues : Mapping class: org.objectweb.alarm.beans.GlopUser -> glop_user
2005-04-19 11:17:53,120 : Configuration.addResource : Mapping resource: org/objectweb/alarm/beans/AlarmData.hbm.xml
2005-04-19 11:17:55,698 : HbmBinder.bindRootPersistentClassCommonValues : Mapping class: org.objectweb.alarm.beans.AlarmData -> alarm_data
2005-04-19 11:17:55,698 : Configuration.doConfigure : Configured SessionFactory: null
PRE-CONFIGURE
2005-04-19 11:17:55,698 : Configuration.secondPassCompile : processing extends queue
2005-04-19 11:17:55,714 : Configuration.secondPassCompile : processing collection mappings
2005-04-19 11:17:55,714 : Configuration.secondPassCompile : processing association property references
2005-04-19 11:17:55,714 : Configuration.secondPassCompile : processing foreign key constraints
2005-04-19 11:17:55,714 : Dialect.<init> : Using dialect: org.hibernate.dialect.PostgreSQLDialect
2005-04-19 11:17:55,714 : SettingsFactory.buildSettings : Default batch fetch size: 1
2005-04-19 11:17:55,714 : SettingsFactory.buildSettings : Generate SQL with comments: disabled
2005-04-19 11:17:55,714 : SettingsFactory.buildSettings : Order SQL updates by primary key: disabled
2005-04-19 11:17:55,714 : SettingsFactory.createQueryTranslatorFactory : Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
2005-04-19 11:17:55,729 : ASTQueryTranslatorFactory.<init> : Using ASTQueryTranslatorFactory
2005-04-19 11:17:55,729 : SettingsFactory.buildSettings : Query language substitutions: {}
2005-04-19 11:17:55,729 : NamingHelper.getInitialContext : JNDI InitialContext properties:{}
2005-04-19 11:17:55,761 : DatasourceConnectionProvider.configure : Using datasource: jdbc_hibernate
2005-04-19 11:17:55,761 : SettingsFactory.buildSettings : JDBC batch size: 15
2005-04-19 11:17:55,761 : SettingsFactory.buildSettings : JDBC batch updates for versioned data: disabled
2005-04-19 11:17:55,776 : SettingsFactory.buildSettings : Scrollable result sets: enabled
2005-04-19 11:17:55,776 : SettingsFactory.buildSettings : JDBC3 getGeneratedKeys(): disabled
2005-04-19 11:17:55,776 : TransactionFactoryFactory.buildTransactionFactory : Using default transaction strategy (direct JDBC transactions)
2005-04-19 11:17:55,776 : TransactionManagerLookupFactory.getTransactionManagerLookup : No TransactionManagerLookup configured (in JTA envi
onment, use of read-write or transactional second-level cache is not recommended)
2005-04-19 11:17:55,776 : SettingsFactory.buildSettings : Automatic flush during beforeCompletion(): disabled
2005-04-19 11:17:55,792 : SettingsFactory.buildSettings : Automatic session close at end of transaction: disabled
2005-04-19 11:17:55,792 : SettingsFactory.createCacheProvider : Cache provider: org.hibernate.cache.EhCacheProvider
2005-04-19 11:17:55,792 : SettingsFactory.buildSettings : Second-level cache: enabled
2005-04-19 11:17:55,792 : SettingsFactory.buildSettings : Optimize cache for minimal puts: disabled
2005-04-19 11:17:55,792 : SettingsFactory.buildSettings : Structured second-level cache entries: enabled
2005-04-19 11:17:55,792 : SettingsFactory.buildSettings : Query cache: disabled
2005-04-19 11:17:55,792 : SettingsFactory.buildSettings : Statistics: disabled
2005-04-19 11:17:55,808 : SettingsFactory.buildSettings : Deleted entity synthetic identifier rollback: disabled
2005-04-19 11:17:55,808 : SettingsFactory.buildSettings : Default entity-mode: pojo
2005-04-19 11:17:55,808 : JFactory.postInvoke : system exception in business method:
java.lang.NullPointerException
at org.objectweb.alarm.beans.SessionTataBean.createUser(Unknown Source)
at org.objectweb.alarm.beans.JOnASSessionTata437579213Remote.createUser(JOnASSessionTata437579213Remote.java:57)
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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at org.objectweb.carol.rmi.jrmp.server.JUnicastServerRef.runDispatch(JUnicastServerRef.java:160)
at org.objectweb.carol.rmi.jrmp.server.JUnicastServerRef.dispatch(JUnicastServerRef.java:145)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)

Can anyone please help me solve my problem.
thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 11:57 am 
Newbie

Joined: Mon Jan 30, 2006 10:52 am
Posts: 2
Would it be possible that you have a race condition there? From the trace, it looked almost as if 2 threads were running at the same time. One hit the utility class first, and thus, hibernate started configuration, and a second one hit the class too but sesion factory not ready yet.

I usually synchronize every turn when trying to build and obtain a singleton.

See if this help.


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