[platform-dev] Newer/Different version of Xerces?

  • From: "Cush1978" < >
  • To:
  • Subject: [platform-dev] Newer/Different version of Xerces?
  • Date: Fri, 30 Nov 2012 12:02:54 -0500

Well I've found a solution that seems to work.  Here's how I did it in case 
anyone needs to do it in the future.

- Wrap the new Xerces JAR in the same module as the library that needs it.

This is usually inadvisable, but in this case that specific module is the 
only one that needs specific functionality from that specific version of 
Xerces.

- Remove the META-INF/services directory from the new Xerces JAR.

We don't want to offer any services, we're directly invoking the classes we 
want to use as opposed to a factory method.

- Replace the context class loader when calling Xerces code.

http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/classpath.html#overlaps

See the specific note on Xerces.


Code:
ClassLoader original = Thread.currentThread().getContextClassLoader();

// Use the module's ClassLoader.
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());

// Do Xerces stuff here.

// If there's exception handling, use a finally block.
Thread.currentThread().setContextClassLoader(original);



At this point, the code works.  I do get a logged warning about arbitrarily 
loading classes from two sources, but there is no thrown exception.  Note 
that this case is a specific end case and doesn't "upgrade" or "replace" 
Xerces functionality.  It just allows me to use a newer Xerces JAR and call 
the specific classes needed within.






[platform-dev] Newer/Different version of Xerces?

Cush1978 11/27/2012

[platform-dev] Re: Newer/Different version of Xerces?

Jaroslav Tulach 11/27/2012

[platform-dev] Newer/Different version of Xerces?

Cush1978 11/28/2012

[platform-dev] Re: Newer/Different version of Xerces?

Benno Markiewicz 11/28/2012

[platform-dev] Newer/Different version of Xerces?

Cush1978 11/28/2012

[platform-dev] Newer/Different version of Xerces?

Cush1978 11/28/2012

[platform-dev] Newer/Different version of Xerces?

Cush1978 11/30/2012

Project Features

Project Links

About this Project

Platform was started in November 2009, is owned by Antonin Nebuzelsky, and has 138 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close