It's all about the answers!

Ask a question

Parameters passed to a service are null


Rakesh Kukkamalla (5615) | asked Jul 08 '08, 1:10 p.m.
I have a service method which takes three parameters, a string, a UUID and a team area handle. I have set these values in the client library of the component and calling the service. But for some reason the UUID and team area handle that are passed to the service are null. I am pretty sure that they are set on the client side but at the service end they are null and I am getting a HTTP 400 error on the client side and a TeamServiceException thrown.

I am calling the service as a ProcessRunnable.

Any ideas why this is happening. I tried to fix it all evening yesterday but I couldnt find out why..

9 answers



permanent link
Jared Burns (4.5k29) | answered Jul 08 '08, 1:20 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You say you're "pretty sure" the values are being passed correctly from
your client. Have you checked this in the debugger?

Jared Burns
Jazz Process Team


rkukkama wrote:
I have a service method which takes three parameters, a string, a UUID
and a team area handle. I have set these values in the client library
of the component and calling the service. But for some reason the
UUID and team area handle that are passed to the service are null. I
am pretty sure that they are set on the client side but at the
service end they are null and I am getting a HTTP 400 error on the
client side and a TeamServiceException thrown.

I am calling the service as a ProcessRunnable.

Any ideas why this is happening. I tried to fix it all evening
yesterday but I couldnt find out why..

permanent link
Rakesh Kukkamalla (5615) | answered Jul 08 '08, 2:38 p.m.
Yes I checked it in the debugger. The team area handle is passed to the service. But at the service end its value is null. The other two parameters, string and UUID are fine. Its just the team area handle that is becoming null.

permanent link
Jared Burns (4.5k29) | answered Jul 08 '08, 4:13 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I haven't seen this kind of problem before. Can you share snippets of
your code? It might be helpful to see the snippet of your client where
you invoke the service method, the snippet of your service interface
where you declare the method, and the snippet of your service
implementation where you receive the parameters.

Jared Burns
Jazz Process Team


rkukkama wrote:
Yes I checked it in the debugger. The team area handle is passed to
the service. But at the service end its value is null. The other two
parameters, string and UUID are fine. Its just the team area handle
that is becoming null.

permanent link
Rakesh Kukkamalla (5615) | answered Jul 09 '08, 12:13 p.m.
<<Client>>

class AddReviewOperation extends ProcessRunnable {

Review review;

private NewReviewParameters params;

public AddReviewOperation(NewReviewParameters params) {
this.params = params;
}

public IOperationReport run(IProgressMonitor monitor)
throws TeamRepositoryException {


System.out.println("I am before review in runnable");


IItemsResponse itemsResponse = getService().postReview(params);

review = (Review)itemsResponse.getFirstClientItem();

return itemsResponse.getOperationReport();
}

}

final NewReviewParameters params = new NewReviewParameters();

params.description = description;
params.workItemID = workItemID;
params.teamArea = (ITeamArea)context.teamRepository().itemManager().fetchCompleteItem(teamAreaHandle, ItemManager.REFRESH, monitor);


AddReviewOperation runnable = new AddReviewOperation(params);

IProcessClientService processClientService = (IProcessClientService)
context.teamRepository().getClientLibrary(IProcessClientService.class);

processClientService.execute(
runnable, "Add Review Operation", monitor);

return runnable.review;

<<Common>>

IItemsResponse postReview(NewReviewParameters params)
throws TeamRepositoryException;

public static final class NewReviewParameters
implements IParameterWrapper {
public String description;
public UUID workItemID;
public ITeamArea teamArea;
}

<<Service>>

public IItemsResponse postReview(final NewReviewParameters params)
throws TeamRepositoryException {

final IRepositoryItemService repositoryItemService = getService(IRepositoryItemService.class);
IProcessServerService processServerService = getService(IProcessServerService.class);
IServerProcess serverProcess = processServerService.getServerProcess(params.teamArea);

final IItemsResponse itemsResponse = ProcessCommon.createItemsResponse();

AdvisableOperation addReviewOperation = new AdvisableOperation(OPERATION_ID_ADDREVIEW, params.description, params.teamArea) {

public IOperationReport run(IBehaviorConfiguration configuration,
IProgressMonitor monitor) throws TeamRepositoryException {
Review review = (Review) getReviewItemType().createItem();
review.setDescription(params.description);
review.setWorkItemID(params.workItemID);
review = (Review) repositoryItemService.saveItem(review);

itemsResponse.setClientItems(new Item[] {review});

return null;
}

public String[] getActions() throws TeamRepositoryException {
return new String[] { ACTION_ID_ADD };
}
};

IOperationReport operationReport = serverProcess.adviseAndExecute(addReviewOperation);

itemsResponse.setOperationReport(operationReport);

return itemsResponse;
}

permanent link
Jared Burns (4.5k29) | answered Jul 09 '08, 12:59 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi, Rakesh.

I believe the problem is that the object you're trying to pass over the
wire isn't marshallable. The Jazz client needs to turn the object into a
stream of bits and the Jazz server needs to turn those bits back into an
object.

