Expand my Community achievements bar.

Hi I am getting null pointer exception while trying to generate pdf using java api

Avatar

Former Community Member

the methods I coded :

@Override

public byte[] generateOutput(final String formPathNm, final byte[] inputData) throws IOException, OutputServiceException {

PDFOutputOptionsSpec pdfOutputOptionsSpec = new PDFOutputOptionsSpec();

pdfOutputOptionsSpec.setFileURI("

\\opt\\abc\\pdf\\abc.pdf");

RenderOptionsSpec rec =

  new RenderOptionsSpec();

rec.setRenderAtClient("YES");

this.outputClient = new OutputClient(myFactory);

  OutputResult outputDocument =null;

try

{ outputDocument =

this.outputClient.generatePDFOutput(TransformationFormat.PDF, "address_zh.xdp",

"\\opt\\aem\\shared\\adobe\\aem\\forms\\", pdfOutputOptionsSpec, rec, new Document(inputData));

catch (Exception e) {

out.println("**************In the method end**************");

return IOUtils.toByteArray(outputDocument.getGeneratedDoc().getInputStream());

the error logs :

**************In the method**************

com.adobe.livecycle.output.exception.OutputException: java.lang.NullPointerException

at com.adobe.livecycle.output.client.OutputClient.generatePDFOutput(OutputClient.java:151)

at com.fourpoint.centralmigration.generateoutput.services.core.outputservices.PdfPrintOutputService.generateOutput(PdfPrintOutputService.java:42)

at com.fourpoint.centralmigration.generateoutput.services.core.GenerateOutputService.printOutput(GenerateOutputService.java:85)

at com.fourpoint.centralmigration.watchedfolder.core.WatchedFolderProcessor.processInputs(WatchedFolderProcessor.java:137)

at com.adobe.aemfd.watchfolder.service.ServiceInputProcessor$1.execute(ServiceInputProcessor.java:52)

at com.adobe.aemfd.watchfolder.service.ServiceInputProcessor$1.execute(ServiceInputProcessor.java:49)

at com.adobe.aemfd.watchfolder.service.ServiceInvoker.lookupAndInvoke(ServiceInvoker.java:37)

at com.adobe.aemfd.watchfolder.service.ServiceInputProcessor.doProcess(ServiceInputProcessor.java:49)

at com.adobe.aemfd.watchfolder.util.AbstractSyncInputProcessor.processInputs(AbstractSyncInputProcessor.java:61)

at com.adobe.aemfd.watchfolder.factory.InputProcessorFactory.processInputs(InputProcessorFactory.java:79)

at com.adobe.aemfd.watchfolder.distribution.DistributionListener.process(DistributionListener.java:85)

at org.apache.sling.event.impl.jobs.JobConsumerManager$JobConsumerWrapper.process(JobConsumerManager.java:500)

at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.startJob(JobQueueImpl.java:291)

at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.access$100(JobQueueImpl.java:58)

at org.apache.sling.event.impl.jobs.queues.JobQueueImpl$1.run(JobQueueImpl.java:227)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:748)

Caused by: java.lang.NullPointerException

at com.adobe.idp.dsc.clientsdk.DocumentPassivationContextFactory.newDocumentPassivationContext(DocumentPassivationContextFactory.java:31)

at com.adobe.idp.dsc.provider.impl.base.RequestOutputStream.defaultPassivate(RequestOutputStream.java:38)

at com.adobe.idp.DocumentRequestOutputStream.passivate(DocumentRequestOutputStream.java:56)

at com.adobe.idp.Document.writeObject(Document.java:877)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1028)

at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)

at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)

at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)

at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)

at java.util.HashMap.internalWriteEntries(HashMap.java:1785)

at java.util.HashMap.writeObject(HashMap.java:1362)

at sun.reflect.GeneratedMethodAccessor158.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1028)

at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)

at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)

at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)

at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)

at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:441)

at java.util.Collections$SynchronizedMap.writeObject(Collections.java:2691)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1028)

at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)

at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)

at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)

at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)

at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)

at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)

at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)

at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)

at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.doSend(EjbMessageDispatcher.java:189)

at com.adobe.idp.dsc.provider.impl.base.AbstractMessageDispatcher.send(AbstractMessageDispatcher.java:69)

at com.adobe.idp.dsc.clientsdk.ServiceClient.invoke(ServiceClient.java:215)

at com.adobe.livecycle.output.client.OutputClient.invokeRequest(OutputClient.java:613)

at com.adobe.livecycle.output.client.OutputClient.generatePDFOutput(OutputClient.java:134)

... 17 more

**************In the method end**************

can anyone pls help me as I am trying to resolve the issue since a long time... thanks in advance

0 Replies