I have a web application that uses JAXB 2. When deployed on an Oracle 10g app 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". Does anyone know 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.
A:
Use a different JVM than your Oracle instance and make sure that their libraries are not in your classpath.
Steve Moyer
2008-09-25 09:58:52
Don't think that's really an option - the webapp is deployed within the Oracle 10g application container, and so is tied to that JVM.
alexmcchessers
2008-09-25 10:02:12
+1
A:
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...
NR
2008-09-25 10:05:53
A good answer that would probably solve my problem in any sane world. Turns out that we used to have that setting for (I didn't realise that 10g was based on Weblogic), but one of my team tells me that it was taken out because it broke something else. DLL hell all over again. Sigh. Thanks anyway.
alexmcchessers
2008-09-25 10:31:11
Ok, to contradict myself, I have tried configuring 10g to prefer my webapp classes, and now get a different error - see this question: http://stackoverflow.com/questions/133993/loader-constraints-violated-when-linking-javaxxmlnamespaceqname-class-from-weba
alexmcchessers
2008-09-25 15:30:05
+1
A:
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.
dacracot
2009-02-13 20:55:29