0

I have HTML file which i'm tring to convert into pdf using iTextPdf but I'm getting following error,

java.lang.NoSuchMethodError: 
com.itextpdf.text.log.LoggerFactory.getLogger(Ljava/lang/Class;)
Lcom/itextpdf/text/log/Logger;

the lib are as follows

  • itextpdf-5.4.5.jar
  • xmlworker-5.4.5.jar
  • slf4j-api-1.7.7.jar
  • slf4j-log4j12-1.7.7.jar

please guide me to solve this problem, thanks in advance

Edit :

  • itextpdf-5.5.2
  • itextpdf-5.5.2-javadoc
  • itextpdf-5.5.2-sources
  • itext-pdfa-5.5.2
  • itext-pdfa-5.5.2-javadoc
  • itext-pdfa-5.5.2-sources
  • itext-xtra-5.5.2
  • itext-xtra-5.5.2-javadoc
  • itext-xtra-5.5.2-sources

java.lang.NoSuchMethodError: com.itextpdf.text.log.LoggerFactory.getLogger(Ljava/lang/Class;)Lcom/itextpdf/text/log/Logger;
        at com.itextpdf.tool.xml.net.FileRetrieveImpl.<clinit>(FileRetrieveImpl.java:67)
        at com.itextpdf.tool.xml.css.StyleAttrCSSResolver.<init>(StyleAttrCSSResolver.java:113)
        at com.itextpdf.tool.xml.css.StyleAttrCSSResolver.<init>(StyleAttrCSSResolver.java:102)
        at com.itextpdf.tool.xml.css.StyleAttrCSSResolver.<init>(StyleAttrCSSResolver.java:90)
        at com.itextpdf.tool.xml.XMLWorkerHelper.parseXHtml(XMLWorkerHelper.java:213)
        at com.itextpdf.tool.xml.XMLWorkerHelper.parseXHtml(XMLWorkerHelper.java:185)

Class Path

    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/itext-pdfa-5.5.2-javadoc.jar"/>
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/itext-pdfa-5.5.2-sources.jar"/>
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/itext-pdfa-5.5.2.jar"/>
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/itext-xtra-5.5.2-javadoc.jar"/>
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/itext-xtra-5.5.2-sources.jar"/>
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/itext-xtra-5.5.2.jar"/>
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/itextpdf-5.5.2-javadoc.jar"/>
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/itextpdf-5.5.2-sources.jar"/>
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/itextpdf-5.5.2.jar"/>
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/xmlworker-5.5.2.jar"/>
5
  • That method is part of the core itextpdf library since at least version 5.1.1. Do you probably have another, older itextpdf library on your classpath? Commented Sep 9, 2014 at 6:58
  • 1
    Your edit looks like you use a fairly current xmlworker with an ancient itextpdf. Please do check whether there is a second itextpdf jar on your classpath. It looks like such a second jar is found before your current one and, therefore, is used. Commented Sep 9, 2014 at 8:50
  • @mkl i have added the XMLWorker with same version as iText Pdf, please check my edits, but still getting same exception Commented Sep 9, 2014 at 9:21
  • 1
    Are you sure your web application environment does not force an older itext version on you? E.g. using some endorsed libraries? You can try and test that by adding code right before your code running into that exception to create a simple PDF in the file system (e.g. using the method createPdf in HelloWorld.java). Inspecting the generated PDF file you can see the iText version which created the file. Commented Sep 9, 2014 at 9:29
  • @mkl solved, as you said it was loading ancient xmlworker, working fine after i clear the project. thank you so much, your comments helped me alot Commented Sep 9, 2014 at 9:30

1 Answer 1

2

you have to also put following jar files in your lib.

  • itext-pdfa
  • itext-xtra

as per appropriate version. try to put whole required code.

Look into stack trance it may be refer to that class line where error was occur.

Sign up to request clarification or add additional context in comments.

4 Comments

Maybe, but the class and the "missing" method are in the core iText jar: sourceforge.net/p/itext/code/HEAD/tree/tags/iText_5_4_5/itext/…
I have added the jar files, but still i'm getting the same error, I have edited my question, please take a look.
did you check in com.itextpdf.text.log.LoggerFactory available or not ? if no then some problem about itextpdf jar file
@HArdik thank you for your answer, the xmlworker jar was not loading properly, working perfectly now :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.