• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.nullpointer

 
amrit pursnani
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class ICaptureDbInteract11 {

public static Logger dbLogger=Logger.getLogger(iCaptureService.ICaptureDbInteract.class.getName());

public static void main(String a[])
{
ICaptureDbEO row=null;
Session session=null;
try
{
dbLogger.info("in hibernate function:");
PropertyConfigurator.configure("d:\\log4j.properties");

System.out.println("in the hibernate function:");
System.out.println("before the session factory");




SessionFactory sessionFactory=new Configuration().addFile("D:/hibernate.cfg.xml").buildSessionFactory();







session=sessionFactory.openSession();
//session=sessions.openSession();


Transaction tx=session.beginTransaction();
String sqlQuery="from ICaptureDbEO as master where master.FORM_ID='LTR19'";//"+formID+"'";


Connection conntn=session.connection();
System.out.println("THIS IS THE CONNECTION OBJECT: "+conntn);
System.out.println("B4 THE QUERY");
Query query=session.createQuery(sqlQuery);
System.out.println("AFTER THE QUERY"+query);

for(Iterator it=query.iterate();it.hasNext()
{
System.out.println("inside the iterator");
row=(ICaptureDbEO)it.next();
System.out.println("recid"+row.getREC_ID());
System.out.println("formid:"+row.getFORM_ID());
System.out.println("form descrition:"+row.getFORM_DESCRIPTION());
System.out.println("dyas to complete:"+row.getDAYS_TO_COMPLETE_WORK());
System.out.println("incoming:"+row.getINCOMING());
}

tx.commit();
}


catch(Exception e)
{
dbLogger.error("EXCEPTION OCCURED DURING DATABASE INTERACTION:"+e);
e.printStackTrace();
}
finally
{
session.close();
}

}




}//CLASS ENDS HERE


when i am running this code as a standalone apllication on dos it is giving java.lang.nullpointer exception when the new Configure() method is invoked

please tell mee why it is happening and how can it be solved?
[ August 02, 2006: Message edited by: Bear Bibeault ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

I don't see "new Configure()" anyplace; I do see "new Configuration()" -- is that what you mean?

Please copy the whole stack trace and paste it into a reply to this topic; then we'll be better able to tell you what's going on.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try putting you "D:/hibernate.cfg.xml" file in your root of your classpath.

Mark
 
amrit pursnani
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i mean configuration() only
source of classpath means source where jars are kept or source where my class files are kept
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
classpath as in, you have a directory with source code in it for your model. so I have

c:\myproject\app\src\org\jboss\model\

in the classpath being set to c:\myproject\app\src, so that is the directory you would put your config file. Then you don't put a specific path to get to the config file, it is in your classpath.

Mark
 
amrit pursnani
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic