-->
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.  [ 4 posts ] 
Author Message
 Post subject: at net.sf.cglib.core.ClassEmitter.setTarget(ClassEmitter.jav
PostPosted: Wed Dec 02, 2009 3:05 am 
Newbie

Joined: Wed Dec 02, 2009 2:38 am
Posts: 1
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 .............


Top
 Profile  
 
 Post subject: Re: at net.sf.cglib.core.ClassEmitter.setTarget(ClassEmitter.jav
PostPosted: Sun Jun 06, 2010 11:18 am 
Newbie

Joined: Sun Jun 06, 2010 10:44 am
Posts: 3
Please add these below jar file, you problem will be solved.

mysql-connector-java-3.1.12-bin.jar
commons-logging-1.1.jar
dom4j-1.6.1.jar
commons-collections-3.2.jar
log4j-1.2.15.jar
slf4j-1.6.0/slf4j-1.6.0/slf4j-api-1.6.0.jar
slf4j-1.6.0/slf4j-1.6.0/slf4j-log4j12-1.6.0.jar
slf4j-1.6.0/slf4j-1.6.0/slf4j-simple-1.6.0.jar
javassist-3.3.jar
jta-1.0.1B.jar
hibernate-commons-annotations-3.1.0.GA.jar
hibernate-annotations-3.1beta8.jar
hibernate-core-3.3.1.GA.jar
antlr-2.7.5H3.jar

I had the same problem and now working fine.

I followed this below tutorial to solve my issue.
http://ayushsuman.blogspot.com/2010/06/first-hibernate-example-hibernate.html

Thanks,

Binod Suman


Top
 Profile  
 
 Post subject: Re: at net.sf.cglib.core.ClassEmitter.setTarget(ClassEmitter.jav
PostPosted: Fri Jul 15, 2011 6:12 am 
Newbie

Joined: Fri Jul 15, 2011 3:34 am
Posts: 3
I also have same problem. It's working fine in my application.
But it shows error only when i use annotation class .

These are the errors.
Code:
java.lang.IllegalAccessError
Exception in thread "main" java.lang.ExceptionInInitializerError
   at com.vaannila.util.HibernateUtil.<clinit>(HibernateUtil.java:14)
   at com.vaannila.course.Main.saveCourse(Main.java:27)
   at com.vaannila.course.Main.main(Main.java:16)
Caused by: 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:117)
   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:295)
   at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
   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:1294)
   at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
   at com.vaannila.util.HibernateUtil.<clinit>(HibernateUtil.java:11)
   ... 2 more


Top
 Profile  
 
 Post subject: Re: at net.sf.cglib.core.ClassEmitter.setTarget(ClassEmitter.jav
PostPosted: Fri Jul 15, 2011 6:47 am 
Newbie

Joined: Fri Jul 15, 2011 3:34 am
Posts: 3
Now it's working.

Instead of
hibernate-commons-annotations-3.1.0.GA.jar
hibernate-annotations-3.1beta8.jar

i use
hibernate-commons-annotations-3.3.0.ga.jar
hibernate-annotations-3.3.0.ga.jar

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.