It's all about the answers!

Ask a question

NPE while trying to retrieve a work item

Kamal Suruguchi (1512114) | asked May 27 '11, 2:48 a.m.
When I try to retrieve an RTC work item, I get an NPE. The code is as follows (in doGet() of my RestService):

// Get credentials from request
Map<String> params = RequestParams.getParameterMap(request.getParams());
String workItemId = HttpRequestUtil.getFirstNonNullParamValue(params, "workitem");

// Initialize HTTP client, if not done yet
if (httpClient == null) {
httpClient = new JazzHttpClient();
defaultHttpContext = httpClient.createDefaultHttpContext();

//Create a functional user context
OAuthContextUtil.setOAuthAccessToken(defaultHttpContext,new OAuthAccessToken(HttpConstants.EMPTY, HttpConstants.EMPTY));
BootstrapConfig config = BootstrapConfig.getInstance();
OAuthContextUtil.setOAuthConsumerProperties(defaultHttpContext, config.getOAuthConsumerProperties());

HttpResponse jfsResponse = null;
try {
String uri = "https://localhost:9443/ccm/resource/"+workItemId;
HttpGet getCurrentUserRequest = new HttpGet(uri);
getCurrentUserRequest.addHeader(HttpConstants.ACCEPT, HttpConstants.CT_APPLICATION_RDF_XML);
jfsResponse = httpClient.execute(getCurrentUserRequest, defaultHttpContext);
//Parse the work item representation
RDFEntity entity = new RDFEntity(jfsResponse.getEntity());
Model model = entity.getModel();
if(model != null){
Resource res = model.getResource(uri);
if (res != null) {

} catch (OAuthInvalidOrExpiredTokenException e) {
response.setEntity(new StringEntity("invalid username or password"));
} catch (Exception e) {
response.setEntity(new StringEntity(e.getMessage()));

During the execution of
RDFEntity entity = new RDFEntity(jfsResponse.getEntity());

I get the following NPE. Can someone help me what's wrong here? When I execute the same query in my browser, I can see the work item details in html format (though I am not sure why it is shown in html and not in RDF).

Also, I am not able to use discovery mechanism for discovering work items because of an existing defect in RTC. Please see

at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(

Be the first one to answer this question!

Register or to post your answer.