I got Below exception
Exception in thread "main" java.lang.IllegalAccessError
at net.sf.cglib.core.ClassEmitter.setTarget(ClassEmitter.java:45)
at net.sf.cglib.core.ClassEmitter.<init>(ClassEmitter.java:37)
at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:165)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:135)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:269)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:425)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
at sessionFactory.HibernateSessionFactory.getSession(HibernateSessionFactory.java:55)
at com.persistance.TestProject.main(TestProject.java:30)
these are list of Jars I have on classpath
activation.jar
ant-1.6.2.jar
ant-antlr-1.6.2.jar
ant-junit-1.6.2.jar
ant-launcher-1.6.2.jar
antlr-2.7.4.jar
ant-swing-1.6.2.jar
c3p0-0.8.5.jar
catalina.jar
catalina-optional.jar
cglib-1.0.jar
cglib-2.1_3.jar
cglib-asm-1.0.jar
cglib-full-2.0.2.jar
cglib-full-2.0.jar
cglib-nodep-2.1_3.jar
cleanimports.jar
commons-beanutils-1.6.1.jar
commons-codec-1.3.jar
commons-collections-2.1.1.jar
commons-collections-3.2.jar
commons-dbcp-1.2.2.jar
commons-digester-1.5.jar
commons-discovery.jar
commons-fileupload-1.2.1.jar
commons-io-1.0.jar
commons-jxpath-1.1.jar
commons-lang-2.3.jar
commons-logging-1.0.4.jar
commons-pool-1.4.jar
commons-validator-1.0.2.jar
concurrent-1.3.2.jar
connector.jar
dom4j-1.5.2.jar
dom4j-1.6.1.jar
ehcache-1.1.jar
freemarker-2.3.8.jar
hibernate.jar
hibernate3.jar
jaas.jar
jacc-1_0-fr.jar
javax.servlet.jsp.jar
jaxen-1.1-beta-4.jar
jboss-cache.jar
jboss-common.jar
jboss-jmx.jar
jboss-remoting.jar
jboss-system.jar
jdbc2_0-stdext.jar
jgroups-2.2.7.jar
jta.jar
junit-3.8.1.jar
log4j-1.2.8.jar
log4j-1.2.9.jar
mail.jar
mysql-connector-java-3.0.16-ga-bin.jar
mysql-connector-java-3.1.6-bin.jar
mysql-connector-java-5.1.10-bin.jar
ognl-2.6.11.jar
oscache-2.1.jar
proxool-0.8.3.jar
servlet-api-2.5-6.1.6.jar
sitemesh-2.3.jar
spring.jar
spring-jdbc.jar
struts2-core-2.0.11.2.jar
struts2-spring-plugin-2.0.11.2.jar
swarmcache-1.0rc2.jar
versioncheck.jar
xerces-2.6.2.jar
xml-apis.jar
xwork-2.0.1.jar
the Java Class is
package com.persistance;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import sessionFactory.HibernateSessionFactory;
import org.hibernate.Session;
import org.hibernate.Transaction;
public class TestProject {
public static void main(String[] args) {
Weeksheetdetail weeksheetdetail=new Weeksheetdetail();
Set<Weeksheetdetail> setWeeksheetdetail = new HashSet<Weeksheetdetail>();
weeksheetdetail.setDetail("first row");
setWeeksheetdetail.add(weeksheetdetail);
System.out.println(setWeeksheetdetail.size());
weeksheetdetail.setDetail("second row");
setWeeksheetdetail.add(weeksheetdetail);
System.out.println(setWeeksheetdetail.size());
setWeeksheetdetail.size();
Weeksheet weeksheet=new Weeksheet();
weeksheet.setUserid(2);
//weeksheet.setWeeksheetdetails(setWeeksheetdetail);
Session session= HibernateSessionFactory.getSession();
Transaction tx=session.getTransaction();
try {
tx.begin();
session.save(weeksheet);
// Weeksheet weeksheet2=new Weeksheet(weeksheet.getUserid(),setWeeksheetdetail);
// weeksheet2.setWeeksheetdetails(setWeeksheetdetail);
// session.save(weeksheet2);
Iterator<Weeksheetdetail > iterator = setWeeksheetdetail.iterator();
while(iterator.hasNext()){
Weeksheetdetail weeksheetdetail2=(Weeksheetdetail) iterator.next();
weeksheetdetail2.setWeeksheet(weeksheet);
// System.out.println(weeksheetdetail.getWeeksheet().getSheetid());
session.save(weeksheetdetail2);
weeksheetdetail2.getWsid();
}
}catch (RuntimeException re) {
tx.rollback();
re.printStackTrace();
throw re;
}finally {
if (tx != null && !tx.wasCommitted() && !tx.wasRolledBack()){
tx.commit();
}
}
}
}
this is file from where I am geting session object
package sessionFactory;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
/**
* Configures and provides access to Hibernate sessions, tied to the
* current thread of execution. Follows the Thread Local Session
* pattern, see {@link
http://hibernate.org/42.html }.
*/
public class HibernateSessionFactory {
/**
* Location of hibernate.cfg.xml file.
* Location should be on the classpath as Hibernate uses
* #resourceAsStream style lookup for its configuration file.
* The default classpath location of the hibernate config file is
* in the default package. Use #setConfigFile() to update
* the location of the configuration file for the current session.
*/
private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";
private static final ThreadLocal<Session> threadLocal = new ThreadLocal<Session>();
private static Configuration configuration = new Configuration();
private static org.hibernate.SessionFactory sessionFactory;
private static String configFile = CONFIG_FILE_LOCATION;
private HibernateSessionFactory() {
}
/**
* Returns the ThreadLocal Session instance. Lazy initialize
* the <code>SessionFactory</code> if needed.
*
* @return Session
* @throws HibernateException
*/
public static Session getSession() throws HibernateException {/*
Session session = (Session) threadLocal.get();
if (session == null || !session.isOpen()) {
if (sessionFactory == null) {
rebuildSessionFactory();
}
session = (sessionFactory != null) ? sessionFactory.openSession()
: null;
threadLocal.set(session);
}
return session;
*/
Session session = null;
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
return session;
}
/**
* Rebuild hibernate session factory
*
*/
public static void rebuildSessionFactory() {
try {
configuration.configure(configFile);
sessionFactory = configuration.buildSessionFactory();
} catch (Exception e) {
System.err
.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
/**
* Close the single hibernate session instance.
*
* @throws HibernateException
*/
public static void closeSession() throws HibernateException {
Session session = (Session) threadLocal.get();
threadLocal.set(null);
if (session != null) {
session.close();
}
}
/**
* return session factory
*
*/
public static org.hibernate.SessionFactory getSessionFactory() {
return sessionFactory;
}
/**
* return session factory
*
* session factory will be rebuilded in the next call
*/
public static void setConfigFile(String configFile) {
HibernateSessionFactory.configFile = configFile;
sessionFactory = null;
}
/**
* return hibernate configuration
*
*/
public static Configuration getConfiguration() {
return configuration;
}
}
Please help me for above issue .............