加载我自己的Xalan实现,其中旧的Xalan被加载到父类加载器 [英] Load my own Xalan implementation where an older Xalan is loaded to the parent classloader

查看:82
本文介绍了加载我自己的Xalan实现,其中旧的Xalan被加载到父类加载器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个框架插件,将我的代码作为子类加载器加载

I'm writing a plugin for a framework that loads my code as a child classloader

问题是该框架使用某个Xerces版本,而不是与我的代码兼容,我想用我的自己的jar用于xerces,但似乎既然旧的已经加载了,我似乎无法使我的代码使用我的。

The problem is that that framework uses a certain Xerces version, that is not compatible with my code, I want to use my "own" jar for xerces, but it seems since the old one was already loaded, I can't seem to make my code use mine.

我正在寻找一些类加载器分离,我知道这是一个已知的问题,但似乎无法解决它

I'm looking for some classloader seperation, I know it's a know problem, but can't seem to solve it

在这种情况下,是否有任何框架,库或代码示例在本地用户使用较新的jar?

Is there any framework, library, or code sample to user locally a newer jar in such a scenario?

推荐答案

您是否尝试将框架和Xerces库的类作为ExtClassLoader的一部分加载到对应于java.ext.dirs系统属性的路径中?这样,框架的Xerces实现版本将由ExtClassLoader加载。

Have you tried loading the classes of your framework and Xerces libs as a part of the ExtClassLoader by placing them in path corresponding to the java.ext.dirs system property? This way the framework's version of Xerces implementation will be loaded by the ExtClassLoader.

然后,您可以将Xerces实现的版本放在与java.class.path对应的路径中由AppClassLoader加载的系统属性。

You can then place your version of Xerces implementation in the path corresponding to the java.class.path system property to be loaded by the AppClassLoader.

我自己没有尝试过,但考虑到类加载层次结构,这应该有效。您可以在此处了解有关类加载层次结构的更多信息 - http:// onjava.com/pub/a/onjava/2005/01/26/classloading.html

I have not tried this myself, but considering the class loading hierarchy this should work. You can learn more about the class loading hierarchy here - http://onjava.com/pub/a/onjava/2005/01/26/classloading.html

这篇关于加载我自己的Xalan实现,其中旧的Xalan被加载到父类加载器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