Load my own Xalan implementation where an older Xalan is loaded to the parent classloader

前端 未结 2 1919
北恋
北恋 2021-01-27 12:22

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

The problem is that that framework uses a certain Xerces version, that is not compatible

2条回答
  •  遇见更好的自我
    2021-01-27 12:44

    try doing:

    ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(childClassLoader);
    try{
        // do xml parsing
    }finally{
        Thread.currentThread().setContextClassLoader(oldContextClassLoader);
    }
    

提交回复
热议问题