ここで多くの例を読みましたが、コーディングの間違いを特定することはまだできません。組み込みのジャージー クライアント MessageBodyReaders を使用しようとしています。
私のポジョは次のようになります。
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {"name", "complexId", "libraryList", "partitionList", "nextLinks"})
@XmlRootElement(name = "LibraryComplex")
public class YapiLibraryComplex
{
@XmlTransient LibraryComplex libComplex;
String name;
int complexId;
List<Integer> libraryList;
List<String> partitionList;
List<URI> nextLinks;
.
.
.
私のサービスは次のようになります。
@Path ("/")
public class YAPIWebService
{
@Context Application yapiAppl;
@Context UriInfo uriInfo;
@GET
@Produces ("application/xml")
//@Produces ("MediaType.APPLICATION_XML")
public Response getLibraryComplex()
{
LibraryComplex libComplex = (((YAPIapplication) yapiAppl).getLibComplex());
YapiLibraryComplex yapiLibPlex;
.
.
.
return Response.ok(yapiLibPlex).build();
そして私のクライアント:
public static void main(String[] args)
{ //client client = new client();
System.out.println("the beginning");
//ClientConfig cc = new DefaultClientConfig();
//cc.getClasses().add(com.sun.jersey.api.core.);
//Client c = Client.create(cc);
Client c = Client.create();
WebResource rsrc = c.resource("http://localhost:7101/");
//ClientResponse response = rsrc.get(ClientResponse.class);
ClientResponse response = rsrc.accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
YapiLibraryComplex libPlex = response.getEntity(YapiLibraryComplex.class);
System.out.println("the libPlex object is " + libPlex.toString());
String entityBody = response.getEntity(String.class);
System.out.println("the response as a string is " + entityBody);
System.out.println("the status is " + response.getStatus());
System.out.println("the links are " + response.getLinks());
System.out.println("the end");
}
}
そして私のスタックトレース:
始まり
2012 年 7 月 25 日 6:47:22 PM com.sun.jersey.core.impl.provider.xml.SAXParserContextProvider getInstance 警告: JAXP 機能 XMLConstants.FEATURE_SECURE_PROCESSING を SAXParserFactory に設定することはできません。外部の一般エンティティの処理は無効になっていますが、その他の潜在的なセキュリティ関連機能は有効になりません。org.xml.sax.SAXNotRecognizedException: http://javax.xml.XMLConstants/feature/secure-processing at oracle.xml.jaxp.JXSAXParserFactory.setFeature(JXSAXParserFactory.java:129)
at com.sun.jersey.core.impl.provider.xml.SAXParserContextProvider.getInstance(SAXParserContextProvider.java:80)
at com.sun.jersey.core.impl.provider.xml.SAXParserContextProvider.getInstance(SAXParserContextProvider.java:54)
at com.sun.jersey.core.impl.provider.xml.ThreadLocalSingletonContextProvider$1.initialValue(ThreadLocalSingletonContextProvider.java:64)
at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:141)
at java.lang.ThreadLocal.get(ThreadLocal.java:131)
at com.sun.jersey.core.impl.provider.xml.ThreadLocalSingletonContextProvider$2.getValue(ThreadLocalSingletonContextProvider.java:77)
at com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider.readFrom(XMLRootElementProvider.java:113)
at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(AbstractRootElementProvider.java:111)
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:554)
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:506)
at .tape.acs.yapi.smokeTest.main(smokeTest.java:32) Exception in thread "main" javax.ws.rs.WebApplicationException: javax.xml.bind.JAXBException: Error creating SAXSource - with linked exception: [org.xml.sax.SAXNotSupportedException: SAX feature 'http://xml.org/sax/features/external-general-entities' not supported.]
at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(AbstractRootElementProvider.java:115)
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:554)
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:506)
at .tape.acs.yapi.smokeTest.main(smokeTest.java:32) Caused by: javax.xml.bind.JAXBException: Error creating SAXSource - with linked exception:[org.xml.sax.SAXNotSupportedException: SAX feature 'http://xml.org/sax/features/external-general-entities' not supported.]
at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getSAXSource(AbstractJAXBProvider.java:205)
at com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider.readFrom(XMLRootElementProvider.java:113)
at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(AbstractRootElementProvider.java:111)
... 3 more Caused by: org.xml.sax.SAXNotSupportedException: SAX feature 'http://xml.org/sax/features/external-general-entities' not supported.
at oracle.xml.parser.v2.NonValidatingParser.setFeature(NonValidatingParser.java:1975)
at oracle.xml.parser.v2.SAXParser.setFeature(SAXParser.java:270)
at oracle.xml.jaxp.JXSAXParserFactory.newSAXParser(JXSAXParserFactory.java:92)
at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getSAXSource(AbstractJAXBProvider.java:201)
... 5 more Process exited with exit code 1.