• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.lang.nullpointer

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mark
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic