You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Karl M. Davis (JIRA)" <ji...@apache.org> on 2014/08/31 18:38:20 UTC

[jira] [Created] (CXF-5980) JAX-RS 2.0 client: response.readEntity(new GenericType<...>{}) fails with "unexpected element" UnmarshalException

Karl M. Davis created CXF-5980:
----------------------------------

             Summary: JAX-RS 2.0 client: response.readEntity(new GenericType<...>{}) fails with "unexpected element" UnmarshalException
                 Key: CXF-5980
                 URL: https://issues.apache.org/jira/browse/CXF-5980
             Project: CXF
          Issue Type: Bug
          Components: JAX-RS
    Affects Versions: 3.0.1
         Environment: Ubuntu 14.04, Oracle Java 7
            Reporter: Karl M. Davis


The following code fails:

{code:Java}
public List<GameSession> getGamesForPlayer() {
	Client client = ClientBuilder.newClient();
	Builder requestBuilder = client.target(config.getServiceRoot())
			.path(IGameSessionResource.SERVICE_PATH)
				.path(IGameSessionResource.SERVICE_PATH_GAMES_FOR_PLAYER)
			.request(MediaType.TEXT_XML_TYPE);
	cookieStore.applyCookies(requestBuilder);

	Response response = requestBuilder.get();
	if (Status.Family.familyOf(response.getStatus()) != Status.Family.SUCCESSFUL)
		throw new HttpClientException(response.getStatusInfo());

	List<GameSession> games = response.readEntity(
			new GenericType<List<GameSession>>(GameSession.class) {});
	cookieStore.remember(response.getCookies());

	return games;
}
{code}

With the following root exception (I'll attach the full log out/stack tracce so you can see where in CXF this is coming from):
{code}
javax.xml.bind.UnmarshalException: unexpected element (uri:"http://justdavis.com/karl/rpstourney/api/schema/v1", local:"gameSessions"). Expected elements are <{http://justdavis.com/karl/rpstourney/api/schema/v1}account>,<{http://justdavis.com/karl/rpstourney/api/schema/v1}gameRound>,<{http://justdavis.com/karl/rpstourney/api/schema/v1}gameSession>,<{http://justdavis.com/karl/rpstourney/api/schema/v1}player>
	... 93 common frames omitted
{code}

This is the first time I've tried to pull a generic/collection object out of a Response using CXF's JAX-RS 2.0 client, so my guess is that this is just an unsupported edge case? For what it's worth, the server-side of the web service being queried is hosted by the same version of CSF and handles this just fine-- only the client seems to have issues.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)