Skip to content
This repository has been archived by the owner on Sep 23, 2023. It is now read-only.

Eclipse Luna throws Error: Plug-in "ch.acanda.eclipse.pmd.core" was unable to instantiate class "ch.acanda.eclipse.pmd.builder.PMDBuilder". #20

Closed
PrabakaranSK opened this issue Jan 7, 2015 · 17 comments
Assignees
Labels

Comments

@PrabakaranSK
Copy link

Using Eclipse Marketplace, the "eclipse-pmd" plugin is installed.

The PMD is activated in a project however it throws an exception like below:

Message:
Plug-in "ch.acanda.eclipse.pmd.core" was unable to instantiate class "ch.acanda.eclipse.pmd.builder.PMDBuilder".

Exception Stack Trace:
java.lang.NoClassDefFoundError: Could not initialize class ch.acanda.eclipse.pmd.builder.PMDBuilder
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at java.lang.Class.newInstance0(Class.java:372)
    at java.lang.Class.newInstance(Class.java:325)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:184)
    at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
    at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
    at org.eclipse.core.internal.events.BuildManager.instantiateBuilder(BuildManager.java:907)
    at org.eclipse.core.internal.events.BuildManager.initializeBuilder(BuildManager.java:860)
    at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:545)
    at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:574)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:244)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:299)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
@acanda acanda self-assigned this Jan 7, 2015
@acanda acanda added the bug label Jan 7, 2015
@acanda
Copy link
Owner

acanda commented Jan 7, 2015

I tried to reproduce this issue but was unsuccessful so far. You could help me identify the cause by telling me which Eclipse version and Java runtime version you are using and on which OS your are running Eclipse.

Please open the dialog "Eclipse Installation Details": Help (menu) > About Eclipse (menu) > Installation Details (button) > Configuration (tab). Then search the following system properties and let me know their values:

  • eclipse.buildId
  • java.vendor
  • java.version
  • os.name
  • os.version
  • os.arch

In the mean time you could also just try and uninstall the plug-in and then install it again.This would solve the problem if there was anything going wrong during the installation.

@LarsWH
Copy link

LarsWH commented Jan 12, 2015

I am seeing something similar on my installation:

  • Eclipse: Kepler Service Release 2 Build id: 20140224-0627
  • Eclipse PMD Plug-in: 1.4.0.201412211449

Problem is reported in a dialogue box during Eclipse initialisation: Problem Occured: 'Building workspace' has encountered a problem. Errors occured during the build. Error instantiating builder 'ch.acanda.eclipse.pmd.builder.PMDBuilder'. Plug-in "ch.acanda.eclipse.pmd.core" was unable to instantiate class "ch.acanda.eclipse.pmd.builder.PMDBuilder". java.lang.ExceptionInInitializerError
Plug-in "ch.acanda.eclipse.pmd.core" was unable to instantiate class "ch.acanda.eclipse.pmd.builder.PMDBuilder". java.lang.ExceptionInInitializerError

Configuration:

  • eclipse.buildId=4.3.2.M20140221-1700
  • java.vendor=Oracle Corporation
  • java.version=1.7.0_60
  • os.name=Windows 7
  • os.version=6.1
  • osgi.arch=x86_64

...and:

  • ch.acanda.eclipse.pmd.core (1.4.0.201412211449) "eclipse-pmd Core" [Active]
  • ch.acanda.eclipse.pmd.java (1.4.0.201412211449) "eclipse-pmd Java" [Resolved]
  • ch.acanda.eclipse.pmd.lib (1.4.0.201412211449) "eclipse-pmd Third Party Libraries" [Resolved]
  • ch.acanda.eclipse.pmd.unsupported (1.4.0.201412211449) "eclipse-pmd Unsupported JRE" [Resolved]

@acanda
Copy link
Owner

acanda commented Jan 12, 2015

@LarsWH do you happen to have the stack trace of that ExceptionInInitializerError that is thrown during the Eclipse initialization?

