I'm sure something is missing, but I do not see it at all.
I am creating PDF files using iText and I want to do it in a bean. I created one, but that was a mistake. It seems that some of the ways that I used to work in Java do not seem to work in this bean.
For example, this line:
com.itextpdf.text.Document document1 = new com.itextpdf.text.Document();
will throw a java.lang.NoClassDefFoundError: com.itextpdf.text.Document error, even if the container is imported, the build path and com.itextpdf.text.Document are imported into the bean.
if you change it to this:
com.itextpdf.text.Document document1;
or
com.itextpdf.text.Document document1 = null;
the error disappears. I donโt understand why one way works and another doesnโt, but itโs pretty easy to change.
Now I need to set the page size. This will work in Eclipse:
document1.setPageSize(PageSize.LETTER);
but this is the error i get:
java.lang.NoClassDefFoundError: com.itextpdf.text.PageSize
Maybe because I set it to null to initialize it. But
document1 = new Document();
and
document1 = new com.itextpdf.text.Document();
both throw java.lang.NoClassDefFoundError: com.itextpdf.text.Document
Oddly enough, the import statement for the (iText) Document warns me that it is never used.
document1.open();
will provide a java.lang.NoClassDefFoundError: com.itextpdf.text.Document error.
So, did I miss something in the syntax in beans? I have created Java Notes agents, XAgents and am directly working on Java Eclipse projects, but I cannot get these methods to work in 8.5.3 Java bean. I imported the iText banks to WebContent \ WEB-INF \ lib, and then added them (via add banks, not add external banks) to the build path. I got the latest jars and I use them, I created and cleaned, the bean is in faces-config. But I am doing something wrong, and I do not see it.
If someone can point me in the right direction, I would be very grateful.
Cheers, Brian
EDIT: License is not a problem, but I still cannot load the class using the Loader class:
Thread currentThread = Thread.currentThread(); ClassLoader clCurrent = currentThread.getContextClassLoader(); //ClassLoader clCurrent=com.ibm.domino.xsp.module.nsf.NotesContext.getCurrent().getModule().getModuleClassLoader(); try { currentThread.setContextClassLoader(Activator.class.getClassLoader()); DebugToolbar.get().info("after setting up FileOutputStream"); com.itextpdf.text.Document document1 = new com.itextpdf.text.Document(); //com.itextpdf.text.Document document1; //com.itextpdf.text.Document document1 = null; //document1 = new com.itextpdf.text.Document(); //document1.open(); document1.setPageSize(PageSize.LETTER);
I still get java.lang.NoClassDefFoundError: com.itextpdf.text.Document
I cut out beans, peeled, built, pasted, peeled, still an error.
I appreciate the help. Brian