Hi
I am using Aspose.Words.jdk15.jar in java.I am getting the below exception while
trying to convert it into PDF. But when i am trying convert DOC didnt face any issue looking good…
Log Trace
java.lang.NoClassDefFoundError: Could not initialize class asposewobfuscated.rw
at com.aspose.words.bcg.a(Unknown Source)
at com.aspose.words.bcg.g(Unknown Source)
at com.aspose.words.auk.c(Unknown Source)
at com.aspose.words.auk.a(Unknown Source)
at com.aspose.words.auk.a(Unknown Source)
at com.aspose.words.yf.b(Unknown Source)
at com.aspose.words.yf.a(Unknown Source)
at com.aspose.words.yv.b(Unknown Source)
at com.aspose.words.xi.a(Unknown Source)
at com.aspose.words.yf.a(Unknown Source)
at com.aspose.words.xv.a(Unknown Source)
at com.aspose.words.xi.a(Unknown Source)
at com.aspose.words.Document.hn(Unknown Source)
at com.aspose.words.qt.a(Unknown Source)
at com.aspose.words.Document.a(Unknown Source)
at com.aspose.words.Document.a(Unknown Source)
at com.aspose.words.Document.i(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
please have a look into the below code for your reference
ByteArrayOutputStream outputByt=new ByteArrayOutputStream();
ByteArrayInputStream bytImg=null;
byte[] img= voRequest.getImage();
bytImg=new ByteArrayInputStream(img);
doc=new com.aspose.words.Document(bytImg);
doc.getRange().replace("<>" ,new Date() ,false,false);
…
…
…
switch(requiredFrmt){
case 1: //PDF Generation
doc.save(outputByt,SaveFormat.PDF);
createTemplateResp.setFormat(“PDF”);
break;
default: // Word document 0
doc.save(outputByt,SaveFormat.DOC);
createTemplateResp.setFormat(“DOC”);
break;
}
Hi
Thanks for your query. It would be great if you please share your document for investigation purposes.
Hi
Thanks for you reply… its working fine for desktop stand alone program. when we tried to do the same thing via J2EE application deployed in unix server facing this issue.
Please find the attachment for your reference.
Hi,
Thanks for sharing the document. I have successfully converted the shared file to PDF and Doc file format. It will be really helpful if you please create a sample application with following two lines. Deploy the application to Linux server and share your findings with us.
com.aspose.words.Document doc = new com.aspose.words.Document("testdocment.docx");
doc.save("AsposeOut.pdf");
Hi
Thanks for your information.
Our application server running in sun solaris server and getting in below exception
Caused by: org.omg.CORBA.UNKNOWN: java.lang.InternalError: Can’t connect to X11 window server using ‘localhost:0.0’ as the value of the DISPLAY variable.
at camros.oak.POAimpl._dispatch_me(POAimpl.java:1494)
then we set the below code in our class
static {
System.setProperty(“java.awt.headless”, “true”);
}
and deployed the code after that it is working fine…
Could you please let me know what is the issue here?
Thanks
Raman
Hi Raman,
Thanks for sharing the information. I have tested the scenario by using JDK 1.6 and have not found the issue. Please find the output Pdf file in attachment.
I will check this scenario by using JDK 1.5 and will update you asap.
Hi Raman,
- Run your application in headless mode (as you have found). This fixes the issue as java.awt appears to work properly when run in headless mode and does not run into any exception even if a display is not set.
- Set the display device, try running this command in console: setenv DISPLAY=localhost:0.0 export DISPLAY
- If the first two do not help/are not applicable, then try using the free-to-use PJA toolkit as a substitution to java.awt. There are instructions on the site of how to replace java.awt with that library with one line of code.