allcolor / YaHP-Converter

YaHP is a Java library that allows you to convert an HTML document into a PDF document.
GNU Lesser General Public License v2.1
56 stars 23 forks source link

Anyone using YaHP with Java 1.7? #3

Closed kridan closed 12 years ago

kridan commented 12 years ago

I have an issue with deploying YaHP.

The issue is intermittent, and likely class loader related. Basically, the inclusion of xml-apis.jar is causing issues because it conflicts with the internal copy of xerces that the JRE has in rt.jar.

How are people getting around this?

allcolor commented 12 years ago

Hi, It should not mess with the JRE classloader... what version of yahp do you use ?

Regards, Quentin

2012/6/13 kridan < reply@reply.github.com

I have an issue with deploying YaHP.

The issue is intermittent, and likely class loader related. Basically, the inclusion of xml-apis.jar is causing issues because it conflicts with the internal copy of xerces that the JRE has in rt.jar.

How are people getting around this?


Reply to this email directly or view it on GitHub: https://github.com/allcolor/YaHP-Converter/issues/3

All those moments will be lost in time, like tears in rain.

kridan commented 12 years ago

Using YaHP 1.3

So here's the scenario......Adding xml-apis.jar that was bundled with the download broke a bunch of stuff in our application that was using the stuff in rt.jar for it's parsing.

So I removed xml-apis.jar hoping that the classes that you needed in there would also be in rt.jar Evidentally not, because I started getting the message: org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer ERROR java.lang.NoClassDefFoundError: org/w3c/dom/html2/HTMLDocument

I'm assuming (perhaps incorrectly) that this is because the org.w3c.dom folders etc are also in rt.jar (but not html2 folder so obviously it's a subset of xml-apis.jar)

I seem to have resolved this by using the Java "endorsed jars" folder. http://docs.oracle.com/javase/7/docs/technotes/guides/standards/

I don't like resolving it this way though and can't believe that no one else has run into this.

allcolor commented 12 years ago

Remove everything in the directory ("META-INF/services") in the xml-apis.jar and it should work. It's effectively a mistake, those things should not have been shipped with the jar. Alternatively, you could remove everything except the 'html2' classes, it should work too.

Regards, Quentin

kridan commented 12 years ago

Outstanding! This indeed fixed the issue.

Thank you so much for the quick response. I was able to make the end-of-day build :)

ravieze commented 9 years ago

can u tell the xml-apis.jar version in use; and from where it was downnloaded. Googling didnt help me.

allcolor commented 9 years ago

http://sourceforge.net/projects/shanidom/

2014-11-24 15:13 GMT+01:00 ravieze notifications@github.com:

can u tell the xml-apis.jar version in use; and from where it was downnloaded. Googling didnt help me.

— Reply to this email directly or view it on GitHub https://github.com/allcolor/YaHP-Converter/issues/3#issuecomment-64198625 .

All those moments will be lost in time, like tears in rain. (Roy Batty/Rutger Hauer)

allcolor commented 9 years ago

Latest version are only available on bintray:

https://bintray.com/allcolor/alc-web/ShaniXmlParser/view

2014-11-24 15:19 GMT+01:00 Quentin Anciaux allcolor@gmail.com:

http://sourceforge.net/projects/shanidom/

2014-11-24 15:13 GMT+01:00 ravieze notifications@github.com:

can u tell the xml-apis.jar version in use; and from where it was downnloaded. Googling didnt help me.

— Reply to this email directly or view it on GitHub https://github.com/allcolor/YaHP-Converter/issues/3#issuecomment-64198625 .

All those moments will be lost in time, like tears in rain. (Roy Batty/Rutger Hauer)

All those moments will be lost in time, like tears in rain. (Roy Batty/Rutger Hauer)

ravieze commented 9 years ago

Actually we have xml-api.jar (xml-commons of apache i think) etc.. already in project; in such a case... can u rername the jar file to something else? i am afraid I may break something if i overwrite the jar (xml-api.jar);

allcolor commented 9 years ago

Just use the xerces provided one... but you may have to update the shani parser with this one http://dl.bintray.com/allcolor/alc-web/org/allcolor/shaniparser/1.4.22/shaniparser-1.4.22.jar

2014-11-24 15:21 GMT+01:00 ravieze notifications@github.com:

Actually we have xml-api.jar from xercer.jar etc.. already in project; in such a case... can u rername the jar file to something else? i am afraid I may break something if i overwrite the jar (xml-api.jar);

