Weblogic 12c: Prefer-web-inf-classes and Preferred Application Packages for Jersey

I need to use both (oddly enough ..) the "prefer-web-inf-classes" and "prefer-application-packages" weblogic.xml properties on the Weblogic 12c server (12.2.1)

This is a REST app 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 must place at the war / library level libraries for guice-jersey / guice, otherwise you will get a Multiuser Error .

It should also point prefer-web-inf-classes to true . This method works correctly! I 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 nothing.

Note. It is not possible to exclude these libraries at the EAR level.

2. Why use: prefer-application-packages

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

It works great on Jersey 1.X if it is listed this way. . I explored the two wars separately and works great ... but, remember, my friend, I have two wars ... etc.

Summary

I cannot use both properties (error deployment to use both properties in weblogic.xml ..), but it is necessary:

  • To solve the problem with Guice Filter, add true-web-inf-classes to true to use guice-servlet.jar / jersey-guice.jar at the war-lib level.
  • To work with Jersey 1.x, you need to use ..... prefer-application-package

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

+6
source share
2 answers

Finally

  • Use only prefer-web-inf-classes for true.
  • If you use this, you do not need to use application preference packages .... BUT MAKE SURE that you have the right war / ear level libraries.

    The problem was this:

The project was dependent on Jersey 2 (based on Swagger for Jersey 2.X ...) Thus, through the Swagger dependencies (swagger-jersey2-jaxrs), the Jersey 2 libraries were packaged in an ear / war ... and therefore prefer-web -inf classes DO NOT NEED EFFECT! After removing all allowed dependencies.!

At the same level (classpath or ear lib or war lib) there should not be different versions of the same library

+1
source
  • Hello World! Hi, There are two ways to solve this problem.

    • You can use to combine both files into one file and call it based on the select tag as requirements.

    • You can simply write tags to merge or import / include the xml file into one. An example is shown. Hint: do google how to merge and invoke the xml file based on the condition.

0
source

All Articles