JAXB 2 in an Oracle 10g Webapp

丶灬走出姿态 提交于 2019-12-23 18:20:02

问题


I have a web application that uses JAXB 2. When deployed on an Oracle 10g Application Server, I get errors as soon as I try to marshal an XML file. It turns out that Oracle includes JAXB 1 in a jar sneakily renamed "xml.jar".

How I can force my webapp to use the version of the jaxb jars that I deployed in WEB-INF/lib over that which Oracle has forced into the classpath, ideally through configuration rather than having to mess about with classloaders in my code?


回答1:


I assume you use the former BEA Weblogic Server?

You can add a weblogic.xml file to your WEB-INF, looking like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN" "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd">
<weblogic-web-app>
    <container-descriptor>
   <prefer-web-inf-classes>true</prefer-web-inf-classes>
    </container-descriptor>
</weblogic-web-app>

(in reply to the comment, I don't have enough reputation yet :-))

Indeed, DLL hell because it is "all or nothing". There seems to be another, more conditional way, described here. Haven't tried that one myself though...




回答2:


If you are still using Oracle's OC4J then include their orion-application.xml in your EAR's META-INF. It should look something like...

<?xml version="1.0" encoding="UTF-8"?>
<orion-application>
    <imported-shared-libraries>
        <remove-inherited name="skip.this.package"/>
    </imported-shared-libraries>
</orion-application>

...with the package you want skipped.




回答3:


Use a different JVM than your Oracle instance and make sure that their libraries are not in your classpath.



来源:https://stackoverflow.com/questions/132409/jaxb-2-in-an-oracle-10g-webapp

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