@LarsWH
Copy link

LarsWH commented Jan 13, 2015

The log file is attached below (not sure how get a stack trace). FYI: if I replace "Eclipse PMD 1.4" (Market place) with "PMD Eclipse" (http://sourceforge.net/projects/pmd/files/pmd-eclipse/update-site/) the problem goes away. This could perhaps be caused by the fact that the name space indicated within my pmd.xml file is xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"?

!SESSION 2015-01-13 11:41:16.768 -----------------------------------------------
eclipse.buildId=4.3.2.M20140221-1700
java.version=1.7.0_60
java.vendor=Oracle Corporation
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

!ENTRY org.eclipse.ui 4 4 2015-01-13 11:41:19.872
!MESSAGE Unable to find Action Set: externaltools.actionSet

!ENTRY org.apache.ivyde.eclipse 1 0 2015-01-13 11:41:21.035
!MESSAGE starting IvyDE plugin

!ENTRY org.apache.ivyde.eclipse 1 0 2015-01-13 11:41:21.046
!MESSAGE IvyDE plugin started

!ENTRY org.eclipse.egit.ui 2 0 2015-01-13 11:41:28.529
!MESSAGE Warning: EGit couldn't detect the installation path "gitPrefix" of native Git. Hence EGit can't respect system level
Git settings which might be configured in ${gitPrefix}/etc/gitconfig under the native Git installation directory.
The most important of these settings is core.autocrlf. Git for Windows by default sets this parameter to true in
this system level configuration. The Git installation location can be configured on the
Team > Git > Configuration preference page's 'System Settings' tab.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.

!ENTRY org.eclipse.egit.ui 2 0 2015-01-13 11:41:28.530
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\lwh'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.

!ENTRY org.eclipse.jface 2 0 2015-01-13 11:41:30.239
!MESSAGE Keybinding conflicts occurred.  They may interfere with normal accelerator operation.
!SUBENTRY 1 org.eclipse.jface 2 0 2015-01-13 11:41:30.239
!MESSAGE A conflict occurred for SHIFT+DEL:
Binding(SHIFT+DEL,
    ParameterizedCommand(Command(org.eclipse.datatools.sqltools.result.removeAllInstances,Remove All Visible Results,
        ,
        Category(org.eclipse.datatools.sqltools.result.category,SQL Results View,null,true),
        org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@438abade,
        ,,true),null),
    org.eclipse.ui.defaultAcceleratorConfiguration,
    org.eclipse.ui.contexts.window,,,system)
Binding(SHIFT+DEL,
    ParameterizedCommand(Command(org.eclipse.ui.edit.cut,Cut,
        Cut the selection to the clipboard,
        Category(org.eclipse.ui.category.edit,Edit,null,true),
        org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@2953cdfe,
        ,,true),null),
    org.eclipse.ui.defaultAcceleratorConfiguration,
    org.eclipse.ui.contexts.dialogAndWindow,,,system)
Binding(SHIFT+DEL,
    ParameterizedCommand(Command(MoreClipboard.commands.moreCut,Transparent Cut via MoreClipboard,
        Cut the selection to the clipboard and register it in the MoreClipboard's history,
        Category(org.eclipse.ui.category.edit,Edit,null,true),
        org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@48f26776,
        ,,true),null),
    org.eclipse.ui.defaultAcceleratorConfiguration,
    MoreClipboard.contexts.main,,,system)

!ENTRY org.eclipse.core.resources 4 75 2015-01-13 11:41:30.350
!MESSAGE Errors occurred during the build.
!SUBENTRY 1 org.eclipse.core.resources 4 75 2015-01-13 11:41:30.350
!MESSAGE Error instantiating builder 'ch.acanda.eclipse.pmd.builder.PMDBuilder'.
!STACK 1
org.eclipse.core.runtime.CoreException: Plug-in "ch.acanda.eclipse.pmd.core" was unable to instantiate class "ch.acanda.eclipse.pmd.builder.PMDBuilder".
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:194)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:188)
    at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
    at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
    at org.eclipse.core.internal.events.BuildManager.instantiateBuilder(BuildManager.java:906)
    at org.eclipse.core.internal.events.BuildManager.initializeBuilder(BuildManager.java:859)
    at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:545)
    at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:574)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:244)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:299)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.lang.ExceptionInInitializerError
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:184)
    ... 16 more
