Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2013
    Location
    coimbatore
    Posts
    6
    Rep Power
    0

    Default Error in Spring Aop

    Hi
    Am beginner for Spring framework. Now am leaning Spring AOP. When I use this below mentioned code
    am getting error like this,

    Nov 30, 2013 5:24:18 PM org.springframework.context.support.ClassPathXmlAp plicationContext prepareRefresh
    INFO: Refreshing org.springframework.context.support.ClassPathXmlAp plicationContext@988707: startup date [Sat Nov 30 17:24:17 IST 2013]; root of context hierarchy
    Nov 30, 2013 5:24:18 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [aspectFile.xml]
    Nov 30, 2013 5:24:18 PM org.springframework.beans.factory.support.DefaultL istableBeanFactory destroySingletons
    INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@b99d08: defining beans [org.springframework.aop.config.internalAutoProxyCr eator,trianle,AspectClass]; root of factory hierarchy
    Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.aop.config.internalAutoProxyC reator': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.springframework.aop.aspectj.annotation.Annotat ionAwareAspectJAutoProxyCreator]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.instantiateBean(Abstrac tAutowireCapableBeanFactory.java:1007)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:953)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:487)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 95)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:223)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:292 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:198)
    at org.springframework.context.support.AbstractApplic ationContext.registerBeanPostProcessors(AbstractAp plicationContext.java:741)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:464)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:139)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:83)
    at org.sasi.springwork.aspect.AsspectApplication.main (AsspectApplication.java:10)
    Caused by: org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.springframework.aop.aspectj.annotation.Annotat ionAwareAspectJAutoProxyCreator]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice
    at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:163)
    at org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:87)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.instantiateBean(Abstrac tAutowireCapableBeanFactory.java:1000)
    ... 12 more
    Caused by: java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknow n Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknow n Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknow n Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.springframework.aop.aspectj.annotation.Annotat ionAwareAspectJAutoProxyCreator.<init>(AnnotationA wareAspectJAutoProxyCreator.java:53)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:148)
    ... 14 more
    Caused by: java.lang.ClassNotFoundException: org.aopalliance.aop.Advice
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 56 more


    my code:
    aspectFile.xml
    <?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"
    xmlns:context ="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-3.0.xsd
    Index of /schema/context
    http://www.springframework.org/schem...ontext-3.0.xsd
    Index of /schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">


    <aop:aspectj-autoproxy/>


    <bean id="triangle" class="org.sasi.springwork.aspect.Triangle">
    <property name="name" value="AOP "/>
    </bean>

    <bean name="AspectClass" class="org.sasi.springwork.aspect.AspectClass"/>
    </beans>



    package org.sasi.springwork.aspect;

    import org.aspectj.lang.annotation.Aspect;
    import org.aspectj.lang.annotation.Before;

    @Aspect
    public class AspectClass {

    @Before("execution(public String getName())")
    public void login(){
    System.out.println("Safe to run");
    }



    Some one please help me..

    Thanks in advance

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Error in Spring Aop

    You need the aopalliance.jar file.
    Please do not ask for code as refusal often offends.

  3. #3
    Join Date
    Nov 2013
    Location
    coimbatore
    Posts
    6
    Rep Power
    0

    Default Re: Error in Spring Aop

    Thanks for your reply Tolls. I added aopalliance.jar file in my project. Then, I tried to run my program but I faced below mentioned error. Kindly let me know why am facing this error.

    INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@19fc023: defining beans [org.springframework.aop.config.internalAutoProxyCr eator,triangle,AspectClass]; root of factory hierarchy
    Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'triangle' defined in class path resource [aspectFile.xml]: Initialization of bean failed; nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.cglib.core.DebuggingClassWrite r has interface org.springframework.asm.ClassVisitor as super class
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:529)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 95)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:223)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:292 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:628)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:479)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:139)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:83)
    at org.sasi.springwork.aspect.AsspectApplication.main (AsspectApplication.java:11)
    Caused by: java.lang.IncompatibleClassChangeError: class org.springframework.cglib.core.DebuggingClassWrite r has interface org.springframework.asm.ClassVisitor as super class




    Thanks in advance

  4. #4
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,089
    Rep Power
    4

    Default Re: Error in Spring Aop

    Try copy/pasting that error

    Java Code:
    Caused by: java.lang.IncompatibleClassChangeError: class org.springframework.cglib.core.DebuggingClassWriter has interface org.springframework.asm.ClassVisitor as super class
    into google and see what you get.

    My quick-scan assumption is that you have libraries deployed with your application that shouldn't be there, such as (wrong versions of) cglib and asm.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    Join Date
    Nov 2013
    Location
    coimbatore
    Posts
    6
    Rep Power
    0

    Default Re: Error in Spring Aop

    Thanks gimbal2..

  6. #6
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,089
    Rep Power
    4

    Default Re: Error in Spring Aop

    Thanks because you solved your problem?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    Join Date
    Nov 2013
    Location
    coimbatore
    Posts
    6
    Rep Power
    0

    Default Re: Error in Spring Aop

    Yes gimbal2 I solved my problem.

  8. #8
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,089
    Rep Power
    4

    Default Re: Error in Spring Aop

    Good work then. Please share what you did to fix it so that other people with the same problem who find this thread can do the same.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  9. #9
    Join Date
    Apr 2014
    Posts
    7
    Rep Power
    0

Similar Threads

  1. Spring ERROR: ContextLoaderListener
    By vitaliy1901 in forum Spring
    Replies: 0
    Last Post: 11-07-2012, 01:31 PM
  2. Spring @RequestMapping and Error 400
    By megabyte in forum Web Frameworks
    Replies: 4
    Last Post: 03-16-2011, 02:15 PM
  3. Spring Configuration Error - XML issue?
    By hofsoc in forum New To Java
    Replies: 0
    Last Post: 09-20-2010, 03:21 PM
  4. Spring Mvc 404 error
    By jadeite100 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 01-04-2010, 06:38 AM
  5. Spring Mvc 404 error
    By jadeite100 in forum Web Frameworks
    Replies: 0
    Last Post: 01-04-2010, 06:21 AM

Posting Permissions

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