— Reply to this email directly or view it on GitHub https://github.com/allcolor/YaHP-Converter/issues/3#issuecomment-64199658 .

All those moments will be lost in time, like tears in rain. (Roy Batty/Rutger Hauer)

ravieze commented 9 years ago

ok took xml-api.jar form http://archive.apache.org/dist/xml/xalan-j/binaries/xalan-j_2_7_1-bin.zip and used the new shaniparser jar; getting the below error

Initializing... Installing new URLStreamHandlerFactory... Installing new URLStreamHandlerFactory DONE. init time: 22 C:\r\ws\Test2\src\in3.html log4j:WARN No appenders could be found for logger (org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. org.allcolor.yahp.converter.IHtmlToPdfTransformer$CConvertException: ERROR: An unhandled exception occured: org/w3c/dom/ html2/HTMLDocument at org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer.transform(CHtmlToPdfFlyingSaucerTransformer.java:79 1) at org.allcolor.yahp.converter.CYaHPConverter.convertToPdf(CYaHPConverter.java:247) at reports.CopyOfHtml2Pdf.main(CopyOfHtml2Pdf.java:77) at reports.CopyOfHtml2Pdf$1.run(CopyOfHtml2Pdf.java:23) Caused by: java.lang.NoClassDefFoundError: org/w3c/dom/html2/HTMLDocument at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(Unknown Source) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$000(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at org.allcolor.xml.parser.CDomHandler.(CDomHandler.java:135) at org.allcolor.xml.parser.CShaniDomParser.(CShaniDomParser.java:382) at org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer.getCShaniDomParser(CHtmlToPdfFlyingSaucerTransforme r.java:422) at org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer.transform(CHtmlToPdfFlyingSaucerTransformer.java:56 4) ... 3 more done.. Caused by: java.lang.ClassNotFoundException: org.w3c.dom.html2.HTMLDocument at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 19 more Destroying YAHP ClassLoader Tree Exception in thread "AWT-Windows" java.lang.IllegalStateException: Shutdown in progress at java.lang.ApplicationShutdownHooks.add(Unknown Source) at java.lang.Runtime.addShutdownHook(Unknown Source) at sun.awt.windows.WToolkit$2.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.awt.windows.WToolkit.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

ravieze commented 9 years ago

and when i take xml-api.jar from : http://mirror.sdunix.com/apache//xerces/j/binaries/Xerces-J-bin.2.11.0.zip; in combination with: shaniparser-1.4.22.jar

i get the below error

Initializing... Installing new URLStreamHandlerFactory... Installing new URLStreamHandlerFactory DONE. init time: 30 C:\r\ws\Test2\src\in3.html log4j:WARN No appenders could be found for logger (org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. org.allcolor.yahp.converter.IHtmlToPdfTransformer$CConvertException: ERROR: An unhandled exception occured: org/w3c/dom/ html2/HTMLDocument at org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer.transform(CHtmlToPdfFlyingSaucerTransformer.java:79 1) at org.allcolor.yahp.converter.CYaHPConverter.convertToPdf(CYaHPConverter.java:247) at reports.CopyOfHtml2Pdf.main(CopyOfHtml2Pdf.java:77) at reports.CopyOfHtml2Pdf$1.run(CopyOfHtml2Pdf.java:23) Caused by: java.lang.NoClassDefFoundError: org/w3c/dom/html2/HTMLDocument at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(Unknown Source) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$000(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at org.allcolor.xml.parser.CDomHandler.(CDomHandler.java:135) at org.allcolor.xml.parser.CShaniDomParser.(CShaniDomParser.java:382) at org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer.getCShaniDomParser(CHtmlToPdfFlyingSaucerTransforme r.java:422) at org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer.transform(CHtmlToPdfFlyingSaucerTransformer.java:56 4) ... 3 more Caused by: java.lang.ClassNotFoundException: org.w3c.dom.html2.HTMLDocument at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 19 more done.. Destroying YAHP ClassLoader Tree Exception in thread "AWT-Windows" java.lang.IllegalStateException: Shutdown in progress at java.lang.ApplicationShutdownHooks.add(Unknown Source) at java.lang.Runtime.addShutdownHook(Unknown Source) at sun.awt.windows.WToolkit$2.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.awt.windows.WToolkit.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

allcolor commented 9 years ago

Yes you have to take the html2 api from the http://dl.bintray.com/allcolor/alc-web/org/allcolor/shaniparser-xmlapi/1.4.22/shaniparser-xmlapi-1.4.22.jar , unzip it and take only the dom/html2 api or use that jar as is.

2014-11-24 15:29 GMT+01:00 ravieze notifications@github.com:

ok took xml-api.jar form file:///C:/Users/admin/Downloads/xalan-j_2_7_1-bin.zip and used the new shaniparser jar; getting the below error

Initializing... Installing new URLStreamHandlerFactory... Installing new URLStreamHandlerFactory DONE. init time: 22 C:\r\ws\Test2\src\in3.html log4j:WARN No appenders could be found for logger (org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. org.allcolor.yahp.converter.IHtmlToPdfTransformer$CConvertException: ERROR: An unhandled exception occured: org/w3c/dom/ html2/HTMLDocument at org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer.transform(CHtmlToPdfFlyingSaucerTransformer.java:79 1) at org.allcolor.yahp.converter.CYaHPConverter.convertToPdf(CYaHPConverter.java:247) at reports.CopyOfHtml2Pdf.main(CopyOfHtml2Pdf.java:77) at reports.CopyOfHtml2Pdf$1.run(CopyOfHtml2Pdf.java:23) Caused by: java.lang.NoClassDefFoundError: org/w3c/dom/html2/HTMLDocument at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(Unknown Source) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$000(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at org.allcolor.xml.parser.CDomHandler.(CDomHandler.java:135) at org.allcolor.xml.parser.CShaniDomParser.(CShaniDomParser.java:382) at org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer.getCShaniDomParser(CHtmlToPdfFlyingSaucerTransforme r.java:422) at org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer.transform(CHtmlToPdfFlyingSaucerTransformer.java:56 4) ... 3 more done.. Caused by: java.lang.ClassNotFoundException: org.w3c.dom.html2.HTMLDocument at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 19 more Destroying YAHP ClassLoader Tree Exception in thread "AWT-Windows" java.lang.IllegalStateException: Shutdown in progress at java.lang.ApplicationShutdownHooks.add(Unknown Source) at java.lang.Runtime.addShutdownHook(Unknown Source) at sun.awt.windows.WToolkit$2.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.awt.windows.WToolkit.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

— Reply to this email directly or view it on GitHub https://github.com/allcolor/YaHP-Converter/issues/3#issuecomment-64200760 .

All those moments will be lost in time, like tears in rain. (Roy Batty/Rutger Hauer)

ravieze commented 9 years ago

worked like charm.. thank u sooooo much.. so kind of u

ravieze commented 9 years ago

can u share the url to the src code of these jar files?

allcolor commented 9 years ago

they are on bintray same url.

Le mar. 25 nov. 2014 à 6:47, ravi notifications@github.com a écrit :

can u share the url to the src code of these jar files?

— Reply to this email directly or view it on GitHub https://github.com/allcolor/YaHP-Converter/issues/3#issuecomment-64313292 .

milkdeliver commented 8 years ago

Hi allcolor,

It's curiosity for me that What does everything in the directory ("META-INF/services") affect when using Java 1.7? Could you please give an explain.Thank you for your answering.

Remove everything in the directory ("META-INF/services") in the xml-apis.jar and it should work. It's effectively a mistake, those things should not have been shipped with the jar. Alternatively, you could remove everything except the 'html2' classes, it should work too. Regards, Quentin

Regards, Sam

allcolor commented 8 years ago

Hi,

they replace the default xml parser used by the JVM.

Regards, Quentin

2016-03-01 9:36 GMT+01:00 Milkdelivery notifications@github.com:

Hi allcolor,

It's curiosity for me that What does everything in the directory ("META-INF/services") affect when using Java 1.7? Could you please give an explain.Thank you for your answering.

Remove everything in the directory ("META-INF/services") in the xml-apis.jar and it should work. It's effectively a mistake, those things should not have been shipped with the jar. Alternatively, you could remove everything except the 'html2' classes, it should work too. Regards, Quentin

Regards, Sam

— Reply to this email directly or view it on GitHub https://github.com/allcolor/YaHP-Converter/issues/3#issuecomment-190611987 .

All those moments will be lost in time, like tears in rain. (Roy Batty/Rutger Hauer)

milkdeliver commented 8 years ago

Hi,

You're right.The old version xml-api.jar will cause error like below.

javax.xml.datatype.DatatypeConfigurationException: Provider org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl not found

When I removed everything in the directory ("META-INF/services") of xml-api.jar or replace the xml-api.jar by shaniparser-xmlapi-1.4.22.jar it works well.

Finally thanks for your answering.

Regards, Sam