0 Replies Latest reply on May 10, 2013 10:12 AM by valacm1c

    Incorrectly shared ResteasyProviderFactory instance between 2 separate WAR archives in JacksonJsonProvider

    valacm1c Newbie



      yesterday i stumbled accros a problem with resteasy in JBoss 7.1.1. I have a project with a resteasy service consuming and producing json using Jackson provider with custom ObjecMapper configuration. When  my application was the only one on the server, everything worked as expected.


      But, when there was another application with reasteasy service, its configuration was used even for my service (or the configuration of the service which started first).


      I made  2 simple projects Rest01 and Rest02. They are identical except, that Rest01 ObjectMapper configuration is serializing dates as unix timestamps and Rest02 ObjectMapper configuration is serializing dates as Strings (difference is in class rest.test.JacksonContextResolver). If each application is deployed separately, it works as expected. But if both applications are deployed at the same time, the configuration from the first deployed is used for both. I traced the problem into class org.codehaus.jackson.jaxrs.JacksonJsonProvider (each app has its own instance), but the injected  field @Context protected Providers _providers is the same instance of org.jboss.resteasy.spi.ResteasyProviderFactory even though both applications create its own instance.


      Is this expected behavior?


      I atached the war archives and source codes so it is possible to easily reproduce the problem. The services can be accessed  at url: /Rest01/rest/action/execute or /Rest02/rest/action/execute.