maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alix Lourme (JIRA)" <j...@codehaus.org>
Subject [jira] (MPMD-204) CPD report : Required class was missing : org/w3c/dom/ElementTraversal
Date Mon, 09 Feb 2015 22:20:18 GMT

    [ https://jira.codehaus.org/browse/MPMD-204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=362906#comment-362906
] 

Alix Lourme commented on MPMD-204:
----------------------------------

{quote}
WDYT
{quote}

The joys of Xml APIs with Xerces ^^ :p

Seriously, with -e option (see [^site-plexus-classpath.log]), _maven-site-plugin_ has by default
in classpath (by plexus) : xercesImpl-2.9.1 / xml-apis-1.3.04.
pmd-java 5.2.3 use xercesImpl-2.11.0 as dependency, without xml-apis-1.4.01 (seem to be required
for this xerces version).

Executing _maven-pmd-plugin_ under Eclipse (Kepler SR2), I have the same error (_ElementTraversal_
not found).

On a simple Eclipse java project with only xercesImpl-2.11.0 dependency, following code provides
same error (no xml-apis provided in dependencies) : 
{code}
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
parser.newDocument();
{code}

No error with xercesImpl-2.9.1 ... this xerces version has xml-apis-1.3.04 in own dependencies
... 
In addition, and contrary to v2.9.1, v2.11.0 seems to require xml-apis for _parser.newDocument()_
call.

----

{quote}
Why did no unit/integration test fail
{quote}

I don't know, I don't understand how there is no problems if the required xml-apis-1.4.01
is not provided :(.
I haven't excluded that the bug comes from my environment ... but it has nothing specific.

----
*+Solution+* ?

I think the best solution is to delete xerces dependency from pmd-java.
To let the high level component the choice of xml API implementation (maven plugin : site
or pmd).

Perhaps using the maven dependencies plugin exclusion system could work (xerces ) ... and
is a better solution that upgrade xml-api (as in my original issue description) and not xerces
(dangerous).

I will do some tests tomorrow.


> CPD report : Required class was missing : org/w3c/dom/ElementTraversal
> ----------------------------------------------------------------------
>
>                 Key: MPMD-204
>                 URL: https://jira.codehaus.org/browse/MPMD-204
>             Project: Maven PMD Plugin
>          Issue Type: Bug
>          Components: CPD
>    Affects Versions: 3.3, 3.4
>         Environment: Maven 3.2.3
>            Reporter: Alix Lourme
>         Attachments: site-plexus-classpath.log
>
>
> Hi, 
> Since _maven-pmd-plugin_ v3.3, on a simple pom : 
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <project...>
>     <modelVersion>4.0.0</modelVersion>
>     <groupId>test</groupId>
>     <artifactId>test</artifactId>
>     <version>1.0.0-SNAPSHOT</version>
>     <packaging>jar</packaging>
>     <reporting>
>         <plugins>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-pmd-plugin</artifactId>
>                 <version>3.4</version>
>             </plugin>
>         </plugins>
>     </reporting>
> </project>
> {code}
> Command _mvn site_ gives : 
> {quote}
> Caused by: org.apache.maven.plugin.PluginContainerException: A required class was missing
while executing org.apache.maven.plugins:maven-site-plugin:3.3:site: org/w3c/dom/ElementTraversal
> {quote}
> Stack : 
> {code}
> Caused by: java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
> 	at java.lang.ClassLoader.defineClass1(Native Method)
> 	[...]
> 	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
> 	at org.apache.xerces.jaxp.DocumentBuilderImpl.newDocument(Unknown Source)
> 	at net.sourceforge.pmd.cpd.XMLRenderer.createDocument(XMLRenderer.java:50)
> 	at net.sourceforge.pmd.cpd.XMLRenderer.render(XMLRenderer.java:73)
> 	at org.apache.maven.plugin.pmd.CpdReport.writeNonHtml(CpdReport.java:301)
> 	at org.apache.maven.plugin.pmd.CpdReport.executeCpd(CpdReport.java:260)
> 	at org.apache.maven.plugin.pmd.CpdReport.executeCpdWithClassloader(CpdReport.java:195)
> 	at org.apache.maven.plugin.pmd.CpdReport.canGenerateReport(CpdReport.java:170)
> 	[...]
> 	at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:121)
> 	[...]
> Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal
> 	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
> 	[...]
> 	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
> 	[...]
> {code}
> ----
> Adding this override fix the problem, but could introduce some impacts on other report
plugins :
> {code:xml}
> <build>
>         <pluginManagement>
>             <plugins>
>                 <plugin>
>                     <groupId>org.apache.maven.plugins</groupId>
>                     <artifactId>maven-site-plugin</artifactId>
>                     <version>3.4</version>
>                     <dependencies>
>                         <dependency>
>                             <groupId>xml-apis</groupId>
>                             <artifactId>xml-apis</artifactId>
>                             <version>1.4.01</version>
>                         </dependency>
>                     </dependencies>
>                 </plugin>
>             </plugins>
>         </pluginManagement>
>     </build>
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.6#6162)

Mime
View raw message