Caused by: java.lang.NullPointerException
    at java.nio.file.Paths.get(Unknown Source)
    at ch.acanda.eclipse.pmd.builder.LocationResolver.resolve(LocationResolver.java:38)
    at ch.acanda.eclipse.pmd.cache.RuleSetsCache.startWatchingRuleSetFiles(RuleSetsCache.java:85)
    at ch.acanda.eclipse.pmd.cache.RuleSetsCache.<init>(RuleSetsCache.java:74)
    at ch.acanda.eclipse.pmd.builder.PMDBuilder.<clinit>(PMDBuilder.java:41)
    ... 22 more
!SUBENTRY 2 org.eclipse.equinox.registry 4 1 2015-01-13 11:41:30.352
!MESSAGE Plug-in "ch.acanda.eclipse.pmd.core" was unable to instantiate class "ch.acanda.eclipse.pmd.builder.PMDBuilder".
!STACK 0
java.lang.ExceptionInInitializerError
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:184)
    at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
    at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
    at org.eclipse.core.internal.events.BuildManager.instantiateBuilder(BuildManager.java:906)
    at org.eclipse.core.internal.events.BuildManager.initializeBuilder(BuildManager.java:859)
    at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:545)
    at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:574)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:244)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:299)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.lang.NullPointerException
    at java.nio.file.Paths.get(Unknown Source)
    at ch.acanda.eclipse.pmd.builder.LocationResolver.resolve(LocationResolver.java:38)
    at ch.acanda.eclipse.pmd.cache.RuleSetsCache.startWatchingRuleSetFiles(RuleSetsCache.java:85)
    at ch.acanda.eclipse.pmd.cache.RuleSetsCache.<init>(RuleSetsCache.java:74)
    at ch.acanda.eclipse.pmd.builder.PMDBuilder.<clinit>(PMDBuilder.java:41)
    ... 22 more
!SUBENTRY 1 org.eclipse.equinox.registry 4 1 2015-01-13 11:41:30.352
!MESSAGE Plug-in "ch.acanda.eclipse.pmd.core" was unable to instantiate class "ch.acanda.eclipse.pmd.builder.PMDBuilder".
!STACK 0
java.lang.ExceptionInInitializerError
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:184)
    at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
    at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
    at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
    at org.eclipse.core.internal.events.BuildManager.instantiateBuilder(BuildManager.java:906)
    at org.eclipse.core.internal.events.BuildManager.initializeBuilder(BuildManager.java:859)
    at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:545)
    at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:574)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:244)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:299)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.lang.NullPointerException
    at java.nio.file.Paths.get(Unknown Source)
    at ch.acanda.eclipse.pmd.builder.LocationResolver.resolve(LocationResolver.java:38)
    at ch.acanda.eclipse.pmd.cache.RuleSetsCache.startWatchingRuleSetFiles(RuleSetsCache.java:85)
    at ch.acanda.eclipse.pmd.cache.RuleSetsCache.<init>(RuleSetsCache.java:74)
    at ch.acanda.eclipse.pmd.builder.PMDBuilder.<clinit>(PMDBuilder.java:41)
    ... 22 more

@acanda
Copy link
Owner

acanda commented Jan 13, 2015

@LarsWH Thank you, this helps a lot! Now I know where to look for the problem.

"PMD Eclipse" from sourceforge.net doesn't have this issue because it is an entirely different PMD plugin.

The xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" in your pmd.xml is correct and should not be the problem causing this issue.

@PrabakaranSK
Copy link
Author

