I created a jasper report and now I need to export that report to pdf format. This is my code for that.
// compiles jrxml
JasperCompileManager.compileReportToFile(reportName + ".jrxml");
// fills compiled report with parameters and a connection
JasperPrint print = JasperFillManager.fillReport(reportName + ".jasper", parameters, connection);
// to view the report
//JasperViewer.viewReport(print, false);
// export repor to pdf
JasperExportManager.exportReportToPdfFile(print, "fromXml.pdf");
When I view the report using JasperViewer, it works fine. But When I exporting the report into pdf format, it gives me the following exception.
Exception in thread "main" java.lang.NoClassDefFoundError: com/itextpdf/text/DocumentException
But I have put the iText jar into my libraries.
But one thing, I had another version of iText jar before. It gave me the same exception. I thought that there may be some issues with the version of it.(I followed a tutorial, so I added the same jar as they had used in the tutorial replacing the new jar I had used).
but still the problem remains. I thought this may be the issue now(the accepted answer of the question). But I do not know how to fix it. I removed the entire library and added it again with iText jar which had been used by the tutorial. But I had no luck.
Could you please help me to overcome this issue.
Thank you!
You need to upgrade your iText-2.1.7.jar file to latest version as earlier the package that was used by jar is com.lowagie...
See the change list here which says it has changed the package name.
Related
We are processing a Word template that was created with Word 365 (Version 2202 Build 16.0.14931.20648) in Docx4J. Once the file was modified by our Java application, Word will show an error message when we open the document. The message will state that the file contains unreadable content and that Word needs to repair it. This works fine and the document will eventually open, however, the message is annoying.
I assume that the error message is related to a namespace issue (see this question). That issue was resolved with docx4j v. 8.2.9, which defines the missing namespaces properly.
However, I'm stuck with docx4j 3.3.3 and cannot update. The fix seems rather simple in the GitHub commit, so I wonder, if there is any way to resolve the issue myself. All I have in my code, is a WordprocessingMLPackage object. Can I add or append namespace definitions to that object or it's sub-properties somehow?
You can't add the namespace definitions to the WordprocessingMLPackage object.
You'll need to get the source code for 3.3.3 from https://github.com/plutext/docx4j/tree/docx4j-3.3.3 then copy the new NamespacePrefixMappings content into it, then build it. You can then deploy this new jar file.
If you wanted to try to avoid compiling the source code, you'd have 2 alternatives to try (since docx4j doesn't implement the stategy pattern there). I don't expect these to work!
One is to replace the relevant classes at runtime. For this, see How to replace classes in a running application in java ?
The other is to replace the relevant classes in your jar file, which is just a zip file.
You'd need to get the new class from docx4j 8.2.9.
Please note that sometimes, there are also changes to ContentTypeManager and ContentTypes; see for example https://github.com/plutext/docx4j/commit/d4d02d3fa6e7bf98f35d1f0520e62eb8aef06cba
That commit introduces new parts, and you'll run into problems if you update ContentTypeManager without those.
So you might be tempted to try to replace NamespacePrefixMappings in your existing jar.
But the interfaces it implements changed at https://github.com/plutext/docx4j/commit/65fb843a26b5893200a1824c04c826db2db7940c#diff-70242e2f5ec56be77fe15322526f4530b02e8eafdcb9ae16b60b2220f62e0632
See further https://github.com/plutext/docx4j/commits/VERSION_8_3_8/docx4j-core/src/main/java/org/docx4j/jaxb/NamespacePrefixMappings.java so that is going to cause you problems.
The upshot is you'll need to get the source code for 3.3.3 from https://github.com/plutext/docx4j/tree/docx4j-3.3.3 then copy the new NamespacePrefixMappings content into it (ie except the interface changes), then build it. If you do this, you may as well just deploy your new jar file.
I'm developing an aplication that generates a PDF using Jasper. To do this I have a custom font that I generate in Jasper but the problem is I can't put this working. Every time that I try to generate the document gives me the following error:
Caused by: net.sf.jasperreports.engine.util.JRFontNotFoundException: Font "reportFonts" is not available to the JVM. See the Javadoc for more details.
I'm on IntelliJ and I already setup the font jar in the project path like the this
And the library looks like this
What am I missing here?
Thanks
I've created a "*.jar" file with Intellij IDEA and added to IBM Notes Domino 9 with Code -- Jars -- Import Jar.
I can see my packages in classes which stored in "Code -- Java") but i have an error when i try to use my jar in xpages code:
I have a simple code on my test xpage:
importPackage(com.ibm.ibateam.sources);
var area = new Area("first");
getComponent("label1").setValue(area.getUnid());
but this code throws exception:
Script interpreter error, line=2, col=16: [ReferenceError] 'Area' not found
1: importPackage(com.ibm.ibateam.sources);
-> 2: var area = new Area("first");
3: getComponent("label1").setValue(area.getUnid());
I've tried everything with Java Build Path but nothing works.
I also tried use information from this link:
http://www.xpagetips.com/2012/06/extending-your-xpages-applications-with.html
but move to "WEB-INF/lib/..." didn't help
I know I can add my jar to "...Notes\jvm\lib\ext)" or to eclipse plugins but I don't like this solution because I want to store my jar in notes database.
I have read this question, but the answers don't help me.
I have added the necessary jar file joda-time-2.2.jar using the full path to the file. This file is needed by a function in Hive. Then trying to use a function in Hive I receive the error in the title.
I receive the error despite the jar is added like:
add jar /path/to/the/scripts/joda-time-2.2.jar;
hive> list jars;
/path/te/the/scripts/joda-time-2.2.jar
Strangely sometimes this error does not occur, so that I can execute the function successfully. But this error occurs mostly so that I am thrown out of hive with the error message.
I have tried different versions of the joda-time-2.2.jar file but no success.
Can someone help me?
P.S.:
The lib I am using is brickhouse. The full code is:
add jar /path/te/the/scripts/brickhouse-0.6.0-sources.jar;
add jar /path/te/the/scripts/joda-time-2.2.jar
CREATE TEMPORARY FUNCTION from_json AS 'brickhouse.udf.json.FromJsonUDF';
select from_json('{"key1":"value1","key2":"value2","key3":"value3","key4":[["0","1","nnn"],["1","3","mmm"],["1","3","ggg"],["1","5","kkk"],["4","5","ppp"]]}', 'map<string,string>') from my_table;
You should add your jars like this :
add jar /path/te/the/scripts/joda-time-2.2.jar;
add jar /path/te/the/scripts/brickhouse-0.6.0-sources.jar;
I encluntered a prblem in the execution of TOXGENE tool to generate XML file,
when I execute the command with the template file
C:\toxgene3.2\samples\catalog>toxgene catalog.tsl
template parsing Done!
Generating 200 elements in author_list: Done!
Reading List genre_lists from ./input/genres.xml"
****Error can not parse files ./input/genres.xml
org.apache.xerces.parsers.SAXParser
any suggestions to fix this error
I suffered this problem and it was caused by the jar files in the last release of Xerces-J not being what ToXgene expects. Try changing the bin/toxgene script such that $XERCES_HOME/xerces.jar on the CLASSPATH.
That's it, which was said by Sudantha, but I found a bug too.
If you is using Windows, it is necessary to edit the line 21 (set TG_CP= ...)
of the bin/toxgene.bat file. You need to remove "$" before "%" characters.
By the way, someone knows where I can to download XBench [1] generator or a ToXgene older version?
[1] https://cs.uwaterloo.ca/~tozsu/ddbms/projects/xbench/index.html
Good luck!