Question

10
Replies
2082
Views
DennyV68 Member since 2015 11 posts
Maantic Inc
Posted: 5 years ago
Last activity: 5 years 2 months ago
Closed
Solved

Exception while reading image

Hi ,

We are using the below code to read TIFF files and saving it as attachment to work object.It was worked fine in 6.1 ,but we created a back up and deleted the ruleset as part of migration to Pega 7.After deployed the code in both 6 and 7 versions, this functionality not working as expected.It is not reading the TIFF file and error file is generating.

Can you please help on this?

Java Code:

try {

//Read file input stream

java.io.InputStream is = parseState.getInputStream();

java.io.ByteArrayOutputStream baos = new

java.io.ByteArrayOutputStream(is.available());

byte[] buffer = new byte[4096];

int bytesRead = 0;

while ((bytesRead = is.read(buffer, 0, 4096))!=-1) {

baos.write(buffer, 0, bytesRead);

}

baos.flush();

baos.close();

is.close();

//Encode byre array to base64

String AttachmentString = Base64Util.encodeToString(baos.toByteArray());

//Set base64 encoded stream to clipboard property

ClipboardPage attachPage = tools.findPage("EncodedFileData_Temp");

ClipboardProperty attachStream = attachPage.getProperty("pyAttachStream");

attachStream.setValue(AttachmentString);

//Get Page Count - Decode base64 to byte array

byte imageArray[] = Base64Util.decodeToByteArray(AttachmentString);

java.util.List bufferedImages = org.apache.commons.imaging.Imaging.getAllBufferedImages(imageArray);

tools.putParamValue("FaxPageCount", bufferedImages.size());

}

catch(Exception e) {

oLog.error("Unable to read file.", e);

throw new PRRuntimeException("Unable to read file.", e);

}

//oLog.info("File read to clipboard successfully.");

Error Generated

<?xml version="1.0"?>

<pagedata>

<pxInsName>1436430377795000!PARFAXFILELISTENERREGION1!DENNY1.1436430376844000.TIFF</pxInsName>

<pyTransactionCount>0</pyTransactionCount>

<pyFileLength>392486</pyFileLength>

<pyBytesProcessed>0</pyBytesProcessed>

<pyPathName>\\agpcorp\apps\Global\APP_Pega_Rx\Dev\3D\Intake\Pega\POC-7\work_PARFaxFileListenerRegion1\denny1.1436430376844000.tiff</pyPathName>

<pxCreateDateTime>20150709T082617.795 GMT</pxCreateDateTime>

<pyListenerName>PARFaxFileListenerRegion1</pyListenerName>

<pyRecoveryAttempt>1</pyRecoveryAttempt>

<pyOriginalFileName>denny1.tiff</pyOriginalFileName>

<pyStackTrace>com.pega.pegarules.pub.PRRuntimeException: Unable to read file.

at com.pegarules.generated.structured.ra_action_attachfiletoworkobject_fca5ab97fb61707ff2d2134fef4baca0.step2_circum0(ra_action_attachfiletoworkobject_fca5ab97fb61707ff2d2134fef4baca0.java:429)

at com.pegarules.generated.structured.ra_action_attachfiletoworkobject_fca5ab97fb61707ff2d2134fef4baca0.perform(ra_action_attachfiletoworkobject_fca5ab97fb61707ff2d2134fef4baca0.java:94)

at com.pega.pegarules.session.internal.mgmt.Executable.doAction(Executable.java:3180)

at com.pega.pegarules.integration.engine.internal.ServiceHelper.runParseStructuredActivity(ServiceHelper.java:1180)

at com.pega.pegarules.integration.engine.internal.services.file.RuleServiceFile.parseFileAtTime(RuleServiceFile.java:682)

at com.pega.pegarules.integration.engine.internal.services.file.RuleServiceFile.process(RuleServiceFile.java:1746)

at com.pega.pegarules.integration.engine.internal.services.file.FileListener.recoverOne(FileListener.java:1521)

at com.pega.pegarules.integration.engine.internal.services.file.FileListener.recovery(FileListener.java:1728)

at com.pega.pegarules.integration.engine.internal.services.file.FileListener.run_(FileListener.java:1900)

at com.pega.pegarules.integration.engine.internal.services.listener.ServiceListenerBaseImpl.run(ServiceListenerBaseImpl.java:448)

at java.lang.Thread.run(Unknown Source)

Caused by: java.lang.NullPointerException

at com.pegarules.generated.structured.ra_action_attachfiletoworkobject_fca5ab97fb61707ff2d2134fef4baca0.step2_circum0(ra_action_attachfiletoworkobject_fca5ab97fb61707ff2d2134fef4baca0.java:404)

... 10 more

</pyStackTrace>

<pyFileName>denny1.1436430376844000.tiff</pyFileName>

<pyProcessingComplete>false</pyProcessingComplete>

<pyOriginalDirectory>\\agpcorp\apps\Global\APP_Pega_Rx\Dev\3D\Intake\Pega\POC-7</pyOriginalDirectory>

<pyOriginalFileId>1436430376844000</pyOriginalFileId>

<pyProcessingStatus>error</pyProcessingStatus>

<pyUniqueId>1436430377795000</pyUniqueId>

<pyFileLastModified>20141118T140944.002 GMT</pyFileLastModified>

<pyRequestorId>AD3167D33C8216D4737289BD4A0A2A682</pyRequestorId>

<pyMessage>Unable to read file.</pyMessage>

<pzInsKey>LOG-SERVICE-FILE 1436430377795000!PARFAXFILELISTENERREGION1!DENNY1.1436430376844000.TIFF</pzInsKey>

<pyTransactionErrorCount>0</pyTransactionErrorCount>

<pyWorkFileName>denny1.1436430377795000.tiff</pyWorkFileName>

<pyDateTime>20150709T082617.795 GMT</pyDateTime>

<pxObjClass>Log-Service-File</pxObjClass>

<pyServerName>VA01DPEGAPP002</pyServerName>

<pzStatus>valid</pzStatus>

</pagedata>

***Updated by moderator: Lochan to close post***
This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Data Integration
Moderation Team has archived post
Share this page LinkedIn