users@jersey.java.net

Re: [Jersey] XmlRootElement not added to generated java sources

From: vaidya nathan <vaidyaatdst_at_gmail.com>
Date: Tue, 25 Aug 2009 15:49:59 -0500

On Tue, Aug 25, 2009 at 2:38 PM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:

>
> On Aug 25, 2009, at 7:14 PM, vaidya nathan wrote:
>
> This is a two part question
>>
>> First part(I)
>> ==========
>> How are these two way different?
>> 1. <xs:element name="elemname" type="tns:elem_type" />
>> <xs:complexType name="elem_type">
>> <xs:sequence>
>> <xs:element name="elem1" type="ns1:elem1_type"/>
>> </xs:sequence>
>> </xs:complexType>
>>
>> 2. <xs:element name="element">
>> <xs:complexType>
>> <xs:sequence>
>> <xs:element name="comment" type="xs:string" maxOccurs="unbounded"/>
>> </xs:sequence>
>> </xs:complexType>
>> </xs:element>
>>
>> The second one is generating the @XmlRootElement(name = "comments")
>> whereas the first one is not when it goes through xjc .Any idea ? Is there a
>> way to specify the element to be root in the schema? Is xjc program the
>> culprit(I have tried with both the maven plugin and the xjc.bat way of
>> generating the java classes)
>>
>
> It is probably an xjc thing, i am not an expert on it so i recommend you
> email users_at_jaxb.dev.java.net.
>
>
>
>> =======================================================================================
>> The second part is as follows.(II)
>>
>> When I try to use the jersey client wrapper and have the request to
>> be one without the XmlRootElement (I way)
>> clientResponse =
>> createWebResource().accept(contentType).post(ClientResponse.class, request);
>>
>>
> What is the type of "request" ?

*The request is an object of generated elemname (generated from xjc). I will
mail to that group.*

>
>
>
> I get the following error message
>> com.sun.jersey.api.client.ClientHandlerException:
>> java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
>> at
>> com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:128)
>> at com.sun.jersey.api.client.Client.handle(Client.java:397)
>> at com.sun.jersey.api.client.WebResource.handle(WebResource.java:557)
>>
>
> Is there more to the exception, like the cause of the
> ClientHandlerException?
>

This is the full exception.
com.sun.jersey.api.client.ClientHandlerException:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
 at
com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:128)
 at com.sun.jersey.api.client.Client.handle(Client.java:397)
 at com.sun.jersey.api.client.WebResource.handle(WebResource.java:557)
 at com.sun.jersey.api.client.WebResource.access$300(WebResource.java:69)
    at
com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:499)
 at
jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown
Source)
 at
java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown
Source)
 at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
 at
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
 at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
 at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
 at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
 at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
 at
org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
 at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
 at
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
 at
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
 at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
 at
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
 at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
 at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
 at java.util.ArrayList.RangeCheck(ArrayList.java:546)
 at java.util.ArrayList.get(ArrayList.java:321)
 at
com.sun.jersey.api.client.TerminatingClientHandler.writeRequestEntity(TerminatingClientHandler.java:293)
 at
com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:179)
 at
com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:126)
 at com.sun.jersey.api.client.Client.handle(Client.java:397)
 at com.sun.jersey.api.client.WebResource.handle(WebResource.java:557)
 at com.sun.jersey.api.client.WebResource.access$300(WebResource.java:69)
 at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:499)
 at
jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown
Source)
 at
java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown
Source)
 at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
 at
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
 at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
 at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
 at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
 at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
 at
org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
 at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
 at
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
 at
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
 at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
 at
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
 at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
 at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)


>
> What version of Jersey?


1.0.3 - both jersey and jersey-client

<dependency>

<groupId>*com*.sun.jersey</groupId>

<artifactId>jersey-client</artifactId>

<version>1.0.3</version>

</dependency>



>
>
>
>
>> Can jersey client only send root elements @XmlRootElement?
>>
>>
> Or instance of JAXBElement i.e. JAXB artifacts that declare an XML root
> element.
>
> But it is not clear to me what the above error is (need to see the checked
> exception), perhaps it could be related to serializing of the "request"
> instance.
>



>
> Paul.
>
>
> Regards
>>
>>
>>
>> Regards
>
>

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>