我现在使用嵌入式jbpm 6.2作为我的常用服务,所以我写了一个包含jbpm服务的jar,然后我使用了一个URL类加载器加载它,它运行得很好,但在我关闭后jbpm引擎并尝试删除罐子,有些罐子我无法移除。
这是在jar
中初始化jbpm引擎的代码 try {
emf = Persistence.createEntityManagerFactory(Constants.JBPM_JPA_UNIT_NAME);
DBUserGroupCallbackImpl callback = new DBUserGroupCallbackImpl(props);
RuntimeEnvironmentBuilder kBuilder = RuntimeEnvironmentBuilder.getDefault()
.classLoader(this.getClass().getClassLoader())
.entityManagerFactory(emf)
.userGroupCallback(callback)
.persistence(true);
String path = props.getProperty(Constants.BPMN_RESOURCE_PATH);
logger.debug("Get bpmn resource with path = {}", path);
if (!StringUtil.isEmpty(path)) {
String[] paths = path.split(";");
List<File> files = getFile(paths);
if (files != null && !files.isEmpty()) {
List<Resource> resources = getResource(files);
if (resources != null && !resources.isEmpty()) {
for (Resource resource : resources) {
kBuilder.addAsset(resource, ResourceType.BPMN2);
logger.info("Add asset to jbpm success, resource = {}", resource);
}
}
}
}
runtimeManager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(kBuilder.get());
runtime = runtimeManager.getRuntimeEngine(EmptyContext.get());
this.kiesession = runtime.getKieSession();
this.taskService = runtime.getTaskService();
这是关闭jbpm引擎的代码:
public void close() {
if (runtimeManager != null) {
runtimeManager.disposeRuntimeEngine(runtime);
runtimeManager.close();
}
if (kiesession != null) {
kiesession.destroy();
}
if (emf != null) {
emf.close();
}
}
现在我使用下面的代码删除jar:
jbpmService.close();
urlcloassloader.close();
System.gc();
// waiting 1min
FileUtil.forceDelete(dir)
大多数罐子已被移除,但我无法移除drools-core-6.2.0.Final.jar和postgresql-42.0.0.jre7.jar,有人知道为什么吗?