Monday 23 August 2010

Archiva gives the maven site plugin an invalid site_en.xml

I got the following nasty error since friday:

$ mvn -U -e -X clean site
...
[DEBUG] Reading site descriptor from /home/amanica/.m2/repository/za/co/my_company/super-pom/1.0.3/super-pom-1.0.3-site_en.xml
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] SiteToolException: Error parsing site descriptor

Expected root element 'project' but found 'html' (position: START_TAG seen ... Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\r\n<html>... @8:7)
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: SiteToolException: Error parsing site descriptor
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
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.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: SiteToolException: Error parsing site descriptor
at org.apache.maven.plugins.site.AbstractSiteRenderingMojo.createSiteRenderingContext(AbstractSiteRenderingMojo.java:232)
at org.apache.maven.plugins.site.SiteMojo.renderLocale(SiteMojo.java:137)
at org.apache.maven.plugins.site.SiteMojo.execute(SiteMojo.java:120)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: org.apache.maven.doxia.tools.SiteToolException: Error parsing site descriptor
at org.apache.maven.doxia.tools.DefaultSiteTool.readDecorationModel(DefaultSiteTool.java:1298)
at org.apache.maven.doxia.tools.DefaultSiteTool.getDecorationModel(DefaultSiteTool.java:1252)
at org.apache.maven.doxia.tools.DefaultSiteTool.getDecorationModel(DefaultSiteTool.java:1260)
at org.apache.maven.doxia.tools.DefaultSiteTool.getDecorationModel(DefaultSiteTool.java:511)
at org.apache.maven.plugins.site.AbstractSiteRenderingMojo.createSiteRenderingContext(AbstractSiteRenderingMojo.java:225)
... 21 more
Caused by: org.codehaus.plexus.util.xml.pull.XmlPullParserException: Expected root element 'project' but found 'html' (position: START_TAG seen ... Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\r\n<html>... @8:7)
at org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader.parseDecorationModel(DecorationXpp3Reader.java:619)
at org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader.read(DecorationXpp3Reader.java:1387)
at org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader.read(DecorationXpp3Reader.java:1401)
at org.apache.maven.doxia.tools.DefaultSiteTool.readDecorationModel(DefaultSiteTool.java:1294)

It turns out that maven looks for a site_en.xml for my parent project on archiva and archiva seems to generate a return file which is actually an error message.
The maven site plugin then tries to parse it and fails horribly :(
I worked around this by just adding the following content to src/site/site_en.xml in my parent project and everything was well!

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/DECORATION/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
<body>
</body>
</project>


I got really frustrated by this cryptic error message. I wanted to bash my head against the table and throw my laptop against the wall. Instead I cried out to God and not long after that I figured it out. Some would say thats just coincidence, I say: "Thank God", "Praise God" and "Why didn't I ask You sooner?".

3 comments:

  1. I don't see the same thing happening (for example: http://vmbuild.apache.org/archiva/repository/central-proxy/org/apache/archiva/archiva-parent/6/archiva-parent-6-site_en.xml).

    Do you have a proxy host sitting in between that might be responsible for this? Maybe you got this cached in your local repository once when on a wifi network that sends back it's login page instead?

    ReplyDelete
  2. After some back'n forth with Brett and I figured out my real problem:

    I used the wrong repository url for jarvana which caused jarvana to not give a 404 for a non-existing file which is then proxied by archiva.

    wrong url: http://www.jarvana.com/jarvana/browse/
    correct url: http://www.jarvana.com/jarvana/

    Thanks Brett!

    ReplyDelete
  3. Thanks a lot AmanicA of a couple of weeks ago!
    I just googled again for "SiteToolException: Error parsing site descriptor", and I found this blog post, and it helped me.
    I just love it when that happens.
    thanks

    ReplyDelete