Weblogic 12c:泽西岛的Prefer-web-inf-classs和Preferred-application-packages [英] Weblogic 12c : Prefer-web-inf-classes and prefer-application-packages for Jersey
问题描述
我必须在 Weblogic 12c服务器(12.2.1)上同时使用(emd.weblogic.xml 的prefer-web-inf-classes
和prefer-application-packages
属性)
它是基于Jersey 1.9的REST应用程序. (Jersey 1.x JAX-RS RI)和Guice.
1.为什么要使用:prefer-web-inf-classes
如果您有多个战争,则必须放置在战争级别/lib库中,以获取guice-jersey/guice的库,否则您将获得解决方案
毕竟
- 仅使用
prefer-web-inf-classes
到true
. -
如果使用此功能,则无需使用
prefer-application-packages
....但请确保在战争/战争级别具有正确的库.问题是:
该项目与Jersey 2有依赖关系(基于Jersey 2.X的 Swagger )所以通过Swagger依赖项(swagger-jersey2-jaxrs
),Jersey 2库被打包在了耳朵上/战争中,因此prefer-web-inf-classes
没有效果!
删除依赖性后,所有问题都解决了!
同一级别(类路径,ear lib或war lib)不应存在同一库的不同版本.
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-package
s 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 :
- For the problem with Guice Filter, need to put
prefer-web-inf-classes
totrue
to useguice-servlet.jar
/jersey-guice.jar
at war-lib level. - To work with Jersey 1.x, need to use .....
prefer-application-package
Question: How to combine both to use one of them??
After all
- Use just
prefer-web-inf-classes
totrue
. 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.
这篇关于Weblogic 12c:泽西岛的Prefer-web-inf-classs和Preferred-application-packages的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!