javacallbackoracle-adforacle-bpm-suite

Oracle BPM Human Task Comments Callback Errors When Instantiating AppModule in Called Class


Oracle BPM Version 11.1.1.7. In a Humantask.task, Events tab, Content Change Callbacks section, I have entered the fully qualified class name of a class that implements NotesStore and the addNote and getNotes methods.

The class uses public methods in an AppModule to write and read comments using our custom table and these methods were well tested during development using the the BC tester and a temporary main in the callback class.

The project is compiled to a jar and placed in the BPM project's SCA-INF/lib folder, then the SCA and related ADF human task forms are deployed.

When a comment is made in the out of box human task comments section during a process instance, the class is called, but an exception occurs in the getNotes method at the line the AppModule is created:

java.lang.ClassCastException: oracle.jbo.common.ampool.PoolMgr

In the class, the AppModule is created as so:

AuditModule service = (AuditModule)Configuration.createRootApplicationModule("com.co.modules.AuditModule", "AuditModuleLocal");

I've tried adding a web.xml config file to the SCA BPM project with a filter as discussed in this post (last answer). This discusses triggering the ADF Context initialization, but I'm still getting the error.

The question is, how can I use a call back from a human task to call a method that uses AppModule public methods to do the DB work? Oracle's documentation is very sparse in this area (29.11.1).

UPDATE

Turns out that the stack trace shows that it is having problems looking up the data source name and is actually throwing a JBO error. If anyone runs in to this, check the stack trace for other issues.

UPDATE2

Finally got this to write task comments into the custom comments table. It turns out it doesn't seem possible to use an AppModule/Model approach in a comments callback class as there appears no way to initiate the needed ADF context when the class is called. By rewriting the class to access the DB directly in code the comment callback class does write the table. But, I am getting the same error as this post. Namely:

Exception invoking method from XML data control. Cause:oracle.bpel.services.workflow.client.WorkflowServiceClientException: java.rmi.UnmarshalException: cannot unmarshaling return; nested exception is: 
Supplemental Detail java.io.IOException: Error: Unexpected type encountered in writeExternal oracle.bpel.services.workflow.client.WorkflowServiceClientException: java.rmi.UnmarshalException: cannot unmarshaling return; nested exception is: 
java.io.IOException: Error: Unexpected type encountered in writeExternal

I suspect this is an Oracle framework issue as the types that are passed back are from the NotesStore implementation which are all passed back to the framework:

public class CommentsCallback implements NotesStore, Serializable...

    public List<CommentType> getNotes(Task task)

Has anyone solved this? Full stacktrace at:

https://community.oracle.com/thread/3638940


Solution

  • After discussion with Oracle, the key to avoiding the unexpected type error is to use an ObjectFactory to populate the CommentType object. While we took a different approach ultimately, the below code was provided by Oracle as an example and might help someone trying to do this:

    import oracle.bpel.services.workflow.task.model.ObjectFactory; 
    import oracle.bpel.services.workflow.task.model.CommentType; 
    import oracle.bpel.services.workflow.task.model.IdentityType; 
    
    ...
    
    ObjectFactory factory = new ObjectFactory() 
    
    CommentType commentType = factory.createCommentType(); 
    
    IdentityType updatedBy = factory.createIdentityType(); 
    updatedBy.setId("some user"); 
    updatedBy.setType(IWorkflowConstants.IDENTITY_TYPE_USER); 
    updatedBy.setDisplayName("some user display name"); 
    
    commentType.setUpdatedBy(updatedBy); 
    commentType.setComment("some comment"); 
    
    ...set the rest of the comment fields as necessary...