简体   繁体   中英

BaseX close Spring Boot classloader

I have a Spring Boot (2.7.5) with BaseX 10.3

On start up I have a server component starting the server in a @PostConstruct

System.setProperty("org.basex.path", basexDataPath);
Context c = new Context();
c.soptions.set(StaticOptions.DBPATH, basexDataPath);
this.server = new BaseXServer(c,sl.finish());

And a client component creating a session in also a @PostConstruct

ClientSession clientSession = new ClientSession(basexServerHost, basexServerPort, UserText.ADMIN, basexAdminPassword);

And then I load functx (still in postconstruct):

RepoInstall ri = new RepoInstall(tmpLib.getAbsolutePath(),null);//tmpLib = functx file
clientSession.execute(ri);

In Eclipse it works but when packaged and running from the jar, the application fail to start because I get a ClassNotFoundException of my own class.

I figured out, that it can not find the class because the classloader is closed. And Basex is closing it :

Here is the stack:

关闭堆栈跟踪

What is wrong with my implementation? How can I avoid BaseX to close the classloader?

The BaseX ModuleLoader used to close URLClassLoaders, assuming that it had instantiated them itself for module loading:

      if(loader instanceof URLClassLoader) {
      try {
        ((URLClassLoader) loader).close();
      } catch(final IOException ex) {

But this could also affect the default classloader, in case it was an URLClassLoader, so it was fixed recently ( b82b4c ). The fix is not yet contained in a released version, though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM