We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

NoSuchMethodError

I am attempting to convert PDFs to java.awt.Image objects using the below method:

public Image createImage(DocumentContent docContent, ThumbnailProperties properties) {
		
		PdfConverter converter = new PdfConverter();
		converter.bindPdf(new ByteArrayInputStream(docContent.getContent()));
		
		converter.setStartPage(properties.getPageNumber()+1);
		converter.setEndPage(properties.getPageNumber()+1);
		
		converter.setResolution(properties.getDpi());
		
		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
		try {
			converter.doConvert();
			
			if (converter.hasNextImage()) {
				converter.getNextImage(outputStream, ImageType.BMP);
			}
			
			Image image = ImageIO.read(new ByteArrayInputStream(outputStream.toByteArray()));
			
			return image;
		} catch (Exception e) {
			throw new ServiceException("Failed to create thumbnail for properties:" + properties, e);
		}
	}

I have installed JAI 1.1.3 (jai-1_1_3-lib-windows-i586) from here and added jai_codec.jar and jai_core.jar to my CLASSPATH.

Unfortunately, I get the following exception:

java.lang.NoSuchMethodError: com.sun.media.jai.codec.SeekableStream.wrapInputStream(Ljava/io/InputStream;Z)Lcom/sun/media/jai/codec/SeekableStream;
	at com.aspose.pdf.kit.jl.b(Unknown Source)
	at com.aspose.pdf.kit.li.a(Unknown Source)
	at com.aspose.pdf.kit.iu.b(Unknown Source)
	at com.aspose.pdf.kit.iu.a(Unknown Source)
	at com.aspose.pdf.kit.li.a(Unknown Source)
	at com.aspose.pdf.kit.ju.a(Unknown Source)
	at com.aspose.pdf.kit.PdfConverter.doConvert(Unknown Source)
	at com.sentry.thumbnails.dao.aspose.AsposePdfKitThumbnailGenerator.createImage(AsposePdfKitThumbnailGenerator.java:49)
	at com.sentry.thumbnails.dao.aspose.TestAsposePdfKitThumbnailGenerator.testPdftoJpg(TestAsposePdfKitThumbnailGenerator.java:27)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Hi Jake,


Thanks for contacting support.

I have tested the scenario using Aspose.Pdf.Kit for Java 4.5.0 over Windows 7 (X64) where I have JDK 1.7 installed and I am unable to notice any issue when I have used one of my sample PDF files. Can you please share the source PDF file which you are using so that we can test the scenario at our end. We are sorry for this inconvenience.

I believe I have figured out this issue after a little more research. It appears that JAI only supports 32 bit JREs. I switched to 32bit Eclipse and 32 bit JDK and the same code now succeeds.

Is it possible to rasterize a PDF to an image using PDF.Kit with a 64bit JRE?

Hi Jake,


I have tested the scenario over Windows 7 (X64) where I have jdk1.7.0_09 (X64) installed over my system and I have used Eclipse JUNO Version: Juno Service Release 1 - Build id: 20120920-0800 (X64) and as per my observations, I am unable to notice any issue during conversion process. Please note that I have used jai_imageio_windows_i586.jar and jai_windows-i586.jar, sun-jai_core.jar files in class path reference.

Where are these JAR files available? After installing JAI, I do not see these.

Hi Jake,


The requested Jars can be downloaded from following links.


In case you still face the same issue, please feel free to contact.

I have added these to my classpath and still get this error. I have attached a screenshot of my build path. When running under a 32bit JRE, everything works fine with or without these jars.

I noticed that contained within jai_imageio_windows_i586.jar and jai_windows-i586.jar were executable installers. I installed these, but that didn’t help either.

I also switched from jdk1.6.0_43 (64bit) to jdk1.7.0_21 (64bit). Neither work, but I have been able to get jdk1.6.0_43 (32bit) and jdk1.7.0_21 (32bit) to work. Also, just to note: I am using Windows 7 64bit and Eclipse Juno.

No combination of the mentioned JAR files, 64bit JRE, installation of the installers embedded in the JARs has been able to produce anything other than the exception above. I have attached a PDF that exhibits this problem, but it doesn’t seem to be limited to any particular PDF since I have tried several.


Hi Jake,


Thanks for sharing the details and sorry for the delayed response.

Please take a look over attached image file which highlights/shows the JAR files which I have referenced in my application. Please note that I have jdk1.7.0_09 (X64) installed over Windows 7(X64) Enterprise and I have used Eclipse Version: Juno Service Release 1 - Build id: 20120920-0800 and as per my observations, when I have tried converting PDF document to Image format using new Aspose.Pdf for Java 4.0.0, I am unable to notice any problem.

For your reference, I have also attached the JAR files which are referenced in my application. In case you still face the same problem, please do let us know. We are sorry for this delay and inconvenience.