Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring aop java.lang.NoClassDefFoundError

I have a problem with aop config. Here is part of my spring xml config:

<bean id="conLogger" class="com.pomkine.pXMPP.connection_service.ConnectionLogger"/>

<aop:config>
    <aop:aspect ref="conLogger">
        <aop:pointcut id="connect"
                      expression= "execution(* com.pomkine.pXMPP.connection_service.connectionManager.connect(..))" />
        <aop:after pointcut-ref="connect"
                   method="connected"/>
    </aop:aspect>
</aop:config>

Here is my main method:

public static void main (String [] args) {
    ApplicationContext ac = new ClassPathXmlApplicationContext("com/pomkine/pXMPP/connection_service/connection-manager.xml");
    connectionManager cm=(connectionManager)ac.getBean("connectionManager");
    try {
        cm.connect();
        cm.disconnect();
      } catch (XMPPException e) {
        e.printStackTrace();
    }

}

When I'm runnig it I'm getting NoClassDefFoundError exception.

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connect': Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException

Can't figure out what the problem is. Would appreciate any help.

like image 654
pomkine Avatar asked Sep 14 '12 21:09

pomkine


1 Answers

This question: Missing Spring AOP libraries in STS seems to address a similar problem (missing libraries), also a problem in this Spring Forum thread.

Do you have the mentioned jars on your classpath?

<dependency>
    <groupId>cglib</groupId>
    <artifactId>cglib</artifactId>
    <version>2.2</version>
</dependency>
<dependency>  
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.6.11</version>
</dependency>
like image 174
Pao Avatar answered Oct 15 '22 00:10

Pao