Eclipse:
Version: Luna Service Release 1 (4.4.1)
Build id: 20140925-1800

Java runtime version: JDK 1.7.0
OS: Windows 7 64 bit

eclipse.buildId=4.4.1.M20140925-0400
java.vendor=Oracle Corporation
java.version=1.7.0
os.name=Windows 7
os.version=6.1
os.arch=amd64

Tried uninstalling and reinstalling the plugin but didn't help.


workspace .log file snippet:

!MESSAGE Plug-in "ch.acanda.eclipse.pmd.core" was unable to instantiate class "ch.acanda.eclipse.pmd.builder.PMDBuilder".
!STACK 0
java.lang.NoClassDefFoundError: Could not initialize class ch.acanda.eclipse.pmd.builder.PMDBuilder
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:184)
at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
at org.eclipse.core.internal.events.BuildManager.instantiateBuilder(BuildManager.java:907)
at org.eclipse.core.internal.events.BuildManager.initializeBuilder(BuildManager.java:860)
at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:545)
at org.eclipse.core.internal.events.BuildManager.getBuilder(BuildManager.java:574)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:244)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:299)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


Session Data from the error log:
eclipse.buildId=4.4.1.M20140925-0400
java.version=1.7.0
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US


eclipse-pmd-error

eclipse-build-error

project-properties-enabling-pmd

.eclipse-pmd of the project:
<?xml version="1.0" encoding="UTF-8"?> <eclipse-pmd xmlns="http://acanda.ch/eclipse-pmd/0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://acanda.ch/eclipse-pmd/0.8 http://acanda.ch/eclipse-pmd/eclipse-pmd-0.8.xsd"> <analysis enabled="true" /> <rulesets> <ruleset name="PA CTG PMD Coding Rules" ref="CTG-Base/.settings/PA_PMD_Coding_Rules.xml" refcontext="workspace" /> </rulesets> </eclipse-pmd>

Thanks
Prabu

@acanda
Copy link
Owner

acanda commented Jan 15, 2015

@PrabakaranSK In your case the problem is the rule set with the type "Workspace" and the location ".settings/PA_PMD_Coding_Rules.xml". Rule set locations relative to the workspace have always the name of a project as the first segment. Please disable this invalid configuration in all your projects. This should then remove it all together. Did you create the invalid configuration with the "Add rule set" wizard or did you manually edit the .eclipse-pmd file?

@LarsWH Do you have a similar workspace relative configuration where the first segment of the location is not a project name?

@LarsWH
Copy link

LarsWH commented Jan 16, 2015

@acanda Yes, I do indeed have refcontext="workspace" and unfortunately an invalid project name too. Correcting the project name made the error message go away. I do not know how my .eclipse-pmd file was originally generated.

It seems that switching to refcontext="project" and removing the project name from ref="..." is the right solution for me. Can you confirm this? Thanks, Lars

@acanda
Copy link
Owner

acanda commented Jan 16, 2015

The workspace relative paths are meant to be used if several projects in your workspace use the same PMD rule set. This way you only have to maintain one PMD rule set file which can be used by several projects. E.g. if you store the PMD rule set in project ProjectA under config/pmd.xml you should use refcontext="workspace" and ref="ProjectA/config/pmd.xml". If you enable this configuration in the projects ProjectA and ProjectB then both will use the PMD rule set from ProjectA .

The project relative paths are meant to be used if your Eclipse projects contain their own (but different) PMD rule sets at the same location within the project. E.g both ProjectA and ProjectB have a PMD rule set file at config/pmd.xml. In this case you should use refcontext="project" and ref=config/pmd.xml. If you enable this configuration in the projects ProjectA and ProjectB then Project A will use the rule set from ProjectA/config/pmd.xml and ProjectB will use the rule set from ProjectB/config/pmd.xml.

So to answer your question: yes, switching to refcontext="project" and removing the project name from ref="..." will fix the problem (if a rule set file exist at this path in this project) but it might not be what you really want if you use a single rule set file for several Eclipse projects.