If you want to pass a single object over the wire, I believe you would
need to model a DTO (data transfer object) using EMF.

But there's a simpler alternative. Jazz already knows how to marshall
strings and IItems, so you could just change the signature of your
service method to take three parameters - the description, work item id,
and team area. It would look something like this:

IItemsResponse postReview(String description, String workItemId,
ITeamArea teamArea)
throws TeamRepositoryException;

By the way, just based on the code you've shown here it looks like your
client is making an unnecessary round trip to fetch the full team area
item. You might want to also change your service interface to just take
a team area *handle*. If the server-side implementation needs the full
item for some reason, it's faster to fetch the item on the server than
it is to make clients fetch the item and then pass it back to the server.

Jared Burns
Jazz Process Team


rkukkama wrote:
Client

class AddReviewOperation extends ProcessRunnable {

Review review;

private NewReviewParameters params;

public AddReviewOperation(NewReviewParameters params) {
this.params = params;
}

public IOperationReport run(IProgressMonitor monitor)
throws TeamRepositoryException {


System.out.println("I am before review in runnable");


IItemsResponse itemsResponse = getService().postReview(params);

review = (Review)itemsResponse.getFirstClientItem();

return itemsResponse.getOperationReport();
}

}

final NewReviewParameters params = new NewReviewParameters();

params.description = description;
params.workItemID = workItemID;
params.teamArea =
(ITeamArea)context.teamRepository().itemManager().fetchCompleteItem(teamAreaHandle,
ItemManager.REFRESH, monitor);


AddReviewOperation runnable = new AddReviewOperation(params);

IProcessClientService processClientService =
(IProcessClientService)
context.teamRepository().getClientLibrary(IProcessClientService.class);

processClientService.execute(
runnable, "Add Review Operation", monitor);

return runnable.review;

<<Common>>

IItemsResponse postReview(NewReviewParameters params)
throws TeamRepositoryException;

public static final class NewReviewParameters
implements IParameterWrapper {
public String description;
public UUID workItemID;
public ITeamArea teamArea;
}

<<Service>>

public IItemsResponse postReview(final NewReviewParameters params)
throws TeamRepositoryException {

final IRepositoryItemService repositoryItemService =
getService(IRepositoryItemService.class);
IProcessServerService processServerService =
getService(IProcessServerService.class);
IServerProcess serverProcess =
processServerService.getServerProcess(params.teamArea);

final IItemsResponse itemsResponse =
ProcessCommon.createItemsResponse();

AdvisableOperation addReviewOperation = new
AdvisableOperation(OPERATION_ID_ADDREVIEW, params.description,
params.teamArea) {

public IOperationReport run(IBehaviorConfiguration configuration,
IProgressMonitor monitor) throws TeamRepositoryException {
Review review = (Review) getReviewItemType().createItem();
review.setDescription(params.description);
review.setWorkItemID(params.workItemID);
review = (Review) repositoryItemService.saveItem(review);

itemsResponse.setClientItems(new Item[] {review});

return null;
}

public String[] getActions() throws TeamRepositoryException {
return new String[] { ACTION_ID_ADD };
}
};

IOperationReport operationReport =
serverProcess.adviseAndExecute(addReviewOperation);

itemsResponse.setOperationReport(operationReport);

return itemsResponse;
}


permanent link
Rakesh Kukkamalla (5615) | answered Jul 09 '08, 1:39 p.m.
Thanks for your reply. I will change my service method signature and try to fix it. I was messing around and thats the reason I tried to send a team Area instead of a team area handle. I was initially sending a team area handle.

permanent link
Rakesh Kukkamalla (5615) | answered Jul 09 '08, 2:21 p.m.
I did what you asked me to do and its throwing me the following exception.

java.lang.RuntimeException: parameter to method should be an instance of IParameterWrapper

Previously i wrapped the parameters in a class that implemented the IParameterWrapper.Any ideas? My service implements ITeamModelledRestService. Did I miss anything here?

permanent link
Rakesh Kukkamalla (5615) | answered Jul 09 '08, 2:28 p.m.
Ok.. I figured out the issue. My service interface in common extends ITeamModelledRestService and this was causing problems. I removed it and it worked fine. But I still dont know why this happened. Can you please explain it?

permanent link
Jared Burns (4.5k29) | answered Jul 09 '08, 2:32 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Not exactly sure, but this sounds like something wasn't quite updated.

I'd make sure you've updated your client, common, and service plugins.
Make sure you're running the updated common plugin on both the client
and server. And make sure to restart both the client and server so
they're running what you think they are.

Jared Burns
Jazz Process Team


rkukkama wrote:
I did what you asked me to do and its throwing me the following
exception.

java.lang.RuntimeException: parameter to method should be an instance
of IParameterWrapper

Previously i wrapped the parameters in a class that implemented the
IParameterWrapper.Any ideas? My service implements
ITeamModelledRestService. Did I miss anything here?

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.