Using epubcheck 1.0.3 as a Library throws NPE

38 views
Skip to first unread message

jeffsese

unread,
Jan 5, 2009, 11:51:02 PM1/5/09
to epubcheck, jefers...@asiatype.com
Hi,

I'm trying to use epubcheck as a library but it throws an NPE at this
code:

boolean result = checker.validate();

where checker is

new EpubCheck(getEpubFile(), new DefaultReportImpl(getEpubFile
().getName()))

here is the stack trace of the error:

Exception in thread "main" java.lang.ExceptionInInitializerError
at com.adobe.epubcheck.api.EpubCheck.validate(EpubCheck.java:127)
at
com.asiatype.hachette.epubconversion.epubvalidation.EpubValidation.validate
(EpubValidation.java:36)
at
com.asiatype.hachette.epubconversion.epubvalidation.EpubValidation.main
(EpubValidation.java:61)
Caused by: java.lang.NullPointerException
at org.relaxng.datatype.helpers.DatatypeLibraryLoader$Service
$Loader2.getResources(DatatypeLibraryLoader.java:151)
at org.relaxng.datatype.helpers.DatatypeLibraryLoader$Service.<init>
(DatatypeLibraryLoader.java:173)
at org.relaxng.datatype.helpers.DatatypeLibraryLoader.<init>
(DatatypeLibraryLoader.java:57)
at com.thaiopensource.relaxng.impl.SchemaReceiverImpl.installHandlers
(SchemaReceiverImpl.java:36)
at com.thaiopensource.validate.auto.AutoSchemaReceiver
$Handler.startElement(AutoSchemaReceiver.java:54)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement
(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl
$NSContentDispatcher.scanRootElementHook(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl
$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument
(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
Source)
at com.thaiopensource.validate.auto.AutoSchemaReader.createSchema
(AutoSchemaReader.java:68)
at com.adobe.epubcheck.xml.XMLValidator.<init>(XMLValidator.java:128)
at com.adobe.epubcheck.ocf.OCFChecker.<clinit>(OCFChecker.java:42)
... 3 more

But using it in the command line does not throw an NPE... the
epubcheck-1.0.3.jar is already the classpath...

How can I resolve this?

Thanks in advance.

-- Jeff

Peter Sorotokin

unread,
Jan 6, 2009, 1:47:22 AM1/6/09
to epub...@googlegroups.com, jefers...@asiatype.com
Jeff,

Do you have saxon.jar in the classpath?

Peter

jeffsese

unread,
Jan 6, 2009, 2:38:19 AM1/6/09
to epubcheck, jefers...@asiatype.com
yes... I'm using the latest version of saxon.

On Jan 6, 2:47 pm, Peter Sorotokin <psoro...@adobe.com> wrote:
> Jeff,
>
> Do you have saxon.jar in the classpath?
>
> Peter
>
> -----Original Message-----
> From: epub...@googlegroups.com [mailto:epub...@googlegroups.com] On Behalf Of jeffsese
> Sent: Monday, January 05, 2009 8:51 PM
> To: epubcheck
>
> Cc: jeferson.s...@asiatype.com

jeffsese

unread,
Jan 6, 2009, 3:42:24 AM1/6/09
to epubcheck, jefers...@asiatype.com
Tracing in eclipse... the NPE is thrown at the following line:

xr.parse(in);

of AutoSchemaReader class

-- Jeff

Peter Sorotokin

unread,
Jan 6, 2009, 11:03:04 AM1/6/09
to epub...@googlegroups.com, jefers...@asiatype.com
That's a problem. Saxon comes with buggy XML parser which causes problems (see the last entry at http://code.google.com/p/epubcheck/wiki/Errors). Please try it with the saxon bundled with epubcheck first.

If you need the most recent saxon, it is possible to either modify saxon to remove XML registration or to get another XML parser (e.g. xerses) in the classpath.

Peter

-----Original Message-----
From: epub...@googlegroups.com [mailto:epub...@googlegroups.com] On Behalf Of jeffsese
Sent: Monday, January 05, 2009 11:38 PM
To: epubcheck
Cc: jefers...@asiatype.com

jeffsese

unread,
Jan 6, 2009, 10:02:59 PM1/6/09
to epubcheck, jefers...@asiatype.com
As far as I know, Saxon does not come with a parser as it loads a
parser using the JAXP mechanisms which usually loads the parser in the
JDK. I have the latest Xerces version in my classpath so it should be
picking up that version. But still i'm getting the NPE.

Again, I tried to use the saxon.jar that came with epubcheck (version
6.5), but still there's the NPE.

Alas, I tried to check the JVM I'm using in the command line and it
was 1.5 and the one I'm using in eclipse was version 6... changing the
version in eclipse to 1.5 removes the NPE.

So I guess epubcheck is not compatible with 1.6.

Again thanks for the answers....

-- Jeff

On Jan 7, 12:03 am, Peter Sorotokin <psoro...@adobe.com> wrote:
> That's a problem. Saxon comes with buggy XML parser which causes problems (see the last entry athttp://code.google.com/p/epubcheck/wiki/Errors). Please try it with the saxon bundled with epubcheck first.
>
> If you need the most recent saxon, it is possible to either modify saxon to remove XML registration or to get another XML parser (e.g. xerses) in the classpath.
>
> Peter
>
> -----Original Message-----
> From: epub...@googlegroups.com [mailto:epub...@googlegroups.com] On Behalf Of jeffsese
> Sent: Monday, January 05, 2009 11:38 PM
> To: epubcheck
>
> Cc: jeferson.s...@asiatype.com

jeffsese

unread,
Jan 12, 2009, 3:59:52 AM1/12/09
to epubcheck, jefers...@asiatype.com
Following-up, I tried building epubcheck 1.0.3 in eclipse using java
1.6 as my jvm... built with no errors but tried running the
application and it throws the errors i mentioned in the first post:
again here is the stack trace:

Epubcheck Version 1.0.3

Exception in thread "main" java.lang.ExceptionInInitializerError
at com.adobe.epubcheck.api.EpubCheck.validate(EpubCheck.java:127)
at com.adobe.epubcheck.tool.Checker.main(Checker.java:48)
Caused by: java.lang.NullPointerException
at org.relaxng.datatype.helpers.DatatypeLibraryLoader$Service
$Loader2.getResources(DatatypeLibraryLoader.java:151)
at org.relaxng.datatype.helpers.DatatypeLibraryLoader$Service.<init>
(DatatypeLibraryLoader.java:173)
at org.relaxng.datatype.helpers.DatatypeLibraryLoader.<init>
(DatatypeLibraryLoader.java:57)
at com.thaiopensource.relaxng.impl.SchemaReceiverImpl.installHandlers
(SchemaReceiverImpl.java:36)
at com.thaiopensource.validate.auto.AutoSchemaReceiver
$Handler.startElement(AutoSchemaReceiver.java:54)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement
(AbstractSAXParser.java:501)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement
(XMLNSDocumentScannerImpl.java:400)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl
$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:
626)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl
$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3095)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl
$PrologDriver.next(XMLDocumentScannerImpl.java:921)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next
(XMLDocumentScannerImpl.java:648)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next
(XMLNSDocumentScannerImpl.java:140)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument
(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse
(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse
(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
$JAXPSAXParser.parse(SAXParserImpl.java:522)
at com.thaiopensource.validate.auto.AutoSchemaReader.createSchema
(AutoSchemaReader.java:68)
at com.adobe.epubcheck.xml.XMLValidator.<init>(XMLValidator.java:129)
at com.adobe.epubcheck.ocf.OCFChecker.<clinit>(OCFChecker.java:42)
... 2 more

Should this be a bug?

-- jeff

Mark Bestley

unread,
Apr 17, 2009, 4:54:47 PM4/17/09
to epub...@googlegroups.com, jefers...@asiatype.com
jeffsese <jeff...@gmail.com> writes:

> Following-up, I tried building epubcheck 1.0.3 in eclipse using java
> 1.6 as my jvm... built with no errors but tried running the
> application and it throws the errors i mentioned in the first post:
> again here is the stack trace:
>
> Epubcheck Version 1.0.3
>
> Exception in thread "main" java.lang.ExceptionInInitializerError
> at com.adobe.epubcheck.api.EpubCheck.validate(EpubCheck.java:127)
> at com.adobe.epubcheck.tool.Checker.main(Checker.java:48)
> Caused by: java.lang.NullPointerException
> at org.relaxng.datatype.helpers.DatatypeLibraryLoader$Service

>> > > But using it in the command line does not throw an NPE... the


>> > > epubcheck-1.0.3.jar is already the classpath...
>>
>> > > How can I resolve this?
>>
>> > > Thanks in advance.
>>

I was playing around and got this error as well under Java 1.6 running under eclipse (so paths into jars might be wrong)

I got the latest version of jing <http://code.google.com/p/jing-trang/source/checkout> and built that. (This might not be needed)

Then got errors which I think are due to com.adobe.epubcheck.xml.XMLValidator having a bug in its constructor and needs an ENTITY_RESOLVER to be added at line 126

mapBuilder.put(ValidateProperty.ENTITY_RESOLVER,
new ResourceEntityResolver() );

However using Java 1.5 I could just use the built epubcheck jar from google code so I am notcertain what is happening here.

--
Mark

Reply all
Reply to author
Forward
0 new messages