3

This is possibly related to a classpath problem, but I'm really not sure at this point, since I don't get this error on some machines.

The error at the top of the stack is SAX2 driver class org.apache.crimson.parser.XMLReaderImpl not found. Why would I get this error only in some environments, but not others? How can I further investigate and/or fix this?

Environments:

  • Jetty on Mac or PC == OK
  • Tomcat 5 or 6 on Mac == OK
  • Tomcat 5 or 6 on Win XP == ERROR
  • Tomcat 6 on CentOS == ERROR

Versions in the POM:

  • batik:batik:jar:1.5:compile
  • net.sf.saxon:saxon:jar:8.7:compile
  • batik:batik-transcoder:jar:1.6-1:compile
    • batik:batik-bridge:jar:1.6-1:compile
    • batik:batik-gvt:jar:1.6-1:compile
    • batik:batik-awt-util:jar:1.6-1:compile
    • batik:batik-util:jar:1.6-1:compile
    • batik:batik-gui-util:jar:1.6-1:compile
    • batik:batik-ext:jar:1.6-1:compile
    • xml-apis:xmlParserAPIs:jar:2.0.2:compile
    • batik:batik-script:jar:1.6-1:compile
    • batik:batik-svg-dom:jar:1.6-1:compile
    • batik:batik-dom:jar:1.6-1:compile
    • batik:batik-css:jar:1.6-1:compile
    • batik:batik-xml:jar:1.6-1:compile
    • batik:batik-parser:jar:1.6-1:compile
    • fop:fop:jar:0.20.5:compile
    • batik:batik-1.5-fop:jar:0.20-5:compile
    • xml-apis:xml-apis:jar:1.0.b2:compile
    • xalan:xalan:jar:2.4.1:compile
    • xerces:xercesImpl:jar:2.2.1:compile
    • avalon-framework:avalon-framework:jar:4.0:compile
Matt
  • 3,254
  • 3
  • 23
  • 32
  • Hi, Matt. I'm having this issue. I've removed fop from /WEB-INF/lib and still get the error. Did you figured out any other related problem? Cheers! – Caio Cunha Jul 26 '12 at 20:09
  • I didn't find any other related problems that I remember (three years ago). I was using Maven to package my application, so excluding the fop artifact in my POM kept Maven from packaging that artifact. If you are still getting the error, then open your WAR and check for that artifact and make sure to restart the Tomcat server. – Matt Jul 26 '12 at 20:31
  • I figured it out. I wasn't deploying the WAR file, and there is 2 other JARs included with `fop`, `batik-fop` and `avalon`. I removed `fop.jar`, but not `batik-fop.jar`. – Caio Cunha Jul 26 '12 at 22:12

3 Answers3

8

Thanks, this was very useful.

On Win 7 / Tomcat 6 had the exactly same "missing crimson" thing. Got it working by adding the crimson libraries, but the performance was poor, very slow. It took something like 10-15 seconds for a single image transcoding. Finally solved the problem by removing the FOP as you described, and now it is really fast. This is how it is in my POM:

    <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-transcoder</artifactId>
        <version>1.6-1</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <artifactId>fop</artifactId>
                <groupId>fop</groupId>
            </exclusion>
        </exclusions>
    </dependency>
Tero Pelkonen
  • 81
  • 1
  • 2
6

It turns out that Apache XML Graphics itself adds Crimson to the classpath, twice. Once in the Apache Batik transcoder, and once in Apache FOP.

Since the libs are loaded alphabetically in Tomcat, FOP included Crimson, first, but then Batik also did the same.

I excluded FOP from the project POM, and have resolved the classpath issue.

Matt
  • 3,254
  • 3
  • 23
  • 32
0

It's a JDK versions problem. Found here:

  • Some JDK already include crimson lib and works fine on developer machine;
  • But some JDK haven't that lib on user's machines and throw error;

Use the following maven config:

<dependency>
    <groupId>batik</groupId>
    <artifactId>batik-transcoder</artifactId>
    <version>1.6-1</version>
</dependency>
<dependency>
    <groupId>crimson</groupId>
    <artifactId>crimson</artifactId>
    <version>1.1.3</version>
</dependency>
JayDi
  • 1,037
  • 15
  • 24