linker85
linker85

Reputation: 1651

why is my webapplication NoClassDefFoundError: org/aspectj/lang/reflect/AjTypeSystem

I´ve a maven web application. I´m using JSF, Primefaces, Hibernate, Spring, Spring AOP and ORACLE 11g. So when I deploy my application on Glassfish 3 it works perfectly, but when I deploy it on weblogic 12 I get the next error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Usuarios' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/lang/reflect/AjTypeSystem

Caused By: java.lang.NoClassDefFoundError: org/aspectj/lang/reflect/AjTypeSystem

So I opened my war then I looked in WEB-INF/lib and I found (aspectjrt.jar and aspectweaver.jar), so I´m not sure what´s wrong. Here is the part of my pom where I declare the aspectJ libs:

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <spring.version>3.2.4.RELEASE</spring.version>
    <aspectj.version>1.7.0</aspectj.version>
    <java.version>1.7</java.version>
    <netbeans.hint.deploy.server>WebLogic9</netbeans.hint.deploy.server>
    <netbeans.hint.j2eeVersion>1.6</netbeans.hint.j2eeVersion>
</properties>


    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency> 

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>${spring.version}</version>
    </dependency>        
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aspects</artifactId>
        <version>${spring.version}</version>
    </dependency>      
    <!-- aspectJ -->
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>${aspectj.version}</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>${aspectj.version}</version>
    </dependency> 

So does anyone knows what´s happening. I already googled the error but every one says that the aspectjrt.jar and aspectweaver.jar might be missing, but I´m pretty sure they aren´t.

Thanks in advance.

Upvotes: 0

Views: 2620

Answers (1)

vorburger
vorburger

Reputation: 3938

Have you tried this in weblogic.xml :

<container-descriptor>
   <prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>

and this in weblogic-application.xml :

   <prefer-application-packages>
      <package-name>org.springframework.*</package-name>
   </prefer-application-packages>

I haven't tried this myself, but found this on http://forum.spring.io/forum/spring-projects/aop/91846-can-t-find-ajtypesystem-during-deployment .. basically what's going is that even that you have aspectjrt.jar and aspectweaver.jar in your WAR, they don't get loaded because WLS thinks they are available somewhere else in its system classpath ("higher up" in the classloader hierarchy typically), sometimes with another version. This is a typical problem on EE application servers, and each one of them (WLS, WAS, JBoss) has some configuration to influence class path loading order. If above doesn't exactly work, Google that further, and you'll figure it out... best of luck.

Upvotes: 3

Related Questions