Harish Kayarohanam
Harish Kayarohanam

Reputation: 4014

Resteasy throws exception at getEntity() method

My server code is as follows (it uses resteasy). Response came from my nexus oss app which uses restlet. This response is being processed by the following method which throws exception

private <T> T get(String path, Class<T> responseClass) throws IntegratedAppFault {

    ClientRequest clientRequest = new ClientRequest(this.mEndPoint + path);
    addHeaderToRequest(clientRequest);
    ClientResponse<T> response;
    try {
        response = clientRequest.get(responseClass);
        if (response.getStatus() == 200) {
            return response.getEntity(); // Line throwing exception 
        } else {
            throw getFault(response);
        }
    } catch (Exception e) {
        throw new IntegratedAppFault(e.getMessage());
    }

When the server receives the exception, it comes into this method and finally throws exception at response.getEntity(). The exception is as follows

javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"com.collabnet.teamforge.ia.types.GetConfigurationParametersResponse"). Expected elements are <{http://www.collab.net/teamforge/integratedapp}CreateProjectConfigurationRequest>,<{http://www.collab.net/teamforge/integratedapp}CreateTemplateRequest>,<{http://www.collab.net/teamforge/integratedapp}CreateTemplatizedProjectConfigurationRequest>,<{http://www.collab.net/teamforge/integratedapp}CreateUserRequest>,<{http://www.collab.net/teamforge/integratedapp}DeleteProjectConfigurationRequest>,<{http://www.collab.net/teamforge/integratedapp}DetailedSCMPostCommitRequest>,<{http://www.collab.net/teamforge/integratedapp}DetailedSCMPreCommitRequest>,<{http://www.collab.net/teamforge/integratedapp}DetailedSCMPreCommitResponse>,<{http://www.collab.net/teamforge/integratedapp}EditProjectConfigurationRequest>,<{http://www.collab.net/teamforge/integratedapp}GetConfigurationParametersRequest>,<{http://www.collab.net/teamforge/integratedapp}GetConfigurationParametersResponse>

I browsed through code found that this method getEntity method in RESTEasy source at bit.ly/1ed06bS. But don't have any clue why this is throwing exception.

I just did a comparison of the objects values for a correctly working scenario(that which doesn't throw exception) and wrongly working scenario (this scenario mentioned above) and found no difference in the object values.

I will attach the debug log . The first column is correctly working scenario and the second column is wrongly working scenario. The pdf is here http://www.scribd.com/doc/157390722/Debug

Can you please help me out in finding why this line throws exception

Upvotes: 0

Views: 552

Answers (1)

gregwhitaker
gregwhitaker

Reputation: 13410

Based on the exception you are receiving, JAXB is expecting your request xml to begin with one of the following tags and it does not.

  1. CreateProjectConfigurationRequest
  2. CreateTemplateRequest
  3. CreateTemplatizedProjectConfigurationRequest
  4. CreateUserRequest
  5. DeleteProjectConfigurationRequest
  6. DetailedSCMPostCommitRequest
  7. DetailedSCMPostCommitResponse
  8. DetailedSCMPreCommitRequest
  9. DetailedSCMPreCommitResponse
  10. EditProjectConfigurationRequest
  11. GetConfigurationParametersRequest
  12. GetConfigurationParametersResponse

Upvotes: 1

Related Questions