Weblogic 12c : Prefer-web-inf-classes and prefer-application-packages for Jersey
Asked Answered
S

2

9

I have to use both (oddly enough ..) prefer-web-inf-classes and prefer-application-packages properties of weblogic.xml on a Weblogic 12c Server (12.2.1)

It is REST application based on Jersey 1.9. ( Jersey 1.x JAX-RS RI) and Guice.

1. Why use :prefer-web-inf-classes

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 Multibindings Error.

It must be indicated also the prefer-web-inf-classes to true.

This way it works properly!

I have tried to work in the same way using prefer-application-packages with packages (com.sun.jersey.guice.spi.container.servlet, com.google.inject.servlet, etc...) but no way.

Note: It is not possible to exclude this libraries at EAR level.

2. Why use :prefer-application-packages

To use Jersey 1.x JAX-RS RI on Weblogic 12c (12.2.1) so I have to indicate the following packages (other way Weblogic uses Jersey 2, and different version of Jackson libraries, etc. )

It works perfectly on Jersey 1.X if it is indicated this way. . I have probed two war separately, and works fine... but, remember my friend I have two war..so....

Summary

I can not use both properties (deploying error for using both properties on the weblogic.xml..), but it's needed :

  1. For the problem with Guice Filter, need to put prefer-web-inf-classes to trueto use guice-servlet.jar / jersey-guice.jar at war-lib level.
  2. To work with Jersey 1.x, need to use ..... prefer-application-package

Question: How to combine both to use one of them??

Supranatural answered 29/3, 2016 at 19:4 Comment(0)
S
2

After all

  1. Use just prefer-web-inf-classes to true.
  2. If you use this, you don't need to use prefer-application-packages ....BUT ENSURE that you have the correct libraries at war /ear level.

    The problem was:

The Project had a dependency with Jersey 2 (based on Swagger for Jersey 2.X ...) So via Swagger dependencies (swagger-jersey2-jaxrs), Jersey 2 libraries was packaged on ear/war... and so prefer-web-inf-classes HAS NO EFFECT!

After removing the dependency all was resolved!

At same the level (classpath or ear lib, or war lib) should not exist different versions of the same library.

Supranatural answered 26/7, 2016 at 9:46 Comment(1)
i want my bounty back )) ! Nobody answered ))Supranatural
R
0
  • Hello, world! Hi, There are two way to resolve this problem.

    1. You can used to combine both file in to one file and call it based on choose tag as requirements.

    2. You can just write tags to merge or import/ include your xml file in to one. Example shown. Hint: Do google how to merge and call xml file based on condition.

Rom answered 7/4, 2016 at 11:37 Comment(1)
Sorry, but this has no sense...The same weblogic.xml must be valid for both purposes, work with Jersey 1.X and Jersey-Guice.Supranatural

© 2022 - 2024 — McMap. All rights reserved.