-->
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: Possible Configuration problem
PostPosted: Wed Nov 02, 2005 5:36 pm 
Newbie

Joined: Fri Oct 28, 2005 3:20 pm
Posts: 8
Location: St Louis MO
Hello, I'm having a bit of a problem trying to run a little test app using Hibernate.

My test app code is as follows:

package com.reallm;

import java.util.HashSet;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class NavMenuTest
{public static void main(String[] args) throws Exception
{//Create the Hibernate Configuration and populate it with our classes
Configuration config = new Configuration();
config.addClass(SubMenuItem.class)
.addClass(SubMenu.class)
.addClass(Menu.class)
.addClass(NavMenu.class);

//Grab a session and reserve a variable to reference a Transaction
SessionFactory sessionFactory = config.buildSessionFactory();
Session session = sessionFactory.openSession();
Transaction tx = null;
try {//Create the Transaction
tx = session.beginTransaction();

//Create and populate a SubMenuItem object
SubMenuItem subMenuItem = new SubMenuItem("My first test!",
"tester",
"test"
);

//Add the SubMenuItem object to a SubMenu
HashSet<SubMenuItem> subMenuItemHashSet = new HashSet<SubMenuItem>();
subMenuItemHashSet.add(subMenuItem);
SubMenu subMenu = new SubMenu("Test SubMenu", subMenuItemHashSet);

//Add the SubMenu to a Menu
HashSet<SubMenu> subMenuHashSet = new HashSet<SubMenu>();
subMenuHashSet.add(subMenu);
Menu menu = new Menu("My Test Menu", subMenuHashSet);

//Add the menu to a NavMenu
HashSet<Menu> menuHashSet = new HashSet<Menu>();
menuHashSet.add(menu);
NavMenu navMenu = new NavMenu("My first test NavMenu", menuHashSet);
session.save(navMenu);
tx.commit();
}
catch(Exception e)
{if(tx != null) {tx.rollback();}
throw e;
}
finally {session.close();}
sessionFactory.close();
}
}
>>>ERROR
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.reallm.NavMenuTest.main(NavMenuTest.java:13)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:110)
... 1 more
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
... 5 more
Caused by: java.lang.NullPointerException
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
... 6 more

>>>ERROR

Hibernate version: 3.0

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

_________________
Fate is a collection of decisions


Top
 Profile  
 
 Post subject: Oops!
PostPosted: Wed Nov 02, 2005 5:44 pm 
Newbie

Joined: Fri Oct 28, 2005 3:20 pm
Posts: 8
Location: St Louis MO
Sorry about that! I'm not sure wha thappened. . . I pressed TAB to indent my source code, there was a pause, and then my post was submitted!

Anyway, my code and error are listed in the previous mesage.

I am using Hibernate Tools 3.1.0-beta1 in Eclipse 3.1.1 running JDK 5.0.
U have several Libraries on my project's classpath, and among them I have log4j-1.2.12. I also have commons-logging-1.0.2 and commons-logging-1.0.4 in two of my other classpath libraries.

THe Hibernate Configurations view shows that my Configuration, Sessions Factory, and Database are fine. I'm not sure if the Configuration part of the Hibernate COnfigurations view and the Configuration Object I construct in my code are related, but it seems like if the Configurations view can find what it needs my test app should be able to as well.

BTW, my hibernate.cfg.xml file is located in $PROJECT_ROOT/(src && bin)/hibernate.cfg.xml.

If you need anymore info please let me know. I'm new to Hibernate and database design in general, so I've been having kind of a tough go so far.

Thanks a lot for your help!

Bryan

_________________
Fate is a collection of decisions


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.