2 Replies Latest reply on Jul 22, 2008 7:02 PM by ironbeard

    aopc error: DuplicateMemberException: duplicate field

    ironbeard Newbie

      I'm trying to create a JBoss MBean service (JBoss AS 4.2.2GA, JBossCache 1.4.1SP3, JDK50-type annotation) to write/read a PojoCache.
      So far, without much success. The simple test I'm trying to get working uses the Address class from the examples in jboss-cache-dist-1.4.1.SP3.zip. I can't get aopc to weave it.

      Here's my build.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <project name="Packager" default="aopc">
      <property name="jboss-lib" value="C:/jboss-4.2.2.GA/lib"/>
      <property name="jboss-all" value="C:/jboss-4.2.2.GA/server/all"/>
      <property name="jboss-all-lib" value="${jboss-all}/lib"/>
      <property name="jboss-all-aop" value="${jboss-all}/deploy/jboss-aop-jdk50.deployer"/>
      <property name="output-dir" value="./build"/>
      <property name="class-dir" value="${output-dir}/classes"/>
      <property name="aop-file" value="./ejbModule/META-INF/jboss-aop.xml"/>
      
      <path id="lib.classpath">
       <pathelement path="${jboss-all}/lib/javassist.jar"/>
       <pathelement path="${jboss-all-aop}/trove.jar"/>
       <pathelement path="${jboss-lib}/concurrent.jar"/>
       <pathelement path="${jboss-lib}/jboss-common.jar"/>
      </path>
      
      <path id="aop.classpath">
       <pathelement path="${jboss-all-aop}/jboss-aop-jdk50.jar"/>
       <pathelement path="${jboss-all-lib}/jboss-cache-jdk50.jar"/>
      </path>
      
      <path id="full.classpath">
       <path refid="lib.classpath"/>
       <path refid="aop.classpath"/>
       <pathelement path="${class-dir}"/>
      </path>
      
      <taskdef name="aopc" classname="org.jboss.aop.ant.AopC"
       classpathref="aop.classpath"/>
      
      <target name="aopc">
       <aopc compilerclasspathref="full.classpath" verbose="true">
       <classpath path="${class-dir}/test/cache"/>
       <src path="${class-dir}/test/cache"/>
       <aopclasspath refid="aop.classpath"/>
       <aoppath path="${aop-file}"/>
       </aopc>
      </target>
      </project>


      ... and my jboss-aop.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <aop>
       <prepare expr="field(* @org.jboss.cache.aop.annotation.PojoCacheable->*)" />
       <bind pointcut="set(* @org.jboss.cache.aop.annotation.PojoCacheable->*)">
       <interceptor class="org.jboss.aspects.patterns.observable.SubjectInterceptor"/>
       </bind>
       <introduction class="@org.jboss.cache.aop.annotation.PojoCacheable">
       <mixin>
       <interfaces>org.jboss.aspects.patterns.observable.Subject</interfaces>
       <class>org.jboss.aspects.patterns.observable.SubjectImpl</class>
       <construction>new org.jboss.aspects.patterns.observable.SubjectImpl(this)</construction>
       </mixin>
       </introduction>
      
       <prepare expr="field(* $instanceof{@org.jboss.cache.aop.annotation.InstanceOfPojoCacheable}->*)" />
       <bind pointcut="set(* @org.jboss.cache.aop.annotation.InstanceOfPojoCacheable->*)">
       <interceptor class="org.jboss.aspects.patterns.observable.SubjectInterceptor"/>
       </bind>
       <introduction class="@org.jboss.cache.aop.annotation.InstanceOfPojoCacheable">
       <mixin>
       <interfaces>org.jboss.aspects.patterns.observable.Subject</interfaces>
       <class>org.jboss.aspects.patterns.observable.SubjectImpl</class>
       <construction>new org.jboss.aspects.patterns.observable.SubjectImpl(this)</construction>
       </mixin>
       </introduction>
      </aop>


      That generates this log:

      Buildfile: D:\Projects\cache\ejb\build.xml
      aopc:
       [aopc] [debug] Passed in instrumentor: null
       [aopc] [debug] Defaulting instrumentor to: org.jboss.aop.instrument.ClassicInstrumentor
       [aopc] [debug] jboss.aop.class.path: C:\jboss-4.2.2.GA\server\all\deploy\jboss-aop-jdk50.deployer\jboss-aop-jdk50.jar;C:\jboss-4.2.2.GA\server\all\lib\jboss-cache-jdk50.jar
      
       ... long list of "looking for aspects in...", ending with ...
      
       [aopc] [debug] Looking for aspects in: org.jboss.cache.aop.annotation.InstanceOfPojoCacheable
       [aopc] [debug] Looking for aspects in: org.jboss.cache.aop.annotation.NonTransient
       [aopc] [debug] Looking for aspects in: org.jboss.cache.aop.annotation.PojoCacheable
       [aopc] [debug] Looking for aspects in: org.jboss.cache.aop.annotation.Serializable
       [aopc] [debug] Looking for aspects in: org.jboss.cache.aop.annotation.Transient
       [aopc] [debug] jboss.aop.search.classpath: 'null' true
       [aopc] [deploying] file:/D:/Projects/cache/ejb/build/classes/META-INF/jboss-aop.xml
       [aopc] AspectXMLLoader using managerorg.jboss.aop.AspectManager@a39137
       [aopc] [debug] jboss.aop.path: D:\Projects\cache\ejb\ejbModule\META-INF\jboss-aop.xml
       [aopc] jboss.aop.path[0]: D:\Projects\cache\ejb\ejbModule\META-INF\jboss-aop.xml
       [aopc] [deploying] file:/D:/Projects/cache/ejb/ejbModule/META-INF/jboss-aop.xml
       [aopc] AspectXMLLoader using managerorg.jboss.aop.AspectManager@a39137
       [aopc] [trying to transform] test.cache.Address
       [aopc] [debug] There are no caller pointcuts!
       [aopc] [debug] javassist.CtMethod@d23b05a4[public setCity (Ljava/lang/String;)V] matches no pointcuts
       [aopc] [debug] javassist.CtMethod@140512a2[public getCity ()Ljava/lang/String;] matches no pointcuts
       [aopc] [debug] javassist.CtMethod@2e76bf69[public setZip (I)V] matches no pointcuts
       [aopc] [debug] javassist.CtMethod@75863e2c[public getZip ()I] matches no pointcuts
       [aopc] [debug] javassist.CtMethod@764fe7bc[public setStreet (Ljava/lang/String;)V] matches no pointcuts
       [aopc] [debug] javassist.CtMethod@e69b9dba[public getStreet ()Ljava/lang/String;] matches no pointcuts
       [aopc] [debug] javassist.CtMethod@ae73fc2d[public getSimpleAddress ()Ljava/lang/String;] matches no pointcuts
       [aopc] [debug] javassist.CtMethod@69cb6c6d[public toString ()Ljava/lang/String;] matches no pointcuts
       [aopc] [debug] javassist.CtConstructor@540408[public Address ()V] matches no pointcuts
       [aopc] javassist.NotFoundException: org.jboss.aspects.patterns.observable.SubjectImpl
       [aopc] at javassist.ClassPool.get(ClassPool.java:436)
       [aopc] at org.jboss.aop.instrument.Instrumentor.addMixin(Instrumentor.java:250)
       [aopc] at org.jboss.aop.instrument.Instrumentor.instrumentIntroductions(Instrumentor.java:375)
       [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:717)
       [aopc] at org.jboss.aop.AspectManager.translate(AspectManager.java:910)
       [aopc] at org.jboss.aop.AspectManager.transform(AspectManager.java:822)
       [aopc] at org.jboss.aop.standalone.Compiler.compileFile(Compiler.java:345)
       [aopc] at org.jboss.aop.standalone.Compiler.compile(Compiler.java:234)
       [aopc] at org.jboss.aop.standalone.Compiler.main(Compiler.java:90)
       [aopc] java.lang.RuntimeException: failed to transform: test.cache.Address
       [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:777)
       [aopc] at org.jboss.aop.AspectManager.translate(AspectManager.java:910)
       [aopc] at org.jboss.aop.AspectManager.transform(AspectManager.java:822)
       [aopc] at org.jboss.aop.standalone.Compiler.compileFile(Compiler.java:345)
       [aopc] at org.jboss.aop.standalone.Compiler.compile(Compiler.java:234)
       [aopc] at org.jboss.aop.standalone.Compiler.main(Compiler.java:90)
       [aopc] Caused by: javassist.NotFoundException: org.jboss.aspects.patterns.observable.SubjectImpl
       [aopc] at javassist.ClassPool.get(ClassPool.java:436)
       [aopc] at org.jboss.aop.instrument.Instrumentor.addMixin(Instrumentor.java:250)
       [aopc] at org.jboss.aop.instrument.Instrumentor.instrumentIntroductions(Instrumentor.java:375)
       [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:717)
       [aopc] ... 5 more
       [aopc] Exception in thread "main" java.lang.RuntimeException: failed to transform: test.cache.Address
       [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:777)
       [aopc] at org.jboss.aop.AspectManager.translate(AspectManager.java:910)
       [aopc] at org.jboss.aop.AspectManager.transform(AspectManager.java:822)
       [aopc] at org.jboss.aop.standalone.Compiler.compileFile(Compiler.java:345)
       [aopc] at org.jboss.aop.standalone.Compiler.compile(Compiler.java:234)
       [aopc] at org.jboss.aop.standalone.Compiler.main(Compiler.java:90)
       [aopc] Caused by: javassist.NotFoundException: org.jboss.aspects.patterns.observable.SubjectImpl
       [aopc] at javassist.ClassPool.get(ClassPool.java:436)
       [aopc] at org.jboss.aop.instrument.Instrumentor.addMixin(Instrumentor.java:250)
       [aopc] at org.jboss.aop.instrument.Instrumentor.instrumentIntroductions(Instrumentor.java:375)
       [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:717)
       [aopc] ... 5 more
      BUILD FAILED


      Not sure why it can't find SubjectImpl. The distribution examples didn't have a problem (or didn't need it?) Anyway, since SubjectImpl is located in jboss-aspect-library-jdk50.jar, I modified aop.classpath to include that jar. Then I get:

      Buildfile: D:\Projects\cache\ejb\build.xml
      aopc:
       [aopc] [debug] Passed in instrumentor: null
       [aopc] [debug] Defaulting instrumentor to: org.jboss.aop.instrument.ClassicInstrumentor
       [aopc] [debug] jboss.aop.class.path: C:\jboss-4.2.2.GA\server\all\deploy\jboss-aop-jdk50.deployer\jboss-aop-jdk50.jar;C:\jboss-4.2.2.GA\server\all\deploy\jboss-aop-jdk50.deployer\jboss-aspect-library-jdk50.jar;C:\jboss-4.2.2.GA\server\all\lib\jboss-cache-jdk50.jar
      
       ... long list of "looking for aspects in...", including...
      
       [aopc] [debug] Looking for aspects in: org.jboss.aspects.patterns.observable.Subject
       [aopc] [debug] Looking for aspects in: org.jboss.aspects.patterns.observable.SubjectImpl
       [aopc] [debug] Looking for aspects in: org.jboss.aspects.patterns.observable.SubjectInterceptor
      
       ... ending with ...
      
       [aopc] [debug] Looking for aspects in: org.jboss.cache.aop.annotation.InstanceOfPojoCacheable
       [aopc] [debug] Looking for aspects in: org.jboss.cache.aop.annotation.NonTransient
       [aopc] [debug] Looking for aspects in: org.jboss.cache.aop.annotation.PojoCacheable
       [aopc] [debug] Looking for aspects in: org.jboss.cache.aop.annotation.Serializable
       [aopc] [debug] Looking for aspects in: org.jboss.cache.aop.annotation.Transient
       [aopc] [debug] jboss.aop.search.classpath: 'null' true
       [aopc] [deploying] file:/D:/Projects/cache/ejb/build/classes/META-INF/jboss-aop.xml
       [aopc] AspectXMLLoader using managerorg.jboss.aop.AspectManager@18e3e60
       [aopc] [debug] jboss.aop.path: D:\Projects\cache\ejb\ejbModule\META-INF\jboss-aop.xml
       [aopc] jboss.aop.path[0]: D:\Projects\cache\ejb\ejbModule\META-INF\jboss-aop.xml
       [aopc] [deploying] file:/D:/Projects/cache/ejb/ejbModule/META-INF/jboss-aop.xml
       [aopc] AspectXMLLoader using managerorg.jboss.aop.AspectManager@18e3e60
       [aopc] [trying to transform] test.cache.Address
       [aopc] [debug] There are no caller pointcuts!
       [aopc] [debug] javassist.CtMethod@d23b05a4[public setCity (Ljava/lang/String;)V] matches no pointcuts
       [aopc] [debug] javassist.CtMethod@140512a2[public getCity ()Ljava/lang/String;] matches no pointcuts
       [aopc] [debug] javassist.CtMethod@2e76bf69[public setZip (I)V] matches no pointcuts
       [aopc] [debug] javassist.CtMethod@75863e2c[public getZip ()I] matches no pointcuts
       [aopc] [debug] javassist.CtMethod@764fe7bc[public setStreet (Ljava/lang/String;)V] matches no pointcuts
       [aopc] [debug] javassist.CtMethod@e69b9dba[public getStreet ()Ljava/lang/String;] matches no pointcuts
       [aopc] [debug] javassist.CtMethod@ae73fc2d[public getSimpleAddress ()Ljava/lang/String;] matches no pointcuts
       [aopc] [debug] javassist.CtMethod@69cb6c6d[public toString ()Ljava/lang/String;] matches no pointcuts
       [aopc] [debug] javassist.CtConstructor@1f934ad[public Address ()V] matches no pointcuts
       [aopc] javassist.bytecode.DuplicateMemberException: duplicate field: _org$jboss$aspects$patterns$observable$SubjectImpl$aop$mixin
       [aopc] at javassist.bytecode.ClassFile.testExistingField(ClassFile.java:529)
       [aopc] at javassist.bytecode.ClassFile.addField(ClassFile.java:515)
       [aopc] at javassist.CtClassType.addField(CtClassType.java:1163)
       [aopc] at org.jboss.aop.instrument.Instrumentor.addMixin(Instrumentor.java:285)
       [aopc] at org.jboss.aop.instrument.Instrumentor.instrumentIntroductions(Instrumentor.java:375)
       [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:717)
       [aopc] at org.jboss.aop.AspectManager.translate(AspectManager.java:910)
       [aopc] at org.jboss.aop.AspectManager.transform(AspectManager.java:822)
       [aopc] at org.jboss.aop.standalone.Compiler.compileFile(Compiler.java:345)
       [aopc] at org.jboss.aop.standalone.Compiler.compile(Compiler.java:234)
       [aopc] at org.jboss.aop.standalone.Compiler.main(Compiler.java:90)
       [aopc] java.lang.RuntimeException: failed to transform: test.cache.Address
       [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:777)
       [aopc] at org.jboss.aop.AspectManager.translate(AspectManager.java:910)
       [aopc] at org.jboss.aop.AspectManager.transform(AspectManager.java:822)
       [aopc] at org.jboss.aop.standalone.Compiler.compileFile(Compiler.java:345)
       [aopc] at org.jboss.aop.standalone.Compiler.compile(Compiler.java:234)
       [aopc] at org.jboss.aop.standalone.Compiler.main(Compiler.java:90)
       [aopc] Caused by: javassist.bytecode.DuplicateMemberException: duplicate field: _org$jboss$aspects$patterns$observable$SubjectImpl$aop$mixin
       [aopc] at javassist.bytecode.ClassFile.testExistingField(ClassFile.java:529)
       [aopc] at javassist.bytecode.ClassFile.addField(ClassFile.java:515)
       [aopc] at javassist.CtClassType.addField(CtClassType.java:1163)
       [aopc] at org.jboss.aop.instrument.Instrumentor.addMixin(Instrumentor.java:285)
       [aopc] at org.jboss.aop.instrument.Instrumentor.instrumentIntroductions(Instrumentor.java:375)
       [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:717)
       [aopc] ... 5 more
       [aopc] Exception in thread "main" java.lang.RuntimeException: failed to transform: test.cache.Address
       [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:777)
       [aopc] at org.jboss.aop.AspectManager.translate(AspectManager.java:910)
       [aopc] at org.jboss.aop.AspectManager.transform(AspectManager.java:822)
       [aopc] at org.jboss.aop.standalone.Compiler.compileFile(Compiler.java:345)
       [aopc] at org.jboss.aop.standalone.Compiler.compile(Compiler.java:234)
       [aopc] at org.jboss.aop.standalone.Compiler.main(Compiler.java:90)
       [aopc] Caused by: javassist.bytecode.DuplicateMemberException: duplicate field: _org$jboss$aspects$patterns$observable$SubjectImpl$aop$mixin
       [aopc] at javassist.bytecode.ClassFile.testExistingField(ClassFile.java:529)
       [aopc] at javassist.bytecode.ClassFile.addField(ClassFile.java:515)
       [aopc] at javassist.CtClassType.addField(CtClassType.java:1163)
       [aopc] at org.jboss.aop.instrument.Instrumentor.addMixin(Instrumentor.java:285)
       [aopc] at org.jboss.aop.instrument.Instrumentor.instrumentIntroductions(Instrumentor.java:375)
       [aopc] at org.jboss.aop.instrument.Instrumentor.transform(Instrumentor.java:717)
       [aopc] ... 5 more
      BUILD FAILED


      There must be something (probably very simple) I'm missing. Can anybody see it?




        • 1. Re: aopc error: DuplicateMemberException: duplicate field
          ironbeard Newbie

          Just a clarification:

          Not sure why it can't find SubjectImpl. The distribution examples didn't have a problem (or didn't need it?) Anyway, since SubjectImpl is located in jboss-aspect-library-jdk50.jar, I modified aop.classpath to include that jar....


          Actually, I do know why aopc can't find SubjectImpl -- because it was not in the classpath. That's why I added the aspect-library jar. Clearly in the second aopc run, it found that class.

          What I don't understand is: 1) Why aopc didn't complain about not finding SubjectImpl when Address was compiled as part of the annotation50 set in the jboss-cache distribution examples (which do not reference aspect-library.jar). And 2) why aopc generates the duplicate field error when it does find SubjectImpl.


          • 2. Re: aopc error: DuplicateMemberException: duplicate field
            ironbeard Newbie

            Figured it out. Turns out the jboss-aop.xml file was accessible via the classpath supplied to aopc. I changed the classpath spec so that that directory was not included and aopc ran fine.

            No idea having jboss-aop.xml in the classpath is a problem (and there's nothing in the aop, pojocache or jbosscache documentation to indicate that is would be) but evidently it is.

            Anyway. Maybe this note will prevent someone else from wasting a couple days on a stupid problem.