Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在部署liferay portlet之前终止所有线程_Java_Multithreading_Liferay_Liferay 6 - Fatal编程技术网

Java 如何在部署liferay portlet之前终止所有线程

Java 如何在部署liferay portlet之前终止所有线程,java,multithreading,liferay,liferay-6,Java,Multithreading,Liferay,Liferay 6,我正在使用Liferay 6.2和使用ServletContextListener创建的线程 因此,当我尝试部署这个特定的portlet应用程序时,它会给出以下错误- INFO: Illegal access: this web application instance has been stopped already. Could not load com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl. The

我正在使用Liferay 6.2和使用ServletContextListener创建的线程

因此,当我尝试部署这个特定的portlet应用程序时,它会给出以下错误-

INFO: Illegal access: this web application instance has been stopped already.  Could not load com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1600)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at javax.xml.parsers.FactoryFinder.getProviderClass(FactoryFinder.java:112)
    at javax.xml.parsers.FactoryFinder.newInstance(FactoryFinder.java:178)
    at javax.xml.parsers.FactoryFinder.newInstance(FactoryFinder.java:147)
    at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:265)
    at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:121)
    at com.h5g.deployment.util.DeploymentUtil.getLobbyBranch(DeploymentUtil.java:642)
    at com.h5g.deployment.service.ClientStatusCheckTask.call(ClientStatusCheckTask.java:47)
    at com.h5g.deployment.service.ClientStatusCheckTask.call(ClientStatusCheckTask.java:1)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
我一直在寻找一种在自动部署开始之前杀死线程的方法


任何指示都会非常有用

尝试停止以下线程:

thread.interrupt();

但我不确定是否需要查看启动线程的代码这听起来很像是您自己创建的线程,这在应用程序服务器环境中通常会引起人们的注意。有几种方法可以缓解这种情况——对当前(隐含的)体系结构影响最小的一种方法是,当您取消部署web应用程序时,需要停止线程。我假设这不会在“部署时”发生,而是在“取消部署后”发生,因为您正在
ServletContextListener
中启动线程,但从未停止它们


当应用程序关闭时,
ServletContextListener
会收到通知,这是您可以用来向生成的线程标记其状态的方法。在典型的无止境循环中,线程会频繁地检查它们是否仍然应该运行——如果不应该,就退出无止境循环,它们会在后面进行完美的清理。重新部署应用程序时,新的
ServletContextListener
将产生新线程。

感谢您的更新。但是,我相信,以编程的方式来做这件事并不是一种理想的方式。必须有某种方法通过liferay配置来处理此问题。