I have created a trivial JAXB Provider:

  @Provider
    @Consumes(MediaType.APPLICATION_XML)
    @Produces(MediaType.APPLICATION_XML)
    public class TrivialJaxbProvider implements MessageBodyReader<Object> {

        @Override
        public boolean isReadable(Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType) {

            return true;
        }

        @Override
        public Object readFrom(Class<Object> type, Type genericType,
Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,
String> httpHeaders,
                InputStream entityStream) throws IOException,
WebApplicationException {
            try {
                return
JAXBContext.newInstance(type).createUnmarshaller().unmarshal(entityStream);
            } catch (JAXBException e) {
                   throw new WebApplicationException(e);
            }
        }

    }

and used it for this test. It worked fine with 750 threads.
So it seems that the bug is in a JAXB Provider.

I'll try to find some time to look into it. Anyway, meanwhile you can use
your own JAXB provider and it should work.

On Fri, Dec 9, 2011 at 8:36 AM, Kumar, Munirathnam <[email protected]
> wrote:

> Test Scenario****
>
> Methodology****
>
> Status****
>
> No of threads used : 1000****
>
> Java SDK : 1.5****
>
> OS : Windows****
>
> JAXB on Server: jaxb 2.2****
>
> Wink : 1.3 ****
>
> ** **
>
> XML String : "<UserSubscription>"****
>
>             +       "<selectedOptions><entry><key >Amount of Memory
> (MB)</key><value >2000</value></entry>" +****
>
>                                    "<entry><key>Number of
> CPUs</key><value>1</value></entry>" +****
>
>                                    "<entry><key>Number of
> Servers</key><value>1</value></entry>"****
>
>             +      "</selectedOptions>"****
>
>             +   "</UserSubscription>";****
>
> ** **
>
> Jaxb****
>
> Version : 2.2****
>
> JAXB Components jars were tested for Unmarshall issues.****
>
> Concurrent method invocation were exceuted to Unmarshall the xml file.****
>
> ** **
>
> Sample Code :****
>
> ** **
>
>         ServiceRequest request = (ServiceRequest)
> context.createUnmarshaller().unmarshal( new
> ByteArrayInputStream(xml.getbytes())); ****
>
> ** **
>
>         if ( request.getSelectedOptions() == null){****
>
>             System.out.println("thread - " +
> Thread.currentThread().getName() + " : " + " ************** Unmarshal
> failed ************* ");****
>
>         }****
>
> All test passed****
>
> Wink Resource ****
>
> @POST****
>
> @Consumes(MediaType.TEXT_PLAIN)****
>
> A Wink Resource was used to post the XML String. ****
>
> It was consumed using MediaType.TEXT_PLAIN****
>
> XML was Unmarshalled using JAXB to create  ServiceRequest object****
>
> ** **
>
> Sample Code:****
>
> ** **
>
> @POST****
>
> @Consumes(MediaType.TEXT_PLAIN)****
>
> @Produces(MediaType.TEXT_PLAIN)****
>
>     public Response getLogs(String xmlRequest){   ****
>
>     String res = "";****
>
>     try {****
>
>         ServiceRequest request = (ServiceRequest)
> context.createUnmarshaller().unmarshal( new
> ByteArrayInputStream(xmlRequest.getbytes())); ****
>
> ** **
>
>         if ( request.getSelectedOptions() == null){****
>
>             System.out.println(" ************** Unmarshal failed
> ************* ");****
>
>         }****
>
> All test Passed****
>
> Wink Resource ****
>
> @POST****
>
> @Consumes(MediaType.* **APPLICATION_XML)*****
>
> A Wink Resource was used to post the XML String. ****
>
> It was consumed using ****
>
> MediaType.* APPLICATION_XML* ****
>
> ** **
>
> Sample code:****
>
> ** **
>
> @POST****
>
> @Consumes(MediaType.* APPLICATION_XML*)****
>
> ** **
>
>     public Response getLogs(ServiceRequest request){   ****
>
>     String res = "";****
>
> ** **
>
>         if ( request.getSelectedOptions() == null){****
>
>             System.out.println(" ************** Unmarshal failed
> ************* ");****
>
>         }****
>
> Few threads failed with errors ****
>
> ** **
>
> ** **
>
> Thanks****
>
> Kumar****
>
> Cloud Services****
>
> ** **
>
> ** **
>
> *From:* Michael Elman [mailto:[email protected]]
> *Sent:* Thursday, December 08, 2011 11:32 PM
>
> *To:* [email protected]
> *Subject:* Re: Inconsistent Unmarshalling during Concurrent requests****
>
> ** **
>
> I guess so...
> The question if it's a Wink bug, or may be JAXB...
> If I have time next week, I'll try to look into it.
>
> Did you try to run the same scenario without JAXB? let's say sent plain
> text and receive it?
> Send JSON?
>
> I guess it can be interesting...****
>
> On Thu, Dec 8, 2011 at 6:17 PM, Kumar, Munirathnam <
> [email protected]> wrote:****
>
> Does this issue qualify for a bug ?****
>
>  ****
>
> *From:* Michael Elman [mailto:[email protected]]
> *Sent:* Thursday, December 08, 2011 9:32 PM****
>
>
> *To:* [email protected]
> *Subject:* Re: Inconsistent Unmarshalling during Concurrent requests****
>
>  ****
>
> Yes, I did it many times.****
>
> With 200 threads it still worked fine.****
>
> With 500 some requests failed...****
>
> no idea what the problem is...****
>
> On Thu, Dec 8, 2011 at 5:56 PM, Kumar, Munirathnam <
> [email protected]> wrote:****
>
> Here is result again. There are failed results as well. Can you please re
> run couple of times. ****
>
>  ****
>
> thread - 44 : Serialisation Passed****
>
> thread - 48 : Serialisation Passed****
>
> thread - 36 : Serialisation Passed****
>
> thread - 46 : Serialisation Passed****
>
> thread - 4 : Serialisation Passed****
>
> thread - 30 : Serialisation Passed****
>
> thread - 13 : Serialisation Passed****
>
> thread - 23 : Serialisation Passed****
>
> thread - 25 : Serialisation Failed****
>
> thread - 45 : Serialisation Failed****
>
> thread - 28 : Serialisation Passed****
>
> thread - 10 : Serialisation Passed****
>
> thread - 24 : Serialisation Failed****
>
> thread - 35 : Serialisation Passed****
>
> thread - 22 : Serialisation Failed****
>
> thread - 34 : Serialisation Passed****
>
> thread - 47 : Serialisation Passed****
>
> thread - 7 : Serialisation Passed****
>
> thread - 38 : Serialisation Failed****
>
> thread - 43 : Serialisation Failed****
>
> thread - 17 : Serialisation Passed****
>
> thread - 41 : Serialisation Failed****
>
> thread - 9 : Serialisation Failed****
>
> thread - 18 : Serialisation Failed****
>
> thread - 15 : Serialisation Passed****
>
> thread - 12 : Serialisation Failed****
>
> thread - 20 : Serialisation Passed****
>
> thread - 42 : Serialisation Passed****
>
> thread - 16 : Serialisation Passed****
>
> thread - 31 : Serialisation Passed****
>
> thread - 14 : Serialisation Failed****
>
> thread - 27 : Serialisation Failed****
>
> thread - 11 : Serialisation Passed****
>
> thread - 26 : Serialisation Failed****
>
> thread - 8 : Serialisation Failed****
>
> thread - 19 : Serialisation Passed****
>
> thread - 40 : Serialisation Passed****
>
> thread - 0 : Serialisation Passed****
>
> thread - 21 : Serialisation Passed****
>
> thread - 3 : Serialisation Failed****
>
> thread - 6 : Serialisation Passed****
>
> thread - 2 : Serialisation Passed****
>
> thread - 33 : Serialisation Failed****
>
> thread - 49 : Serialisation Passed****
>
> thread - 39 : Serialisation Failed****
>
> thread - 37 : Serialisation Passed****
>
> thread - 29 : Serialisation Passed****
>
> thread - 1 : Serialisation Passed****
>
> thread - 5 : Serialisation Passed****
>
> thread - 32 : Serialisation Failed****
>
>  ****
>
> *From:* Michael Elman [mailto:[email protected]]
> *Sent:* Thursday, December 08, 2011 9:22 PM****
>
>
> *To:* [email protected]
> *Subject:* Re: Inconsistent Unmarshalling during Concurrent requests****
>
>  ****
>
> Tried to run your code. Everything looks fine:****
>
>  ****
>
> thread - 29 : Serialization Passed****
>
> thread - 0 : Serialization Passed****
>
> thread - 20 : Serialization Passed****
>
> thread - 9 : Serialization Passed****
>
> thread - 7 : Serialization Passed****
>
> thread - 38 : Serialization Passed****
>
> thread - 5 : Serialization Passed****
>
> thread - 37 : Serialization Passed****
>
> thread - 36 : Serialization Passed****
>
> thread - 25 : Serialization Passed****
>
> thread - 1 : Serialization Passed****
>
> thread - 13 : Serialization Passed****
>
> thread - 47 : Serialization Passed****
>
> thread - 4 : Serialization Passed****
>
> thread - 43 : Serialization Passed****
>
> thread - 22 : Serialization Passed****
>
> thread - 28 : Serialization Passed****
>
> thread - 17 : Serialization Passed****
>
> thread - 21 : Serialization Passed****
>
> thread - 33 : Serialization Passed****
>
> thread - 32 : Serialization Passed****
>
> thread - 30 : Serialization Passed****
>
> thread - 40 : Serialization Passed****
>
> thread - 39 : Serialization Passed****
>
> thread - 24 : Serialization Passed****
>
> thread - 35 : Serialization Passed****
>
> thread - 16 : Serialization Passed****
>
> thread - 31 : Serialization Passed****
>
> thread - 18 : Serialization Passed****
>
> thread - 44 : Serialization Passed****
>
> thread - 42 : Serialization Passed****
>
> thread - 34 : Serialization Passed****
>
> thread - 2 : Serialization Passed****
>
> thread - 10 : Serialization Passed****
>
> thread - 27 : Serialization Passed****
>
> thread - 19 : Serialization Passed****
>
> thread - 3 : Serialization Passed****
>
> thread - 49 : Serialization Passed****
>
> thread - 26 : Serialization Passed****
>
> thread - 46 : Serialization Passed****
>
> thread - 41 : Serialization Passed****
>
> thread - 8 : Serialization Passed****
>
> thread - 14 : Serialization Passed****
>
> thread - 23 : Serialization Passed****
>
> thread - 11 : Serialization Passed****
>
> thread - 6 : Serialization Passed****
>
> thread - 45 : Serialization Passed****
>
> thread - 48 : Serialization Passed****
>
> thread - 12 : Serialization Passed****
>
> thread - 15 : Serialization Passed****
>
>  ****
>
> On Thu, Dec 8, 2011 at 5:07 PM, Kumar, Munirathnam <
> [email protected]> wrote:****
>
> I have created new Instance for each thread but still I have the same
> issue.****
>
>  ****
>
> RestClient client = new RestClient();****
>
>  ****
>
> for ( int i =0; i < 50 ; i ++ ){****
>
>              resource = client.resource("http://localhost:8080/logger/test
> ");****
>
>              new Thread(new Multi(resource),new
> Integer(i).toString()).start();****
>
>          }****
>
>  ****
>
>  ****
>
> *From:* Michael Elman [mailto:[email protected]]
> *Sent:* Thursday, December 08, 2011 8:11 PM
> *To:* [email protected]
> *Subject:* Re: Inconsistent Unmarshalling during Concurrent requests****
>
>  ****
>
> If I understand your code correctly, you reuse Resource instance on
> multiple threads. ****
>
> But as I recall Resource is not threadsafe.****
>
> Just create a new instance each time, and it should be fine.****
>
> On Thu, Dec 8, 2011 at 4:05 PM, Kumar, Munirathnam <
> [email protected]> wrote:****
>
> Hi****
>
> I am requesting  Concurrent requests to a Resource.****
>
> But on the Resource, bean objects are not completely populated for some
> request and gets populated completely for other requests.****
>
>  ****
>
> Please see the Client,Bean and Resource Class below.****
>
>  ****
>
> For few client request the *request.getSelectedOptions()* always returns
> null . ****
>
>  ****
>
> Is this a bug with Wink ?****
>
>  ****
>
> Can you please help****
>
>  ****
>
> -          kumar****
>
>  ****
>
> Client ****
>
>  ****
>
> class Multi implements Runnable{    ****
>
>     Resource resource;****
>
>     String xml = "<UserSubscription>"****
>
>             +       "<selectedOptions><entry><key >Amount of Memory
> (MB)</key><value >2000</value></entry>" +****
>
>                                            "<entry><key>Number of
> CPUs</key><value>1</value></entry>" +****
>
>                                            "<entry><key>Number of
> Servers</key><value>1</value></entry>"****
>
>             +      "</selectedOptions>"****
>
>             +   "</UserSubscription>";****
>
>     ****
>
>     Multi(Resource resource){****
>
>         this.resource = resource;****
>
>         ****
>
>     }****
>
>     public void run(){****
>
>              String res =
> resource.contentType(MediaType.APPLICATION_XML).accept(MediaType.TEXT_PLAIN).post(String.class,xml);
> ****
>
>              System.out.println("thread - " +
> Thread.currentThread().getName() + " : " +  res);       ****
>
>     }****
>
> }****
>
>  ****
>
> Bean Class****
>
>  ****
>
> @XmlAccessorType(XmlAccessType.NONE)****
>
> @XmlRootElement(name = "UserSubscription")****
>
> public class ServiceRequest {****
>
>                 private Properties modelInputs;****
>
>  ****
>
>  ****
>
>                 public  void setSelectedOptions(Properties modelInputs) {*
> ***
>
>                                 this.modelInputs = modelInputs;****
>
>                 }****
>
>  ****
>
>                 @XmlElementWrapper(name = "selectedOptions", required =
> true, nillable = false)****
>
>                 public  Properties getSelectedOptions() {****
>
>                                 return this.modelInputs;****
>
>                 }****
>
> }****
>
>  ****
>
>  ****
>
> Resource Class****
>
>  ****
>
> @Path("/test")****
>
> public class PropResource {****
>
>     ****
>
> @POST****
>
> @Consumes(MediaType.APPLICATION_XML)****
>
> @Produces(MediaType.TEXT_PLAIN)****
>
>     public Response getLogs(ServiceRequest request){****
>
>  ****
>
>     String res = "";****
>
>     if( request.getSelectedOptions() == null){               ****
>
>         res = "Serialization Failed";****
>
>     } else if(request.getSelectedOptions() != null ){        ****
>
>         res = "Serialization Passed";****
>
>     }    ****
>
>     return Response.ok(res).build();****
>
>     }****
>
>  ****
>
> }****
>
>  ****
>
>  ****
>
>  ****
>
>  ****
>
> ** **
>

Reply via email to