18 Replies Latest reply: Nov 25, 2010 5:31 AM by Arnoud Bos RSS

    i feel stupid :)

    Arnoud Bos Community Member

      Hi all,

       

      i'm trying to integrate pmd in our build with ant but get the following rror:

       

      [flexPmd] net.sourceforge.pmd.RuleSetNotFoundException: Can't find resource com/adobe/ac/pmd/rulesets/architecture.xml. Make sure the resource is a valid file or URL or is on the CLASSPATH

        [flexPmd] at net.sourceforge.pmd.util.ResourceLoader.loadResourceAsStream(ResourceLoader.java:28)

        [flexPmd] at net.sourceforge.pmd.RuleSetFactory.parseRuleSetReferenceNode(RuleSetFactory.java:284)

        [flexPmd] at net.sourceforge.pmd.RuleSetFactory.parseRuleNode(RuleSetFactory.java:251)

        [flexPmd] at net.sourceforge.pmd.RuleSetFactory.parseRuleSetNode(RuleSetFactory.java:209)

        [flexPmd] at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:157)

        [flexPmd] at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:146)

        [flexPmd] at com.adobe.ac.pmd.engines.AbstractFlexPmdEngine.loadRuleset(AbstractFlexPmdEngine.java:184 )

        [flexPmd] at com.adobe.ac.pmd.engines.AbstractFlexPmdEngine.<init>(AbstractFlexPmdEngine.java:100)

      I set it up like on the doc page and if i echo the task with filled in paths i get the right ones:
      Buildfile: build.xml
           [echo]
           [echo]
           [echo] <taskdef name="flexPmd"
           [echo] classname="com.adobe.ac.pmd.ant.FlexPmdAntTask"
           [echo] classpath="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/flex-pmd-ant -task-1.0.jar">
           [echo] <classpath>
           [echo] <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/as3-parser-1 .0.jar"/>
           [echo] <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/as3-parser-a pi-1.0.jar"/>
           [echo] <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/as3-plugin-u tils-1.0.jar"/>
           [echo] <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/commons-lang -2.4.jar"/>
           [echo] <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/flex-pmd-cor e-1.0.jar"/>
           [echo] <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/flex-pmd-fil es-1.0.jar"/>
           [echo] <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/flex-pmd-rul eset-1.0.jar"/>
           [echo] <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/flex-pmd-rul eset-api-1.0.jar"/>
           [echo] <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/plexus-utils -1.0.2.jar"/>
           [echo] <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/pmd-4.2.5.ja r"/>
           [echo] </classpath>
           [echo] </taskdef>
           [echo]
           [echo]
      i call the task without a ruleset so it should use the default one, right?

      <flexPmd sourceDirectory="${src.flex.dir}" outputDirectory="${build.pmd.dir}" />

       

      any thoughts? No one but me seems to have trouble to get the thing to work ....

      i use the latest version 1.0 from the adobe opensource site

       

      any help would be highly appreciated!

       

      Arnoud

       

       

       

       

        • 1. Re: i feel stupid :)
          Xavier Agnetti Adobe Employee

          Ok. Your error means that your flex-pmd-ruleset-1.0-jar is not foud.

          You need to make sure that this file is in the class-path.

           

          Xavier

          • 2. Re: i feel stupid :)
            Arnoud Bos Community Member

            Hi thanx for the fast reply.

             

            Does that mean that including the jars in the taskdef of flexPmdAntTask is not sufficient? Now i have:

             

            <taskdef name="flexPmd"
                classname="com.adobe.ac.pmd.ant.FlexPmdAntTask"
                classpath="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/flex-pmd-an t-task-1.0.jar">
                <classpath>
                     <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/as3-parser-1 .0.jar"/>
                     <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/as3-parser-a pi-1.0.jar"/>
                     <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/as3-plugin-u tils-1.0.jar"/>
                     <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/commons-lang -2.4.jar"/>
                     <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/flex-pmd-cor e-1.0.jar"/>
                     <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/flex-pmd-fil es-1.0.jar"/>
                     <pathelement location="/Users/arnoudbos/Desktop/AgileFlex2/_build/taskdef-lib/flexpmd/1.0/flex-pmd-rul eset-1.0.jar"/>
            etc...
            i verified the paths, if i have to include the .jars in the classpath in another way i wonder why they should be included like above?
            any further insights?
            Thanx
            Arnoud

            • 3. Re: i feel stupid :)
              clotton Community Member

              Did you ever get this to work?

               

              I'm having the EXACT same problem, and I've verified that my paths are correct, file names are correct, etc.  I just can't figure out why it's not picking up the ruleset jar, when it's clearly there.

               

              Any ideas?

              • 4. Re: i feel stupid :)
                xavi.beumala Community Member

                Hi,

                 

                could you try using this newer build http://www.rialvalue.com/flexPmd/updateSite/

                 

                We´ll release this version early next week. this problems should be fixed there

                 

                Xavi    

                • 5. Re: i feel stupid :)
                  Arnoud Bos Community Member

                  No, i'm afraid i couldn't get it working.

                  But glad to hear it's fixed in the next release. It was driving me mad for a whle :-)

                   

                  we switched to maven and that's working well.

                   

                  Anyway great to hear a new version is coming up.

                  FlexPMD is great! Also sonar flex (build on top of flex pmd) looks really promising!

                   

                  Arnoud

                  • 6. Re: i feel stupid :)
                    clotton Community Member

                    Thank you for the link, but I'm afraid it doesn't contain a build.  Only a jar with one xml file in it. 

                     

                    Do older versions of flex pmd work?

                     

                    Thanks

                     

                    Chris

                    • 7. Re: i feel stupid :)
                      xavi.beumala Community Member

                      Hi,

                       

                      it's not a build, it's an update site for the eclipse plugin. I think I've missed read your thread though thinking you had a problem with the eclipse plugin and the project paths

                      • 8. Re: i feel stupid :)
                        clotton Community Member

                        No, the issue is with the ant task, not the eclipse plugin.

                         

                        Thanks

                        • 9. Re: i feel stupid :)
                          Xavier Agnetti Adobe Employee

                          Did you add the ruleset jar to the ant task classpath?

                           

                          That's all you should need to do.

                           

                          Xavier

                          • 10. Re: i feel stupid :)
                            Arnoud Bos Community Member

                            Just to confirm,

                             

                            for me it was the ant task too that didn't work.

                             

                            Arnoud

                            • 11. Re: i feel stupid :)
                              clotton Community Member

                              Yes, and confirmed its path and spelling is valid.  Like Arnoud, I've used the example ant task provided.

                              • 12. Re: i feel stupid :)
                                Arnoud Bos Community Member

                                I think it would greatly help to state if the taskdef in the post http://forums.adobe.com/message/2458304#2458304

                                is correct.

                                 

                                See the last pathelement, that should suffice, right?

                                do you need to do more?

                                 

                                maybe it's fixed in subsequent releases which i didn't try with ant

                                 

                                Arnoud

                                • 13. Re: i feel stupid :)
                                  clotton Community Member

                                  FYI, I've tried version 1.2, 1.1, and 1.0 with the same result:

                                   

                                  net.sourceforge.pmd.RuleSetNotFoundException: Can't find resource com/adobe/ac/pmd/rulesets/architecture.xml. Make sure the resource is a valid file or URL or is on the CLASSPATH

                                         at net.sourceforge.pmd.util.ResourceLoader.loadResourceAsStream(ResourceLoader.java:28)

                                         at net.sourceforge.pmd.RuleSetFactory.parseRuleNodeWithExclude(RuleSetFactory.java:385)

                                         at net.sourceforge.pmd.RuleSetFactory.parseExternallyDefinedRuleNode(RuleSetFactory.java:331 )

                                         at net.sourceforge.pmd.RuleSetFactory.parseRuleNode(RuleSetFactory.java:263)

                                         at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:199)

                                         at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:172)

                                         at com.adobe.ac.pmd.engines.AbstractFlexPmdEngine.loadRuleset(AbstractFlexPmdEngine.java:181 )

                                         at com.adobe.ac.pmd.engines.AbstractFlexPmdEngine.(AbstractFlexPmdEngine.java:100)

                                         at com.adobe.ac.pmd.engines.FlexPmdXmlEngine.(FlexPmdXmlEngine.java:58)

                                         at com.adobe.ac.pmd.ant.FlexPmdAntTask.execute(FlexPmdAntTask.java:58)

                                         at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)

                                         at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)

                                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                                         at java.lang.reflect.Method.invoke(Method.java:585)

                                         at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)

                                         at org.apache.tools.ant.Task.perform(Task.java:348)

                                         at org.apache.tools.ant.Target.execute(Target.java:357)

                                         at org.apache.tools.ant.Target.performTasks(Target.java:385)

                                         at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)

                                         at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:3 8)

                                         at org.eclipse.ant.internal.launching.remote.EclipseSingleCheckExecutor.executeTargets(Eclip seSingleCheckExecutor.java:30)

                                         at org.apache.tools.ant.Project.executeTargets(Project.java:1181)

                                         at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)

                                         at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)

                                         at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)

                                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                                         at java.lang.reflect.Method.invoke(Method.java:585)

                                         at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)

                                         at org.apache.tools.ant.Task.perform(Task.java:348)

                                         at org.apache.tools.ant.Target.execute(Target.java:357)

                                         at org.apache.tools.ant.Target.performTasks(Target.java:385)

                                         at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)

                                         at org.apache.tools.ant.Project.executeTarget(Project.java:1298)

                                         at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)

                                         at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDe faultExecutor.java:32)

                                         at org.apache.tools.ant.Project.executeTargets(Project.java:1181)

                                         at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:42 3)

                                         at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:1 37)

                                  • 14. Re: i feel stupid :)
                                    clotton Community Member

                                    Just curious if anybody has actually used the example ant task/target successfully?  I've seen plenty of blogs and tutorials online, but they all seem to just copy/paste the example ant target provided by Adobe, which leads me to believe they probably haven't used the target.  If you have a successfully running flex pmd ant target, could you post it?

                                     

                                    Thanks

                                    • 15. Re: i feel stupid :)
                                      clotton Community Member

                                      I just got it to work by switching to Ant 1.8.

                                      • 16. Re: i feel stupid :)
                                        clintmodien Community Member

                                        Doesn't answer your question but I actually just run the jar file from a macrodef... 

                                         

                                              

                                                       <java jar="${flexpmd.dir}/flex-pmd-command-line-${flexpmd.version}.jar"

                                                                 fork="true" failonerror="true" outputproperty="@">

                                                            <arg value="-s@"/>

                                                            <arg value="-o@"/>

                                                            <arg value="-r@"/>

                                                             

                                                  <mkdir dir="$/reports/flexpmd" />           <flexPmd                sourceDirectory="$/src"

                                                       outputDirectory="$/reports/flexpmd"

                                                       ruleSet="${flexpmd.dir}/rulesets/pmd.xml"

                                                       outputProperty="flexpmd.out"/>

                                                   

                                             </target

                                        • 17. Re: i feel stupid :)
                                          clotton Community Member

                                          We resolved the issue.

                                           

                                          It seems the Ant 1.7 supplied to us contained an old pmd-4.1.jar in the lib directory.   Removing that jar solves the problem.  This jar wasn't present in the supplied Ant 1.8, which is why that version worked.

                                          • 18. Re: i feel stupid :)
                                            Arnoud Bos Community Member

                                            I can confirm this. Problem is gone in a clean ant 1.8.1 installation

                                             

                                            cheers,

                                             

                                            Arnoud