-->
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: testing hibernate
PostPosted: Tue Feb 14, 2006 4:02 am 
Beginner
Beginner

Joined: Tue Feb 07, 2006 10:39 pm
Posts: 46
this is my test file of the hibernate:

package test;

import hibernate.ThreadLocalSession;
import model.User;

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

public class firstName {

/*
* Hibernate example to inset data into Contact table
*/
public static void main(String[] args) {
Session ses = null;

try{
ses = ThreadLocalSession.currentSession();
//Create new instance of User and set values in it by reading them from form object
System.out.println("Inserting Record");
User user = new User();
user.setEmpNo("002");
user.setFirstName("Hii");
user.setLastName("Ling");
user.setDesignation("null");
user.setCompany("xyz");
user.setDepartment("abc");
user.setExtNo("375");
ses.save(user);
System.out.println("Done");
}catch(Exception e){
System.out.println(e.getMessage());
}finally{
// Actual user insertion will happen at this step
ses.flush();
ses.close();

}

}
}


the error shows when i run the java application is as shown below:

** 2
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
java.lang.NullPointerException
at test.firstName.main(firstName.java:36)
Exception in thread "main"


can anyone comment on this??


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 14, 2006 4:14 am 
Regular
Regular

Joined: Tue Dec 14, 2004 5:21 am
Posts: 104
Location: india
your ThreadlocalSession class may be trying to find session factory from jndi . in that case, the error may be solved to specifying the JNDI context properties , and INCLUDE the context factory class in the class path

_________________
sHeRiN
thanks for your ratings ...... :)


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.