facebook

Problem in Struts Hibernate Integration

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #267126 Reply

    shantanu_s
    Member

    I 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 error

    Error occurred during initialization of VM
    java/lang/NoClassDefFoundError: java/lang/Object

    Independent 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

    #267199 Reply

    Riyad Kalla
    Member

    Any 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 install

    You 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.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Problem in Struts Hibernate Integration

You must be logged in to post in the forum log in