PMD-Plugin: 4.0.7.v20150522-1709
Eclipse Luna SR2
IBM JDK 1.7.0
Eclipse is run with the IBM-JDK. When clicking OK on the project properties page for PMD the following exception is thrown:
java.lang.RuntimeException: Could not instantiate serializer com.sun.org.apache.xml.internal.serialize.XMLSerializer: java.lang.ClassNotFoundException: com.sun.org.apache.xml.internal.serialize.XMLSerializer
at org.exolab.castor.xml.BaseXercesJDK5Serializer.<init>(BaseXercesJDK5Serializer.java:59)
at org.exolab.castor.xml.XercesJDK5XMLSerializerFactory.getSerializer(XercesJDK5XMLSerializerFactory.java:34)
at org.exolab.castor.xml.util.XMLParserUtils.getSerializer(XMLParserUtils.java:259)
at org.castor.xml.AbstractInternalContext.getSerializer(AbstractInternalContext.java:370)
at org.exolab.castor.xml.Marshaller.configureSerializer(Marshaller.java:477)
at org.exolab.castor.xml.Marshaller.setWriter(Marshaller.java:423)
at net.sourceforge.pmd.eclipse.runtime.properties.impl.ProjectPropertiesManagerImpl.writeProjectProperties(ProjectPropertiesManagerImpl.java:280)
....</init>
The problem is that the IBM JDK does not ship the class com.sun.org.apache.xml.internal.serialize.XMLSerializer (note the leading "com.sun"), but the class org.apache.xml.internal.serialize.XMLSerializer (without leading "com.sun").
I fixed that locally by adding
marshaller.setProperty("org.exolab.castor.xml.serializer.factory","org.exolab.castor.xml.XercesXMLSerializerFactory");
to the following two methods:
net.sourceforge.pmd.eclipse.core.rulesets.impl.RuleSetsManagerImpl.writeToXml(RuleSets, OutputStream)
net.sourceforge.pmd.eclipse.runtime.properties.impl.ProjectPropertiesManagerImpl.writeProjectProperties(IProject, ProjectPropertiesTO)
I have no Oracle JDK to test, but I guess that this would break the plugin there.
This will be fixed with the next version.
You can test the new version by installing the latest plugin version from
https://sourceforge.net/projects/pmd/files/pmd-eclipse/update-site-latest/
I removed castor completely and use just JAXB.
Fix confirmed. Thank you.
I build from source, as I also needed the fix described in #1415.