@LarsWH
Copy link

LarsWH commented Jan 16, 2015

@acanda I have my rule set under revision control within the project tree, so I am probably going for the refcontext="project" method. Thanks a lot for taking time to clarify and help out. Kind regards, Lars

@PrabakaranSK
Copy link
Author

@acanda After following your instructions, the problem is solved now. Thanks.

Background:
I have a base project in which the ".eclipse-pmd" is kept with ".settings/PA_PMD_Coding_Rules.xml" with ref as "workspace". (The idea was to enable developers to use PMD/Checkstyle easily, just by copying this Base project into their workspace and then copying the ".eclipse-pmd" from this base project into their respective projects in the workspace). Now I prefixed "Base/" to ".settings" which solved the issue. Thanks a lot. I will close this ticket.

@acanda
Copy link
Owner

acanda commented Jan 19, 2015

I'm reopening the issue as it still needs to be fixed. To fix this issue the following things need to be done:

  • fail gracefully when the .eclipse-pmd file contains an invalid configuration, i.e. ignore the invalid configuration but keep using the remaining working configurations
  • mark the invalid configuration in the PMD property page of the project with an error icon
  • automatically update workspace relative configurations when the project name changes, e.g. when renaming the project that contains the rule set file

I'm already working on this and it will most likely be part of the upcoming 1.5.0 release.

@acanda acanda reopened this Jan 19, 2015
acanda added a commit that referenced this issue Jan 19, 2015
acanda added a commit that referenced this issue Feb 1, 2015
Invalid configurations are marked with a warning icon (when they are not
activated) or an error icon (when they are activated). A tool tip shows
the actual absolute path of the configuration to help the user resolve
the problem.

This is the second part of resolving issue #20.
acanda added a commit that referenced this issue Feb 4, 2015
@acanda
Copy link
Owner

acanda commented May 23, 2015

I released eclipse-pmd 1.5 which fails gracefully when the .eclipse-pmd file contains an invalid configuration and marks it in the PMD property page with an error icon.
Automatically updating the workspace relative configuration when a project name changes will come in a later release.

@rsandidfc
Copy link

I've just installed PMD for the first time, and on launching Eclipse am immediately presented with:

Errors occurred during the build.
Error instantiating builder 'ch.acanda.eclipse.pmd.builder.PMDBuilder'.
Plug-in ch.acanda.eclipse.pmd.core was unable to load class ch.acanda.eclipse.pmd.builder.PMDBuilder.
An error occurred while automatically activating bundle ch.acanda.eclipse.pmd.core (1671).
Plug-in ch.acanda.eclipse.pmd.core was unable to load class ch.acanda.eclipse.pmd.builder.PMDBuilder.
An error occurred while automatically activating bundle ch.acanda.eclipse.pmd.core (1671).

I'm running Mars on Win2k8
Version: Mars.2 Release (4.5.2)
Build id: 20160218-0600
eclipse-pmd-1.8.0-201512061933
PMD for Eclipse 4.0.8.v20151204-2156

@acanda
Copy link
Owner

acanda commented Apr 25, 2016

@rsandidfc Did you rename a project or manually edit the .eclipse-pmd file?

@acanda
Copy link
Owner

acanda commented Apr 25, 2016

@rsandidfc I could reproduce your problem. I opened a new issue for this since it is not the same problem as this issue. Please see issue #36.

@acanda
Copy link
Owner

acanda commented Dec 15, 2016

I'm closing this issue as the following bugs have been fixed:

  • fail gracefully when the .eclipse-pmd file contains an invalid configuration, i.e. ignore the invalid configuration but keep using the remaining working configurations
  • mark the invalid configuration in the PMD property page of the project with an error icon

For the remaining enhancement i opened a issue #41:

  • automatically update workspace relative configurations when the project name changes, e.g. when renaming the project that contains the rule set file

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants