• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Exception in thread "main" java.lang.NoClassDefFoundError: com/itextpdf/text/Element  RSS feed

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am getting subjected error even if there is class file present so please help me out of this ..

following is my java code :

package   pkh.kky;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Date;

public class PDFWriter{

   /**
    * @param args
    */
   public static void main(String[] args) {
       try {
           File file = new File("/home/hdfc/jboss-eap-6.4/standalone/deployments/ICM_UNB.war/WEB-INF/classes/interchange/dataobject/itext.pdf");
           FileOutputStream pdfFileout = new FileOutputStream(file);
           Document doc = new Document();
           PdfWriter.getInstance(doc, pdfFileout);

           doc.addAuthor("QuicklyJava.com");
           doc.addTitle("This is title");
           doc.open();

           Paragraph para1 = new Paragraph();
           para1.add("This is paragraph 1");

           Paragraph para2 = new Paragraph();
           para2.add("This is paragraph 2");

           doc.add(para1);
           doc.add(para2);

           doc.close();
           pdfFileout.close();

           System.out.println("Success!");
       } catch (Exception e) {
           e.printStackTrace();
       }
   }

}
 
author & internet detective
Posts: 39172
724
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you running that program at the command line or through JBoss? IF the former, do you have itext.jar in your classpath?
 
karthik swamy
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am running this code through command in jboss server.
I compiled using javac -cp $CLASSPATH: and then the lib path and class also got compiled without any error but still it gives the same error.
So please hekp me out
 
Jeanne Boyarsky
author & internet detective
Posts: 39172
724
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right so it compiles. The problem is at runtime. Have you added the jar to JBoss' runtime classpath?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i have fixed the above problem.Here problem with Classloader. we can overcome this by placing jar file in web-inf/lib/ext folder. Probably we could not seen this.It is the secondary loaction for classloader to load the jars or third party files. further deatils go through this url:

https://javarevisited.blogspot.com/2012/10/5-ways-to-add-multiple-jar-to-classpath-java.html
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!