Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] [aspectj plugin] weaving jars to other projects + 3rd party libaries not found in those projects

Hi Michael,
the Maven mojo requires that in the pom.xml of the second project, you need to specify, using <weavedependencies>, on which dependencies you want to apply the aspects. See http://mojo.codehaus.org/aspectj-maven-plugin/weaveJars.html . Also, the libraries used by the aspects should be in the pom.xml of the aspect project as dependencies without any particular scope (so that they are carried), and the aspect library itself should be in the dependencies of the second project without any particular scope.

It looks like it is a classpath problem, cause it arrives to the aspectOf call, meaning that something has been weaved. You should try to execute a mvn dependency:tree on the final project (the one you actually run), to see if the required library (the one containing org/wsml/reasoner/api ) is there or not, it could simply be that it is not included as a dependency in the pom.xml file and as such not "transported" up to your final project. If you want you can send the whole pom.xml files.

If it is there, then it is not loaded by your runtime. What are you building and running? A war? Otherwise can you see the classpath it is working on?

Sorry for being vague, but after looking the pom fragment and the stacktrace it seems to be a different problem than simply a mojo misconfiguration.

Simone




Michael Rogger wrote:
Hi Simone,

thx for the fast reply. The plugin part from the project where the aspect is located is the following:

           <plugin>
               <groupId>org.codehaus.mojo</groupId>
               <artifactId>aspectj-maven-plugin</artifactId>
               <executions>
                   <execution>
                       <goals>
                           <goal>compile</goal>
                       </goals>
                   </execution>
               </executions>
               <configuration>
                   <source>1.6</source>
                   <target>1.6</target>
                   <verbose>true</verbose>
                   <outxml>false</outxml>
                   <showWeaveInfo>true</showWeaveInfo>
                   <aspectDirectory>src/main/aspectj</aspectDirectory>
<testAspectDirectory>src/test/java</testAspectDirectory>
               </configuration>
           </plugin>

And the next plugin part is in another project where I inject the compiled aspects into:


           <plugin>
           <groupId>org.codehaus.mojo</groupId>
           <artifactId>aspectj-maven-plugin</artifactId>
           <executions>
             <execution>
             <phase>compile</phase>
               <goals>
                 <goal>compile</goal>
               </goals>
             </execution>
           </executions>
           <configuration>
             <source>1.6</source>
             <target>1.6</target>
             <verbose>true</verbose>
             <outxml>false</outxml>
             <showWeaveInfo>true</showWeaveInfo>
               <aspectLibraries>
                   <aspectLibrary>
                       <groupId>wsmx</groupId>
                       <artifactId>wsmx-securitymanager</artifactId>
                   </aspectLibrary>
               </aspectLibraries>
           </configuration>
           </plugin>


The error trace:
...
12:35:56,888 Reviver::ServiceDiscoveryFramework WARN AbstractExecutionSemantic: Failure during execution of state PerformServiceDiscovery. org.aspectj.lang.NoAspectBoundException: Exception while initializing at_sti2_wsmx_securitymanager_aspects_SecurityAspect: java.lang.NoClassDefFoundError: org/wsml/reason
er/api/inconsistency/InconsistencyException
at at.sti2.wsmx.securitymanager.aspects.SecurityAspect.aspectOf(SecurityAspect.aj:1) at ie.deri.wsmx.servicediscovery.ServiceDiscoveryFramework.discoverServiceCompositon(ServiceDiscoveryFramework.java:128) at ie.deri.wsmx.executionsemantic.AchieveGoalChor$PerformServiceDiscovery.handleState(AchieveGoalChor.java:530) at ie.deri.wsmx.executionsemantic.AbstractExecutionSemantic.runState(AbstractExecutionSemantic.java:98) at ie.deri.wsmx.scheduler.GenericReviver.run(GenericReviver.java:138)
       at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org/wsml/reasoner/api/inconsistency/InconsistencyException at at.sti2.wsmx.securitymanager.aspects.SecurityAspect.<init>(SecurityAspect.aj:35) at at.sti2.wsmx.securitymanager.aspects.SecurityAspect.ajc$postClinit(SecurityAspect.aj:1) at at.sti2.wsmx.securitymanager.aspects.SecurityAspect.<clinit>(SecurityAspect.aj:19) at ie.deri.wsmx.executionsemantic.AchieveGoalChor$PerformServiceDiscovery.handleState(AchieveGoalChor.java)
       ... 3 more
Caused by: java.lang.ClassNotFoundException: org.wsml.reasoner.api.inconsistency.InconsistencyException
       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.loadClassInternal(Unknown Source)
       ... 7 more
12:35:56,888 Reviver::ServiceDiscoveryFramework WARN GenericReviver : Failure during execution of state, killing active execution semantic.

Best regards
Michael

Simone Gianni schrieb:
Hi Michael,
can you post the <plugin> part of the pom.xml where you are configuring the AspectJ mojo?

Also, could you post the stacktrace of the exception?

Simone

Michael Rogger wrote:
Hi,

I'm using the maven plugin for aspectj, but I think most of you use that too, so I write to this mailinglist ;) I have several projects (each project is a component for the whole system) and I apply already compiled aspects to them. Everything works fine until I access a 3rd party library from the aspect, for example I call a factory class or make an instance. If I do that, I get a java.lang.NoClassDefFoundError execption, so the classloader cannot find the library. I tried several things: First I tried to include the library directly into the compiled aspect lib. The second thing I tried was to include that library in the project where I injected the aspect code using the compiled aspect lib. Unfortunately none of both worked for me and the java.lang.NoClassDefFoundError remains. My question is, how do you access within an aspect a 3rd party library? I mean where can I put those libaries into, in order that the classloader can find it, in each proejct where I weave the compiled aspects?

Thank you very much for your help, I hope someone can help me!

Best regards
Rogger







--
Simone Gianni            CEO Semeru s.r.l.           Apache Committer
http://www.simonegianni.it/



Back to the top