- This topic has 1 reply, 2 voices, and was last updated 17 years, 10 months ago by Riyad Kalla.
-
AuthorPosts
-
shantanu_sMemberI have a independent java program that works very fine when executed independently,
but when included and called from a struts action class it exits giving this errorError occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/ObjectIndependent program:
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;public class testHibernate {
public static void main(String[] args) {
try{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session =sessionFactory.openSession();
loginForm form1 = new loginForm();
org.hibernate.Transaction tx = session.beginTransaction();
//Create new instance of Contact and set values in it by reading them from form object
System.out.println(“Inserting Record”);form1.setUserid(“newe88”);
form1.setPwd(“newww88”);
session.save(form1);
tx.commit();
System.out.println(“Donee”);
session.flush();
session.close();}
catch (Exception e) {
e.printStackTrace();
}}
}Code called from action class : Erroneous Code which is included in a Struts project
package com.torrentx.util;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;import com.torrentx.forms.loginForm;
public class Write2DB {
public Write2DB(){
}
public boolean writevalues(String u,String p)
{
try{
System.out.println(“came to write value “);
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session =sessionFactory.openSession();
// Create new instance of Contact and set values in it by reading them from form object
Transaction tx = session.beginTransaction();
System.out.println(“Inserting Record”);
loginForm form1 = new loginForm();
form1.setUserid(“testuser “+u);
form1.setPwd(“testpwd “+p);
session.save(form1);
System.out.println(“Done”);
tx.commit();
session.close();}
catch (Exception e) {e.printStackTrace();
return false;
}
return true;
}public static void main(String[] args)
{
Write2DB wr = new Write2DB();
boolean a =wr.writevalues(“a”,”b”);
}}
I am using Jdk 1.5 , struts 1.1 and Websphere 5.1.2
Riyad KallaMemberAny time you see such a fundamental error like that (if Object can’t be found, then that means the VM cannot find the rt.jar) it means a few things:
1) Bad JRE install
2) Screwed up class path
3) Possibly screwed up app server installYou might want to double check your deployment to make sure you aren’t accidentally deploying your JRE with your web project, some app servers will detect deployments of unallowed classes (like the platform classes) and stop them from loading, that could explain what is going on.
-
AuthorPosts