11 Replies Latest reply on Jul 23, 2015 2:30 PM by cscaffidi@sympatico.ca

    Use custom component to retrieve form data

    hkho Level 1

      Hi, I am creating a custom component that can retrieve form data for a task, when I run the component in workflow, it throws an exception:


      "com.adobe.idp.taskmanager.dsc.client.task.TaskImpl cannot be cast to com.adobe.idp.taskmanager.dsc.client.task.TaskInfo"


      at the line:


      "TaskInfo tinfo = taskManager.getTaskInfo(taskId);"


      If i put the same code on a java console app to test it, it works fine.


      I've tried to googled it but nothing come up for TaskImpl.




        • 1. Re: Use custom component to retrieve form data
          $Nith$ Level 4

          Can you post your JAR file?

          • 2. Re: Use custom component to retrieve form data
            hkho Level 1

            Please download the jar file here:



            Here is the source code for the operation:


            public com.adobe.idp.Document QueryFormData(long TaskId){
                        //Set connection properties required to invoke LiveCycle ES2                                                                                                                       
                         Properties connectionProps = new Properties();
                         connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, "jnp://localhost:1099");
                         connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,Service ClientFactoryProperties.DSC_EJB_PROTOCOL);         
                         connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
                         connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
                         connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
                       //Create a ServiceClientFactory object
                       ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);


                       //Create a TaskManager object
                       TaskManager myTaskManager = TaskManagerClientFactory.getTaskManager(myFactory);   
                       TaskInfo tInfo = myTaskManager.getTaskInfo(TaskId);
                       //Retrieve the form instance associated with task
                       FormInstance[] fi = tInfo.getTaskItems();
                       long formInstanceId = fi[0].getFormInstanceId();
                       FormInstance newfi = myTaskManager.getFormInstanceForTask(TaskId, formInstanceId, true);
                       //Get data located in the form
                       Document doc = newfi.getDocument();

                       return doc;
                   catch(Exception e)
                       return null;



            • 3. Re: Use custom component to retrieve form data
              hkho Level 1

              I still haven't solved the problem yet. Any help will be appericated. Thanks.

              • 4. Re: Use custom component to retrieve form data
                Jon Bionda Level 3

                Strange since TaskInfo is the interface implemented by TaskImpl.  Must be something else going on.


                Ignoring that for a moment, it might be easier to try skip getting the TaskInfo since you don't need it.  Try this:


                     FormInstance formInstance = myTaskManager.getFormInstanceForTask(tid, 0); // formId is 0

                     Document doc = formInstance.getDocument();









                • 5. Re: Use custom component to retrieve form data
                  hkho Level 1

                  Thx for the reply, but after I changed the code, it throw another exception:


                  "java.lang.ClassCastException: com.adobe.idp.taskmanager.dsc.client.task.FormInstanceImpl cannot be cast to com.adobe.idp.taskmanager.dsc.client.task.FormInstance"


                  that's strange, seems it can't cast the implemented class to the interface class.

                  • 6. Re: Use custom component to retrieve form data
                    hkho Level 1

                    I just tried to use queryManager to do a task search and it can return the List of task, I checked the result.size() is right, but when I get the details of the task:


                    List result = queryManager.taskSearch(filter);

                    int count = result.size(); // this line is right and return the correct number of tasks

                    TaskRow tr = (TaskRow) result.get(0); // this line throws exception


                    it throws similar exception:


                    "com.adobe.idp.taskmanager.dsc.client.query.TaskRowImpl cannot be cast to com.adobe.idp.taskmanager.dsc.client.query.TaskRow"


                    seems all implementations cannot cast to interface, is there anything i missed, anything i need to do before the class can be casted to interface?

                    • 7. Re: Use custom component to retrieve form data
                      Jon Bionda Level 3

                      I just looked in the dsc (jar) you posted and it is likely the cause.  you are including taskmanager client and usermanager client jars in your classpath.  The classes in these jars are exported from the the taskmanager and usermanager dscs so in order to get them loaded by the same class loader you need to import (use <import-package> tags) them in your component.xml and remove them from the classpath.


                      Also, because you are writing a dsc to call another dsc, you don't need to use the ejb protocol to call it.  If you just create an instance of the serviceclientfactory, it should be go.

                      • 8. Re: Use custom component to retrieve form data
                        hkho Level 1

                        do you mean that i should put sth like:






                        and remove the class-path tag from component.xml or i just need to remove adobe-taskmanager-client.jar and adobe-usermanager-client.jar?

                        <class-path>lib/adobe-livecycle-client.jar lib/adobe-taskmanager-client.jar lib/adobe-usermanager-client.jar lib/adobe-utilities.jar lib/adobe-workflow-client-sdk.jar lib/commons-codec-1.3.jar lib/jbossall-client.jar</class-path>


                        and i am not sure about the ejb protocol? do you mean i need to remove the line:

                        connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSP ORT_PROTOCOL,ServiceClientFactoryProperties.DSC_EJB_PROTOCOL);


                        or i just use

                        ServiceClientFactory myFactory = ServiceClientFactory.createInstance();

                        and no need to set the connection properties?



                        • 9. Re: Use custom component to retrieve form data
                          Jon Bionda Level 3

                          these links should help:








                          - note that for the import-packages, it must be explicit.  specifying <package>a.b.c</package> will not import classes in a.b.c.d.


                          - for any classes you import, you cannot have the jar in the component.xml classpath and do not want it in included in your components jar.


                          - if you use ServiceClientFactory.createInstance() without a context, then you will get the current context.  Who this is depends on how your service operation is invoked.  I direct invocation by a user will be have the user context.  If invoked by the workflow engine as part of a long-lived process then it will be run as a system context.  Since you are calling TaskManager to get the data for a task, access rights will apply so you need to be aware of the context.  The system context has full access rights so it can get the desired results.  But if running under a calling user's context, that user must be the owner of the task or the request will fail.

                          • 10. Re: Use custom component to retrieve form data
                            hkho Level 1

                            It works now after I added the import package tag. Thanks for your help.

                            • 11. Re: Use custom component to retrieve form data

                              Thanks Jon! Four years later I know but I only ran into this issue now.