Document is in disposed state! - accessing a Document workflow variable | Community
Skip to main content
crich2784
Level 6
May 19, 2022

Document is in disposed state! - accessing a Document workflow variable

  • May 19, 2022
  • 2 replies
  • 2118 views

We have written a custom workflow step.  It has the following code.  The idea is to save a Document variable to the Payload directory.

In Java, we are trying to read in the Document variable.

 

Document doc = (Document) wfd.getMetaDataMap().get(docDataVariableName);
log.info("Document is a variable name: " + docDataVariableName);
log.info("Document information content type: " + doc.getContentType());

 

It fails when accessing doc.getContentType();

 

java.lang.IllegalStateException: Document is in a disposed state!
at com.adobe.aemfd.docmanager.Document.checkDisposed(Document.java:236) [adobe-aemds-core-docmanager:3.0.94]
at com.adobe.aemfd.docmanager.Document.getContentType(Document.java:383) [adobe-aemds-core-docmanager:3.0.94]
at com.s360g.aem.workflowcomponent.custom.saveDocumentToPayload.execute(saveDocumentToPayload.java:74) [com-s360g-aem-workflowcomponent.core:0.1.0.20220519201659008]

 

We have similar problems in other components too - all when accessing the Document variable from a workflow.

 

I had a previous post that says this was a bug in 6.5.9 - I have upgraded to 6.5.12 and still having the issue.  I have opened a ticket: 000626337 but, I would love any feedback ahead of answering the ticket.  It's a big blocker in our project.

 

Thanks,

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Mayank_Gandhi
Adobe Employee
Adobe Employee
May 20, 2022

@crich2784 which service is it? output, forms, dor?

crich2784
crich2784Author
Level 6
May 20, 2022

It is not a service producing the Document.  We have built a custom component to read a file from filesystem into a document variable.

 

Document doc = new Document(inFile);
com.adobe.aemfd.docmanager.Document(Files.readAllBytes(filePath));
//doc.passivate();
wfd.getMetaDataMap().put(documentVariableName, doc);

 

This is the code to set the Document variable in the "read file from filesystem"

Mayank_Gandhi
Adobe Employee
Adobe Employee
May 20, 2022

@crich2784 jee workbench?

Adobe Employee
May 31, 2022

@crich2784 Will it be possible for you to share the code for the custom workflow step? Are you calling document.dispose() anywhere in your code? How are you creating the document object? Most likely, this is not a product bug but issue in the custom code.

crich2784
crich2784Author
Level 6
May 31, 2022

@sharoon23  the code is super simple and I have a 1 step workflow to exploit the issue.  It has been submitted to Adobe support.  After reading my dialog variables, this is the code to read the file from the filesystem and put it into a Document variable in the workflow.  The document variable in the workflow is not be accessed prior to this component.

 

log.info(" Creating File variable using this path: " + path);
File inFile = new File(path);
if(inFile.exists() ) {
log.info(" File exists - proceeding with setting process variables.");
if ( fileExistsVariableName.length() > 0 ) {
log.info(" Setting variable fileExistsVariableName to Boolean.TRUE" );
wfd.getMetaDataMap().put(fileExistsVariableName, Boolean.TRUE);
}
log.info(" Creating Adobe Document from java File.");
Document doc = new Document(inFile);
log.info(" Document created with content type " + doc.getContentType() + " and maxInlineSize " + doc.getMaxInlineSize());
//Path filePath = Paths.get(path);
//com.adobe.aemfd.docmanager.Document doc = new com.adobe.aemfd.docmanager.Document(Files.readAllBytes(filePath));
//doc.passivate();
wfd.getMetaDataMap().put(documentVariableName, doc);

Wells_Sri
Level 2
June 22, 2022

I too facing same issue. Any solution for this ?