title: Weblogic 12c : Prefer-web-inf-classes and prefer-application-packages for Jersey
body: <p>I have to use both (oddly enough ..) <code>prefer-web-inf-classes</code> and <code>prefer-application-packages</code>  properties of <em>weblogic.xml</em> on a <em>Weblogic 12c Server (12.2.1)</em></p>
  
  <p>It is REST application based on Jersey 1.9. ( Jersey 1.x JAX-RS RI) and Guice.</p>
  
  <p><strong>1. Why use :prefer-web-inf-classes</strong></p>
  
  <p>If you have more than one WAR you have to place at the level of war/lib the  libraries for guice-jersey / guice  , other way you get an <a href="https://github.com/google/guice/issues/559" rel="nofollow noreferrer">Multibindings Error</a>.</p>
  
  <p>It must be indicated also the <code>prefer-web-inf-classes</code> to <strong><code>true</code></strong>.</p>
  
  <p>This way it works properly! </p>
  
  <p>I have tried to work in the same way using <code>prefer-application-package</code>s with packages (<code>com.sun.jersey.guice.spi.container.servlet</code>, <code>com.google.inject.servlet</code>, etc...) but no way.</p>
  
  <p>Note: It is not possible to exclude this libraries at <em>EAR</em> level.</p>
  
  <p><strong>2. Why use :prefer-application-packages</strong></p>
  
  <p>To use Jersey 1.x JAX-RS RI on Weblogic 12c (12.2.1) so I have to indicate the following packages (<em>other way Weblogic uses Jersey 2, and different version of Jackson libraries, etc.</em> )</p>
  
  <p>It works perfectly on Jersey 1.X if it is <a href="https://docs.oracle.com/middleware/1213/wls/RESTF/version-restful-service.htm#RESTF200" rel="nofollow noreferrer">indicated this way.</a> . I have probed two war separately, and works fine... but, remember my friend I have two war..so....</p>
  
  <p><strong>Summary</strong></p>
  
  <p>I can not use both properties (deploying error for using both properties on the weblogic.xml..), but it's needed : </p>
  
  <ol>
  <li>For the problem with Guice Filter, need to put <code>prefer-web-inf-classes</code> to <code>true</code>to use <code>guice-servlet.jar</code> / <code>jersey-guice.jar</code> at  <em>war-lib level</em>.</li>
  <li>To work with Jersey 1.x, need to use ..... <code>prefer-application-package</code></li>
  </ol>
  
  <p><strong>Question</strong>: How to combine both to use one of them??</p>