Exception coming: java.util.ServiceConfigurationError

前端 未结 2 1977
旧时难觅i
旧时难觅i 2021-01-07 04:16

Getting below exception while running my application :

I am using jboss : 5.1.1 and jdk 1.6.

01:50:04,828 ERROR [[HelloWorld]] Servlet.service() for          


        
2条回答
  •  心在旅途
    2021-01-07 04:37

    Try to switch class loaders.

    Grab classloader from your Service class and reset after the call.

        final ClassLoader targetClassLoader = ServiceXY.class.getClassLoader();
        final Thread currentThread = Thread.currentThread();
        final ClassLoader contextClassLoader = currentThread.getContextClassLoader();
        try {
               currentThread.setContextClassLoader(targetClassLoader);
               //here call your Service 
        } finally {
               currentThread.setContextClassLoader(contextClassLoader);
        }
    

    JEE libs have been removed with Java 9, JEE-specific libs / implementations must now be made available by the application via thirdparty libraries - e.g. jaxws-api.jar and jaxws-rt.jar. This code of JEE libs often still expects to be part of the jre system library and with that of the application classloader - but it isn't anymore. So if service classloader ServiceXY.class.getClassLoader() and your application classloader Thread.currentThread().getContextClassLoader() are different you need to switch for the request.

提交回复
热议问题