Clark Bao
Clark Bao

Reputation: 1693

build failed when using maven call ant tasks "xslt"

This part of the pom.xml

<plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>                 
                    <executions>
                        <execution>

                            <id>validate</id>
                            <phase>validate</phase>
                            <configuration>
                                <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
                                <tasks>
                                    <property name="generated.target" value="${basedir}/target/generated" />
                                    <property name="generated.src.test" value="${generated.target}/src/main/java" />
                                    <property name="generated.resources.test" value="${generated.target}/src/main/resources" />
                                    <property name="generated.wsdl.test" value="${generated.resources.test}/" />
                                    <property name="test.resources.dir" location="${basedir}/src/main/resources" />

                                    <mkdir  dir="${generated.resources.test}/wsdl/type_test" />
                                    <xslt classpath="C://saxonhe9-3-0-5j/saxon9he.jar"  style="${test.resources.dir}/wsdl/type_test/type_test_ID_xsd.xsl" in="${test.resources.dir}/wsdl/type_test/type_test.xsd" out="${generated.resources.test}/wsdl/type_test/type_test_1.xsd">
                                          <param name="groupID" expression="1" />
                                    </xslt>

...

This is the error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:
run (validate) on project cxf-testutils: An Ant BuildException has occured: java
.lang.NoClassDefFoundError: org/apache/xml/serializer/ExtendedContentHandler: or
g.apache.xml.serializer.ExtendedContentHandler -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-antrun-plugin:1.6:run (validate) on project cxf-te
stutils: An Ant BuildException has occured: java.lang.NoClassDefFoundError: org/
apache/xml/serializer/ExtendedContentHandler
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:217)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)

I tried add classpath="C://saxonhe9-3-0-5j/saxon9he.jar" in the xslt tag. But it still throws this exception. I tried Maven 2.2.0 and Maven 3.0.3.JDK 1.6.0 All failed.This pom is actually from apache cxf source code. Anyone can fix it?

UPDATE

I tried many workaround. But this one finally works. Don't change anything in the xslt tag. Just put your xalan jar files into %JAVA-HOME%\jre\lib\endorsed. I download xalan-j_2_7_0. And run cmd
java org.apache.xalan.xslt.EnvironmentCheck to ensure it can find it. It finally works. Huh! It costs me hours to resolve it.

Upvotes: 0

Views: 1629

Answers (2)

avijendr
avijendr

Reputation: 4153

Just ran into this issue,and this is what I did to resolve it.

Add dependency for saxon:

<dependency>
    <groupId>net.sf.saxon</groupId>
    <artifactId>Saxon-HE</artifactId>
    <version>9.4</version>
</dependency>

Add the classpath for saxon:

<xslt in="in.xml" out="out.html" style="style.xsl">
  <classpath location="${net.sf.saxon:Saxon-HE:jar}" />
  <factory name="net.sf.saxon.TransformerFactoryImpl"/>
</xslt>

Upvotes: 0

Michael-O
Michael-O

Reputation: 18405

Use the XML Maven Plugin. This supports Saxon virtually out of the box.

Upvotes: 1

Related Questions