0
votes

Below is the XMl file.

        <?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-3.0.xsd 
    http://www.springframework.org/schema/aop 
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd ">

        <!-- bean definition & AOP specific configuration -->
    <aop:aspectj-autoproxy/> 


        <bean name = "circle" class = "com.SpringAOP.Model.Circle">
    <property name = "name" value = "circle name"/>
    </bean>

    <bean name = "triangle" class = "com.SpringAOP.Model.Triangle">
    <property name = "name" value = "triangle name"/>
    </bean>



    <bean name = "shapeservice" class ="com.SpringAOP.Service.ShapeService" autowire      = "byName"/>

    <bean name = "loggingaspect" class = "com.SpringAOP.Aspect.LoggingAspect"/>

    </beans>

Im getting the below execption while running the application and the above xml was able to create the bean without the AOP tag. please let me know is it something related to the jars.

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'circle' defined in class path resource [Spring.xml]: Initialization of bean failed; nested exception is java.lang.IllegalAccessError at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83) at com.SpringAOP.AOPMain.main(AOPMain.java:10)

1
any private constructors?Evgeni Dimitrov
review all your constructors, getter/setters for there access modifiers, check if inside constructor you are calling something which is again not reachable because of access modifiers. Verify if Runtime version of classes are same as your compile-time classes.sakura
no private constructors. let me know if you need any additional informationuser2681868
Can you post the Circle class?Evgeni Dimitrov
package com.SpringAOP.Model; public class Circle { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; }user2681868

1 Answers

0
votes

Even i tried the same code and was getting the same error. I resolved it by using the correct aopalliance-1.0. jar. The jar mentioned in the link of the above code was throwing an error. and hence i dowloaded it individually.

Also I was using the cglib version 3.1 so i changed it to 2.2.2.

It worked.

Sonal