It's all about the answers!

Ask a question

getService(Class) throws java.lang.IllegalArgumentException:


Jagadish R Rao (10612111) | asked Jan 12 '10, 2:02 a.m.
Hi

I am trying to modify the properties of another workitem when save is invoked by code looks like this

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import com.ibm.team.process.common.IProcessConfigurationElement;
import com.ibm.team.process.common.advice.AdvisableOperation;
import com.ibm.team.process.common.advice.IAdvisorInfoCollector;
import com.ibm.team.process.common.advice.runtime.IOperationAdvisor;
import com.ibm.team.repository.common.IAuditable;
import com.ibm.team.repository.common.TeamRepositoryException;
import com.ibm.team.repository.service.AbstractService;
import com.ibm.team.workitem.common.ISaveParameter;
import com.ibm.team.workitem.common.model.IComment;
import com.ibm.team.workitem.common.model.IWorkItem;
import com.ibm.team.workitem.service.IWorkItemServer;

public class WorkItemSyncServer extends AbstractService implements IOperationAdvisor {

public boolean isCopiedWorkItem=false;
public String sWID="";
public int sourceWorkItemID=-1;

@SuppressWarnings("deprecation")
public void run(AdvisableOperation operation,
IProcessConfigurationElement advisorConfiguration,
IAdvisorInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException {
// TODO Auto-generated method stub
Object data= operation.getOperationData();
if (data instanceof ISaveParameter)
{
IAuditable auditable= ((ISaveParameter)data).getNewState();
if (auditable instanceof IWorkItem) {
IWorkItem sourceworkItem=(IWorkItem) auditable;
try{
IComment sourceComments[]=sourceworkItem.getComments().getContents();
if (sourceComments.length>0)
isCopiedWorkItem=searchForWorkItemID(sourceComments);
}
catch (Exception e){
isCopiedWorkItem=false;
e.printStackTrace();
}
if (isCopiedWorkItem){
// Search the source work Item and Modify the contents
IWorkItemServer itemServer=getService(com.ibm.team.workitem.service.IWorkItemServer.class);
IWorkItem itemCopy=(IWorkItem)itemServer.findWorkItemById(sourceWorkItemID, IWorkItem.FULL_PROFILE, null).getWorkingCopy();
//modify attributes
itemCopy.setState2(sourceworkItem.getState2());
IStatus result= itemServer.saveWorkItem2(itemCopy, null, null);
if (!result.isOK()) {
// deal with errors
System.out.println("Save Work Item 2 failed ....");
}
}
}
}
}
}

When I try to save a work item after getting the ID it throws :
java.lang.IllegalArgumentException: The service 'com.ibm.team.workitem.save.WorkItemSyncServer@38803880' failed to find the required service 'interface com.ibm.team.workitem.service.IWorkItemServer'. Check <prerequisites> in plugin.xml.
at com.ibm.team.repository.service.AbstractService.getService(AbstractService.java:569)
at com.ibm.team.workitem.save.WorkItemSyncServer.run(WorkItemSyncServer.java:80)
at com.ibm.team.process.internal.common.advice.runtime.OperationAdviceManager.runAdvisor(OperationAdviceManager.java:1118)
at com.ibm.team.process.internal.common.advice.runtime.OperationAdviceManager.runAdvisors(OperationAdviceManager.java:819)
at com.ibm.team.process.internal.common.advice.runtime.OperationAdviceManager.advise(OperationAdviceManager.java:273)
at com.ibm.team.process.internal.common.util.AbstractProcess.doAdvise(AbstractProcess.java:181)
at com.ibm.team.process.internal.service.ServerProcess.access$1(ServerProcess.java:1)
at com.ibm.team.process.internal.service.ServerProcess$2.run(ServerProcess.java:130)
at com.ibm.team.repository.service.internal.TransactionService$1.run(TransactionService.java:99)
at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase.runTransaction(RepositoryDatabase.java:320)
at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase.runInTransaction(RepositoryDatabase.java:244)
at com.ibm.team.repository.service.internal.TransactionService.runInTransaction(TransactionService.java:74)
at com.ibm.team.repository.service.internal.TransactionService.runInTransaction(TransactionService.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:370)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:356)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
at $Proxy44.runInTransaction(Unknown Source)
at com.ibm.team.process.internal.service.ProcessService.runInTransaction(ProcessService.java:3346)
at com.ibm.team.process.internal.service.ProcessService.runInTransaction(ProcessService.java:3353)
at com.ibm.team.process.internal.service.ServerProcess.adviseAndExecute(ServerProcess.java:128)
at com.ibm.team.workitem.service.internal.AuditableServerProcess.adviseAndExecute(AuditableServerProcess.java:80)
at com.ibm.team.workitem.service.internal.WorkItemRepositoryService.processSave(WorkItemRepositoryService.java:400)
....

Any help would be great ...

3 answers



permanent link
Jagadish R Rao (10612111) | answered Jan 12 '10, 2:10 a.m.
Hi

I forgot to add the plugin.xml looks as follows

<plugin>
<extension>
<operationAdvisor>
<description>
This is used for synchronizing two work items for its state and comments within the same server repository
</description>
</operationAdvisor>
</extension>
<prerequisites>
<requiredService>
</prerequisites>
</plugin>

not sure if the prerequsites tag is correctly mentioned

Thx & Regds
Jagadish

Hi

I am trying to modify the properties of another workitem when save is invoked by code looks like this

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import com.ibm.team.process.common.IProcessConfigurationElement;
import com.ibm.team.process.common.advice.AdvisableOperation;
import com.ibm.team.process.common.advice.IAdvisorInfoCollector;
import com.ibm.team.process.common.advice.runtime.IOperationAdvisor;
import com.ibm.team.repository.common.IAuditable;
import com.ibm.team.repository.common.TeamRepositoryException;
import com.ibm.team.repository.service.AbstractService;
import com.ibm.team.workitem.common.ISaveParameter;
import com.ibm.team.workitem.common.model.IComment;
import com.ibm.team.workitem.common.model.IWorkItem;
import com.ibm.team.workitem.service.IWorkItemServer;

