It seems that I searched for information from various sources over google to solve my problem, but I am still in trouble. To clarify my problem I will give you as much information as I can.
I am using NetBeans IDE 7.3.1 and Spring 3.1.1.
What I have now:
I created 6 classes and 1 xml file.
These classes are working fine (because these classes are based from book which I am currently reading).
I suppose something is wrong with my jar files (maybe somthing is wrong with versions compatibility or something (idk, i am new in this scope)).
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 id="knight" class="castle.BraveKnight">
<constructor-arg ref = "quest"/>
</bean>
<bean id="quest"
class="castle.SlayedDragonQuest"/>
<bean id="mistreal"
class="castle.Mistreal"/>
<aop:config>
<aop:aspect ref="mistreal">
<aop:pointcut id="embark"
expression="execution(* *.embarkQuest(..))" />
<aop:before pointcut-ref="embark"
method="singBeforeQuest"/>
<aop:after pointcut-ref="embark"
method="signAfterQuest"/>
</aop:aspect>
</aop:config>
</beans>
After compiling my code, I am getting this:
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [knight.xml]; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice
It is obvious that classloader cannot find my aop class which is called Advice. But why?
I added jars to my project like this:
Did I miss something? Can anyone give me some information. (I read related resources but result is the same).
Thank you
EDITED:
I added aopalliance.jar file, now I am getting this:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'knight' defined in class path resource [knight.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#1': Cannot create inner bean '(inner bean)' of type [org.springframework.aop.aspectj.AspectJAfterAdvice] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#2': Cannot create inner bean '(inner bean)' of type [org.springframework.aop.config.MethodLocatingFactoryBean] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#2': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Unable to locate method [signAfterQuest] on bean [mistreal] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:452) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
It seems that one solution rises another problem. How can I fix it? P.s. I am not using a Marven. And also this is a mistake in my picture, i fixed it in my project, but it didn't change anything.
Mistreal class:
package castle;
public class Mistreal {
public void singBeforeQuest(){
System.out.println("Singing before quest");
}
public void singAfterQuest(){
System.out.println("Singing after quest");
}
}