how to disable Jersey from weblogic 12.2.1

血红的双手。 提交于 2019-11-30 22:40:18
user2169241

You need to include the jersey files in the web-inf lib of your project (you can get jersey and dependencies zip file from jersey's website), also add these lines to your weblogic.xml file (as indicated in this post Using Jersey 2.x web service on Weblogic 12.1.1):

 <container-descriptor>

    <prefer-application-packages>
        <!-- jsr311 -->
        <package-name>javax.ws.rs.*</package-name>
        <!-- javassist -->
        <package-name>javassist.*</package-name>
        <!-- aop repackaged -->
        <package-name>org.aopalliance.*</package-name>

        <!-- jersey 2 -->
        <package-name>jersey.repackaged.*</package-name>
        <package-name>org.glassfish.jersey.*</package-name>
        <package-name>com.sun.research.ws.wadl.*</package-name>

        <!-- hk2 -->
        <package-name>org.glassfish.hk2.*</package-name>
        <package-name>org.jvnet.hk2.*</package-name>
        <package-name>org.jvnet.tiger_types.*</package-name>

    </prefer-application-packages>

    <prefer-application-resources>
        <resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
        <resource-name>META-INF/services/javax.ws.rs.ext.RuntimeDelegate</resource-name>

        <!-- jersey -->
        <resource-name>META-INF/services/org.glassfish.jersey.*</resource-name>
        <resource-name>org.glassfish.jersey.*</resource-name>
        <resource-name>jersey.repackaged.*</resource-name>

        <!-- hk2 -->
        <resource-name>META-INF/services/org.glassfish.hk2.*</resource-name>
    </prefer-application-resources>
</container-descriptor>

Doing this will override the jersey version used by weblogic 12.2.1.

If you're using Json you will also require to get these jars as indicated in this post POST to Jersey REST service getting error 415 Unsupported Media Type:

  • jersey-media-json-jackson
  • jackson-jaxrs-json-provider
  • jackson-core
  • jackson-databind
  • jackson-annotations
  • jackson-jaxrs-base
  • jackson-module-jaxb-annotations
  • jersey-entity-filtering

and add these lines to the <prefer-application-packages> section in weblogic.xml:

 <package-name>org.codehaus.jackson.*</package-name>
 <package-name>com.fasterxml.jackson.*</package-name>

UDPATE- Also worth mentioning that weblogic 12 default JSON binder is MOXy and not Jersey, this has caused me some issues and I eventually replaced the provider with Jersey which makes my above changes unnecessary.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!