Results 1 to 6 of 6

Thread: Couldn't generate CGLIB subclass of class : org.springframework.aop.framework.AopConf

  1. #1
    Join Date
    Oct 2007
    Posts
    13

    Default Couldn't generate CGLIB subclass of class : org.springframework.aop.framework.AopConf

    Dear All,

    I am having a problem with simple AOP application. Actually I think the proxy of my class does not created. So anybody please guide what is the actually problem and how can I resolve this. I am using Eclipse6 IDE and I added the following jars.

    spring-beans.jar
    spring-context.jar
    spring-core.jar
    commons-attributes-api.jar
    commons-attributes-comiler.jar
    commons-logging.jar
    log4j-1.2.14.jar

    spring-aop.jar
    spring-agent.jar
    spring-tomcat-weaver.jar
    asm-2.2.3.jar
    asm-comons-2.2.3.jar
    asm-util-2.2.3.jar
    aspectjrt.jar
    aspectjweaver.jar
    aopalliance.jar
    cglib-nodep-2.1_3.jar
    jakarta-2.0.8.jar


    I found the following Exceptions

    Code:
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testDao' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Couldn't generate CGLIB subclass of class [class test.TestDao]: Common causes of this problem include using a final class or a non-visible class; nested exception is net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
    Caused by: org.springframework.aop.framework.AopConfigException: Couldn't generate CGLIB subclass of class [class test.TestDao]: Common causes of this problem include using a final class or a non-visible class; nested exception is net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
    Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
    	at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237)
    	at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
    	at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
    	at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:196)
    	at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:429)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:299)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:315)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1181)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:428)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:270)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
    	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:733)
    	at main.SpringMain.main(SpringMain.java:17)
    Caused by: java.lang.reflect.InvocationTargetException
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
    	at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
    	... 13 more
    Caused by: java.lang.SecurityException: class "test.TestDao$$EnhancerByCGLIB$$651400c9"'s signer information does not match signer information of other classes in the same package
    	at java.lang.ClassLoader.checkCerts(Unknown Source)
    	at java.lang.ClassLoader.preDefineClass(Unknown Source)
    	at java.lang.ClassLoader.defineClass(Unknown Source)
    	... 19 more
    my applicationCotext.xml is as follows

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:aop="http://www.springframework.org/schema/aop"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
               http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
    
    	<bean id="testDao" class="test.TestDao" scope="prototype"></bean>
    	
    	<bean id="methodTimingAdvice" class="interceptor.MethodTimingInterceptor"/>
    	
    	<aop:config>
    		<aop:pointcut id="getCountriesPointCut" expression="execution(* test.TestDao.getCountries())"/>
    		<aop:advisor id="methodTimingAdvisor" advice-ref="methodTimingAdvice" pointcut-ref="getCountriesPointCut"/>
    	</aop:config>
    </beans>
    my testDao class is as follows...
    Code:
    public TestDao(){
    		System.out.println("Instance of TestDao is being created");
    	}
    	
    	@Override
    	public String toString() {
    		return "New Object of TestDao created at ---> "+super.toString();
    	}
    	
    	public List<String> getCountries(){
                            //having some db logic
                 }
    }
    my TimingInteceptor is as follows

    Code:
    package interceptor;
    
    import java.math.BigDecimal;
    
    import org.aopalliance.intercept.MethodInterceptor;
    import org.aopalliance.intercept.MethodInvocation;
    import org.apache.commons.lang.time.DateUtils;
    import org.apache.commons.lang.time.StopWatch;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    
    public class MethodTimingInterceptor implements MethodInterceptor {
    
    	final Log log = LogFactory.getLog(getClass());
    	
    	public Object invoke(final MethodInvocation methodinoInvocation) throws Throwable {
    		
    		Object methodResult = null;
    		final StopWatch stopWatch = new StopWatch();
    		stopWatch.start();
    		
    		try{
    			methodResult = methodinoInvocation.proceed();
    		}finally{
    			stopWatch.stop();
    		}
    		
    		final long milis = stopWatch.getTime();
    		
    		final BigDecimal seconds = new BigDecimal(milis).divide(new BigDecimal(DateUtils.MILLIS_PER_SECOND), BigDecimal.ROUND_HALF_UP);
    		
    		log.info("Method Invocation : "+methodinoInvocation.getThis().getClass().getName()+" : "
    				+methodinoInvocation.getMethod().getName()+" /n Total Time of Execution : "+seconds+" Seconds "+milis+" Milis");
    
    		return methodResult;
    	}
    
    }
    Thank you very much in advance for you response.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Code:
    Caused by: java.lang.SecurityException: class "test.TestDao$$EnhancerByCGLIB$$651400c9"'s signer information does not match signer information of other classes in the same package
    Are you working with signed jars?
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Oct 2007
    Posts
    13

    Default

    Dear Marten,

    Thanks a lot for prompt reply. I am using the jars which Eclipse provides by default and I think those are signed as having the following files.

    gunitc.sf and
    gunitc.dsa

    So now will you please tell me that what should I do to make my program run ?

    should I need to add new jars or some other steps I need to take ?

    Thanking you,

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    I am using the jars which Eclipse provides by default
    Which jars?
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Oct 2007
    Posts
    13

    Default

    The list of jars are as follows. Which are available with Eclipse6 by default and these jar files also having the
    gunitc.sf and
    gunitc.dsa



    spring-beans.jar
    spring-context.jar
    spring-core.jar
    commons-attributes-api.jar
    commons-attributes-comiler.jar
    commons-logging.jar
    log4j-1.2.14.jar

    spring-aop.jar
    spring-agent.jar
    spring-tomcat-weaver.jar
    asm-2.2.3.jar
    asm-comons-2.2.3.jar
    asm-util-2.2.3.jar
    aspectjrt.jar
    aspectjweaver.jar
    aopalliance.jar
    cglib-nodep-2.1_3.jar
    jakarta-2.0.8.jar

  6. #6
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Don't use the ones from eclipse, use the ones provided by spring.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •