DOC to PDF conversion throws NoClassDefFoundError using JDK 1.5

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,


Thanks for your inquiry.

The exception “Cannot connect to X11 window server…” that you are getting is the result of the Linux server you are running not having any display device set. Aspose.Words uses the java.awt package when doing rendering and other graphic tasks. In the Java environment the java.awt class requires a display device and if one cannot be found this exception can occur. Therefore the issue is most likely with your machine setup and not with Aspose.Words

Please see below for solutions to this issue:

  1. 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.
  2. Set the display device, try running this command in console: setenv DISPLAY=localhost:0.0 export DISPLAY
  3. 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.

Please let us know how you go with this. Regarding the other exception you were recieveing in your first thread, are you still having problems with this?

If we can help with anything else, please feel free to ask.

Thanks,