Access methods from imported jars in managed beans

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

+1
source share
2 answers

I called support for Lotus / ICS. It seems that 8.5.3, if you put the jars in ~ Lotus \ Notes \ jvm \ lib \ ext, they will load. I am testing this on my local, but the same way should work on the server. I will spend this Monday. I researched, and if it is mentioned, I did not find it. Jars will be a design element in 9, placing them in a directory that should not be needed for this version, but it seems that adding them this way is now more consistent. The boxes were loaded properly for some of the applications that I made, so it confused me a bit.

Stefan and Panu, thanks for answering.

Brian

0
source

Most likely you have a classloader isssue . If your application is not intended solely for internal use, you can reconsider the use of iText, as it is a GPL. Apache PDFBox is an alternative to licensing Apache (I especially love) or Apache FOP (I will complete] 2 missing articles] ( http://www.wissel.net/blog/htdocs/DominoXSLT ), promise). Of course, OpenNTF POI4XPages can only be what you need.

0
source

All Articles