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.
Thanks,
hkho
Solved! Go to Solution.
these links should help:
http://help.adobe.com/en_US/livecycle/9.0/componentXMLRef/webframe.html
http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?content=001379.html
http://www.adobe.com/devnet/livecycle/articles/dsc_development.html
- 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.
Can you post your JAR file?
Views
Replies
Total Likes
Please download the jar file here:
http://www.sendspace.com/file/zgafgg
Here is the source code for the operation:
public com.adobe.idp.Document QueryFormData(long TaskId){
try{
//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,ServiceClientFactoryProperties.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)
{
System.out.println(e.getMessage());
return null;
}
}
Views
Replies
Total Likes
I still haven't solved the problem yet. Any help will be appericated. Thanks.
Views
Replies
Total Likes
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();
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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?
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
do you mean that i should put sth like:
<import-packages>
<package>com.adobe.idp.taskmanager.dsc.client</package>
<package>com.adobe.livecycle.usermanager.client</package>
</import-packages>
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?
thanks
Views
Replies
Total Likes
these links should help:
http://help.adobe.com/en_US/livecycle/9.0/componentXMLRef/webframe.html
http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?content=001379.html
http://www.adobe.com/devnet/livecycle/articles/dsc_development.html
- 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.
It works now after I added the import package tag. Thanks for your help.
Views
Replies
Total Likes
Thanks Jon! Four years later I know but I only ran into this issue now.
Carm
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies