[Java][Liferay] 解决Liferay ext项目deploy的问题
2024-08-23 13:24:14
Liferay ext project在install war包之后需要重启服务器,重启服务器中会执行ExtHotDeployListener中的逻辑,这里有一个坑,如果是第二次以后install ext war包,会发现新修改的文件不起作用,原因如下
ExtHotDeployListener.java
protected void doInvokeDeploy(HotDeployEvent hotDeployEvent)
throws Exception {
ServletContext servletContext = hotDeployEvent.getServletContext();
String servletContextName = servletContext.getServletContextName();
if (_log.isDebugEnabled()) {
_log.debug("Invoking deploy for " + servletContextName);
}
String xml = HttpUtil.URLtoString(
servletContext.getResource(
"/WEB-INF/ext-" + servletContextName + ".xml"));
if (xml == null) {
return;
}
if (_log.isInfoEnabled()) {
_log.info(
"Registering extension environment for " + servletContextName);
}
/*
* Ext 项目在重启tomcat的时候会checkd liferay-portal/tomcat-xxx/webapps/ROOT/WEB-INF/ext-project-***-ext.xml是否存在
* 如果存在,就不执行后面的逻辑,也就不会执行installExt(***),那么也不会重新拷贝替换的文件
*
*/
if (ExtRegistry.isRegistered(servletContextName)) {
if (_log.isInfoEnabled()) {
_log.info(
"Extension environment for " + servletContextName +
" has been applied.");
}
return;
}
Map<String, Set<String>> conflicts = ExtRegistry.getConflicts(
servletContext);
if (!conflicts.isEmpty()) {
StringBundler sb = new StringBundler();
sb.append(
"Extension environment for " + servletContextName +
" cannot be applied because of detected conflicts:");
for (Map.Entry<String, Set<String>> entry : conflicts.entrySet()) {
String conflictServletContextName = entry.getKey();
Set<String> conflictFiles = entry.getValue();
sb.append("\n\t");
sb.append(conflictServletContextName);
sb.append(":");
for (String conflictFile : conflictFiles) {
sb.append("\n\t\t");
sb.append(conflictFile);
}
}
_log.error(sb.toString());
return;
}
installExt(servletContext, hotDeployEvent.getContextClassLoader());
FileAvailabilityUtil.reset();
if (_log.isInfoEnabled()) {
_log.info(
"Extension environment for " + servletContextName +
" has been applied. You must reboot the server and " +
"redeploy all other plugins.");
}
}
xxx-ext.xml格式如下
<ext-info>
<servlet-context-name>hsf-plugins-shared-ext</servlet-context-name>
<files>
<file>xxxx-ext.xml</file>
<file>ext-impl/classes/com/liferay/portal/action/xxx.class</file>
....
<file>ext-web/docroot/html/js/xxx.js</file>
<file>web.xml</file>
</files>
</ext-info>
解决方案
1>. 去除掉doInvokeDeploy中这段逻辑,不管是否包含ext-project-***-ext.xml都执行install
if (ExtRegistry.isRegistered(servletContextName)) {
if (_log.isInfoEnabled()) {
_log.info(
"Extension environment for " + servletContextName +
" has been applied.");
}
return;
}
2>. 在第二次install ext project war包之后需要删除liferay-portal/tomcat-xxx/webapps/ROOT/WEB-INF/ext-project-***-ext.xml,然后重启tomcat
最新文章
- hive 调优总结
- 七牛云存储Python SDK使用教程 - 上传策略详解
- 手机App开发
- input内容改变触发事件,兼容IE
- webx学习笔记
- Sass中常用的函数
- 正经学C#_变量与其转换:《c#入门经典》
- iPad和iPhone开发的比较
- [Angular 2] Using ng-model for two-way binding
- 调用awk的三种方式
- 华为MAC Flapping , MAC的漂移
- UVa 10905 - Children&#39;s Game 排序,题目没有说输入是int 难度: 0
- Data URI scheme - 数据的uri模式
- 【SpringBoot系列2】SpringBoot整合Redis
- 使用XMing+putty运行linux图形界面程序
- Vxlan抓包
- lakala GradientBoostedTrees
- linux 测试网络延迟
- [UI] 精美UI界面欣赏[12]
- js跳出循环:break 、continue 、return