#1069 Eclipse plugin does not accept project-local config

PMD-5.0.5
closed
None
PMD
3-Major
Bug
4.0.0.201211080927
2014-03-31
2013-03-05
Ralf
No

We have configured the PMD eclipse plugin to use a ruleset file local to our project. See attached .pmd from one of our projects.

This did not work.

Workaround: Remove all rules in the workspace preferences and import the project-local ruleset there.

Environment: Eclipse Indigo SR 2 running on SUSE Linux Enterprise Server 11 (x86_64)

1 Attachments

Related

Issues: #1069

Discussion

1 2 > >> (Page 1 of 2)
  • Andreas Dangel
    Andreas Dangel
    2013-03-05

    • module: PMD --> Eclipse
     
  • john
    john
    2013-03-08

    I am seeing this with Eclipse SDK

    Version: 4.2.1
    Build id: M20120914-1800

    PMD Plug-in 4.0.0.201211080927 net.sourceforge.pmd.eclipse.feature.group

     
  • john
    john
    2013-03-13

    Here's the exception I see in the eclipse log:

    Message:


    Project RuleSet cannot be loaded for project fsw-core using RuleSet file name .ruleset. Using the rules from properties.Can't find resource rulesets//home/myusername/git/myusername/parentProject/projectName.xml. Make sure the resource is a valid file or URL or is on the CLASSPATH. Here's the current classpath: /usr/lib/eclipse//plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar

    Exception Stack:


    net.sourceforge.pmd.RuleSetNotFoundException: Can't find resource rulesets//home/myusername/git/myusername/parentProject/projectName.xml. Make sure the resource is a valid file or URL or is on the CLASSPATH. Here's the current classpath: /usr/lib/eclipse//plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
    at net.sourceforge.pmd.RuleSetReferenceId.getInputStream(RuleSetReferenceId.java:254)
    at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:161)
    at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java:126)
    at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java:111)
    at net.sourceforge.pmd.eclipse.runtime.properties.impl.ProjectPropertiesManagerImpl.loadRuleSetFromProject(ProjectPropertiesManagerImpl.java:155)
    at net.sourceforge.pmd.eclipse.runtime.properties.impl.ProjectPropertiesManagerImpl.loadProjectProperties(ProjectPropertiesManagerImpl.java:108)
    at net.sourceforge.pmd.eclipse.plugin.PMDPlugin.loadProjectProperties(PMDPlugin.java:356)
    at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.rulesetFromResourceDelta(ReviewCodeCmd.java:466)
    at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.processResourceDelta(ReviewCodeCmd.java:480)
    at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.execute(ReviewCodeCmd.java:185)
    at net.sourceforge.pmd.eclipse.runtime.cmd.JobCommandProcessor$1.run(JobCommandProcessor.java:85)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

     
  • Steven Swor
    Steven Swor
    2013-04-12

    I have a similar issue with PMD plugin version 4.0.0.201211080927 in Eclipse Juno SR 2. In my case, the file is named .pmd_ruleset and is located in the project's root folder. Here is my stack trace:

    net.sourceforge.pmd.RuleSetNotFoundException: Can't find resource /path/to/project. Make sure the resource is a valid file or URL or is on the CLASSPATH
    at net.sourceforge.pmd.util.ResourceLoader.loadResourceAsStream(ResourceLoader.java:64)
    at net.sourceforge.pmd.RuleSetReferenceId.getInputStream(RuleSetReferenceId.java:251)
    at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:161)
    at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java:126)
    at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java:111)
    at net.sourceforge.pmd.eclipse.runtime.properties.impl.ProjectPropertiesManagerImpl.loadRuleSetFromProject(ProjectPropertiesManagerImpl.java:155)
    at net.sourceforge.pmd.eclipse.runtime.properties.impl.ProjectPropertiesManagerImpl.loadProjectProperties(ProjectPropertiesManagerImpl.java:108)
    at net.sourceforge.pmd.eclipse.plugin.PMDPlugin.loadProjectProperties(PMDPlugin.java:356)
    at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.rulesetFromResourceDelta(ReviewCodeCmd.java:466)
    at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.processResourceDelta(ReviewCodeCmd.java:480)
    at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.execute(ReviewCodeCmd.java:185)
    at net.sourceforge.pmd.eclipse.runtime.cmd.JobCommandProcessor$1.run(JobCommandProcessor.java:85)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
    

    Judging from the error message, it appears something is balking at the . in the file name, but I'm not sure. The /path/to/project is correct and should not have any issues with file permissions (I've chowned everything to my user and added full permissions to that file). There are no spaces or special characters in the file path (except for the leading . in the file name)

     
  • Thomas Leplus
    Thomas Leplus
    2013-06-26

    Same here.

    Message:
    Project RuleSet cannot be loaded for project trax using RuleSet file name .ruleset. Using the rules from properties.Can't find resource C:\workspace\project. Make sure the resource is a valid file or URL or is on the CLASSPATH

    Exception:
    net.sourceforge.pmd.RuleSetNotFoundException: Can't find resource C:\workspace\project. Make sure the resource is a valid file or URL or is on the CLASSPATH
    at net.sourceforge.pmd.util.ResourceLoader.loadResourceAsStream(ResourceLoader.java:64)
    at net.sourceforge.pmd.RuleSetReferenceId.getInputStream(RuleSetReferenceId.java:251)
    at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:161)
    at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java:126)
    at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java:111)
    at net.sourceforge.pmd.eclipse.runtime.properties.impl.ProjectPropertiesManagerImpl.loadRuleSetFromProject(ProjectPropertiesManagerImpl.java:155)
    at net.sourceforge.pmd.eclipse.runtime.properties.impl.ProjectPropertiesManagerImpl.loadProjectProperties(ProjectPropertiesManagerImpl.java:108)
    at net.sourceforge.pmd.eclipse.plugin.PMDPlugin.loadProjectProperties(PMDPlugin.java:360)
    at net.sourceforge.pmd.eclipse.runtime.cmd.AbstractProjectCommand.projectProperties(AbstractProjectCommand.java:62)
    at net.sourceforge.pmd.eclipse.ui.properties.UpdateProjectPropertiesCmd.execute(UpdateProjectPropertiesCmd.java:84)
    at name.herlin.command.DefaultCommandProcessor.processCommand(DefaultCommandProcessor.java:47)
    at name.herlin.command.AbstractProcessableCommand.performExecute(AbstractProcessableCommand.java:62)
    at net.sourceforge.pmd.eclipse.ui.properties.PMDPropertyPageController.performOk(PMDPropertyPageController.java:161)
    at net.sourceforge.pmd.eclipse.ui.properties.PMDProjectPropertyPage.performOk(PMDProjectPropertyPage.java:554)
    at org.eclipse.jface.preference.PreferenceDialog$13.run(PreferenceDialog.java:965)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
    at org.eclipse.jface.preference.PreferenceDialog.okPressed(PreferenceDialog.java:945)
    at org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.okPressed(FilteredPreferenceDialog.java:448)
    at org.eclipse.jface.preference.PreferenceDialog.buttonPressed(PreferenceDialog.java:233)
    at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
    at org.eclipse.jface.window.Window.open(Window.java:801)
    at org.eclipse.ui.dialogs.PropertyDialogAction.run(PropertyDialogAction.java:158)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1438)

    Session Data:
    eclipse.buildId=M20130204-1200
    java.version=1.6.0_34
    java.vendor=Sun Microsystems Inc.
    BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
    Framework arguments: -product org.eclipse.epp.package.jee.product
    Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

     
  • Ian Brandt
    Ian Brandt
    2013-07-31

    This worked fine for me in Indigo with 3.2.6.v200903300643. I'm trying to upgrade to Kepler with 4.0.0.v20130510-1000, and am seeing the same issue as everyone else.

     
  • Andreas Dangel
    Andreas Dangel
    2013-08-05

    Hi, could you post me, exactly how the project-local ruleset file is called in your projects? E.g.

    • Is it an absolute path name or a relative path name?
    • What is the file extension of the ruleset file?
    • Does the path name contain a dash ("-")?

    We use there some tricky logic to make ruleset names like "java-basic" working :) And maybe we rewrite your original pathname to something, that simply doesn't work (like adding "releases/" as the prefix and adding ".xml" at the end...).

    Can you try, whether it works, if you rename your file to have a ".xml" extension? Because, if it ends with ".xml", then we bypass the logic...

    Thanks,
    Andreas

     
  • Ralf
    Ralf
    2013-08-06

    Hello Andreas

    I'm on vacation currently and left my laptop at home.

    Lets see...

    the rule file is pmd/pmd-ruleset.xml. So there we have a '-' in the filename. (see file .pmd attached to the bug report)

    I just remember that this directory is created while importing a maven project. From the eclipse point of view the file is available as stated above. Not sure if it is so on the filesystem. Have to check when I'm back home (14 days).

    Regards
    Ralf

    --
    Diese Nachricht wurde von mir gesendet.

    Andreas Dangel adangel@users.sf.net schrieb:

    Hi, could you post me, exactly how the project-local ruleset file is called in your projects? E.g.

    Is it an absolute path name or a relative path name?What is the file extension of the ruleset file?Does the path name contain a dash ("-")?

    We use there some tricky logic to make ruleset names like "java-basic" working :) And maybe we rewrite your original pathname to something, that simply doesn't work (like adding "releases/" as the prefix and adding ".xml" at the end...).

    Can you try, whether it works, if you rename your file to have a ".xml" extension? Because, if it ends with ".xml", then we bypass the logic...

    Thanks,
    Andreas


    [bugs:#1069] Eclipse plugin does not accept project-local config

    Status: open
    Created: Tue Mar 05, 2013 11:47 AM UTC by Ralf
    Last Updated: Wed Jul 31, 2013 07:19 PM UTC
    Owner: nobody

    We have configured the PMD eclipse plugin to use a ruleset file local to our project. See attached .pmd from one of our projects.

    This did not work.

    Workaround: Remove all rules in the workspace preferences and import the project-local ruleset there.

    Environment: Eclipse Indigo SR 2 running on SUSE Linux Enterprise Server 11 (x86_64)


    Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/pmd/bugs/1069/

    To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

     

    Related

    Issues: #1069

    • Andreas Dangel
      Andreas Dangel
      2013-08-06

      Hi Ralf,

      thanks for the answer. However, I guess, you have another problem.
      In the original description, you mention to delete all rules in the workspace preferences and then importing your special ruleset.
      I know that the behavior of the plugin is a little bit surprising in this area: with the workspace preferences you can activate/deactivate rules globally for all projects. So, if the rules are deactivated in the workspace preferences, then they will never be executed, even if the project itself has them activated.
      By the way, does your ruleset contain custom rules or does it just reuse the standard PMD rules? If you have custom rules, it might be necessary to do it as you have described it in the workaround.

      For the others, who have posted the stacktrace, I probably found a bugfix, that is backwards compatible and I hope to have it included in the next release.

      Thanks,
      Andreas

       
  • Andreas Dangel
    Andreas Dangel
    2013-08-07

    • status: open --> in-progress
    • assigned_to: Andreas Dangel
     
1 2 > >> (Page 1 of 2)