public class WorkItemSyncServer extends AbstractService implements IOperationAdvisor {

public boolean isCopiedWorkItem=false;
public String sWID="";
public int sourceWorkItemID=-1;

@SuppressWarnings("deprecation")
public void run(AdvisableOperation operation,
IProcessConfigurationElement advisorConfiguration,
IAdvisorInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException {
// TODO Auto-generated method stub
Object data= operation.getOperationData();
if (data instanceof ISaveParameter)
{
IAuditable auditable= ((ISaveParameter)data).getNewState();
if (auditable instanceof IWorkItem) {
IWorkItem sourceworkItem=(IWorkItem) auditable;
try{
IComment sourceComments[]=sourceworkItem.getComments().getContents();
if (sourceComments.length>0)
isCopiedWorkItem=searchForWorkItemID(sourceComments);
}
catch (Exception e){
isCopiedWorkItem=false;
e.printStackTrace();
}
if (isCopiedWorkItem){
// Search the source work Item and Modify the contents
IWorkItemServer itemServer=getService(com.ibm.team.workitem.service.IWorkItemServer.class);
IWorkItem itemCopy=(IWorkItem)itemServer.findWorkItemById(sourceWorkItemID, IWorkItem.FULL_PROFILE, null).getWorkingCopy();
//modify attributes
itemCopy.setState2(sourceworkItem.getState2());
IStatus result= itemServer.saveWorkItem2(itemCopy, null, null);
if (!result.isOK()) {
// deal with errors
System.out.println("Save Work Item 2 failed ....");
}
}
}
}
}
}

When I try to save a work item after getting the ID it throws :
java.lang.IllegalArgumentException: The service 'com.ibm.team.workitem.save.WorkItemSyncServer@38803880' failed to find the required service 'interface com.ibm.team.workitem.service.IWorkItemServer'. Check <prerequisites> in plugin.xml.
at com.ibm.team.repository.service.AbstractService.getService(AbstractService.java:569)
at com.ibm.team.workitem.save.WorkItemSyncServer.run(WorkItemSyncServer.java:80)
at com.ibm.team.process.internal.common.advice.runtime.OperationAdviceManager.runAdvisor(OperationAdviceManager.java:1118)
at com.ibm.team.process.internal.common.advice.runtime.OperationAdviceManager.runAdvisors(OperationAdviceManager.java:819)
at com.ibm.team.process.internal.common.advice.runtime.OperationAdviceManager.advise(OperationAdviceManager.java:273)
at com.ibm.team.process.internal.common.util.AbstractProcess.doAdvise(AbstractProcess.java:181)
at com.ibm.team.process.internal.service.ServerProcess.access$1(ServerProcess.java:1)
at com.ibm.team.process.internal.service.ServerProcess$2.run(ServerProcess.java:130)
at com.ibm.team.repository.service.internal.TransactionService$1.run(TransactionService.java:99)
at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase.runTransaction(RepositoryDatabase.java:320)
at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase.runInTransaction(RepositoryDatabase.java:244)
at com.ibm.team.repository.service.internal.TransactionService.runInTransaction(TransactionService.java:74)
at com.ibm.team.repository.service.internal.TransactionService.runInTransaction(TransactionService.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:370)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:356)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
at $Proxy44.runInTransaction(Unknown Source)
at com.ibm.team.process.internal.service.ProcessService.runInTransaction(ProcessService.java:3346)
at com.ibm.team.process.internal.service.ProcessService.runInTransaction(ProcessService.java:3353)
at com.ibm.team.process.internal.service.ServerProcess.adviseAndExecute(ServerProcess.java:128)
at com.ibm.team.workitem.service.internal.AuditableServerProcess.adviseAndExecute(AuditableServerProcess.java:80)
at com.ibm.team.workitem.service.internal.WorkItemRepositoryService.processSave(WorkItemRepositoryService.java:400)
....

Any help would be great ...

permanent link
Patrick Streule (4.9k21) | answered Jan 12 '10, 4:53 a.m.
JAZZ DEVELOPER
I forgot to add the plugin.xml looks as follows

plugin
extension
operationAdvisor
description
This is used for synchronizing two work items for its
state and comments within the same server repository
/description
/operationAdvisor
/extension
prerequisites
<requiredService
</prerequisites
/plugin

not sure if the prerequsites tag is correctly mentioned

You need to declare the dependencies of your implementation:

<operationAdvisor>
<description>
...
</description>
<extensionService>
<prerequisites>
<requiredService>
<requiredService>
</prerequisites>
</extensionService>
</operationAdvisor>


--
Regards,
Patrick
Jazz Work Item Team

permanent link
Jagadish R Rao (10612111) | answered Jan 12 '10, 6:15 a.m.
Hi Patrick,

Thanks for the reply .. I fixed the plugin.xml and it is working fine now

Thanks & Regds
Jagadish

I forgot to add the plugin.xml looks as follows

plugin
extension
operationAdvisor
description
This is used for synchronizing two work items for its
state and comments within the same server repository
/description
/operationAdvisor
/extension
prerequisites
<requiredService
</prerequisites
/plugin

not sure if the prerequsites tag is correctly mentioned

You need to declare the dependencies of your implementation:

<operationAdvisor>
<description>
...
</description>
<extensionService>
<prerequisites>
<requiredService>
<requiredService>
</prerequisites>
</extensionService>
</operationAdvisor>


--
Regards,
Patrick
Jazz Work Item Team

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.