title: Oracle BPM Human Task Comments Callback Errors When Instantiating AppModule in Called Class
body: <p>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.</p>
  
  <p>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. </p>
  
  <p>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.</p>
  
  <p>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:</p>
  
  <blockquote>
    <p>java.lang.ClassCastException: oracle.jbo.common.ampool.PoolMgr</p>
  </blockquote>
  
  <p>In the class, the AppModule is created as so:</p>
  
  <pre><code>AuditModule service = (AuditModule)Configuration.createRootApplicationModule("com.co.modules.AuditModule", "AuditModuleLocal");
  </code></pre>
  
  <p>I've tried adding a web.xml config file to the SCA BPM project with a filter as <a href="https://community.oracle.com/thread/2350800" rel="nofollow">discussed in this post</a> (last answer). This discusses triggering the ADF Context initialization, but I'm still getting the error. </p>
  
  <p>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? <a href="https://docs.oracle.com/cd/E23943_01/dev.1111/e10224/bp_hwfconf_shared.htm#SOASE87372" rel="nofollow">Oracle's documentation</a> is very sparse in this area (29.11.1).</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>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.</p>
  
  <p><strong>UPDATE2</strong></p>
  
  <p>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 <a href="https://community.oracle.com/thread/3577362" rel="nofollow">this post</a>. Namely:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>public class CommentsCallback implements NotesStore, Serializable...
  
      public List&lt;CommentType&gt; getNotes(Task task)
  </code></pre>
  
  <p>Has anyone solved this? Full stacktrace at: </p>
  
  <p><a href="https://community.oracle.com/thread/3638940" rel="nofollow">https://community.oracle.com/thread/3638940</a></p>