首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Liferay portlet部署Java错误

Liferay portlet部署Java错误
EN

Stack Overflow用户
提问于 2015-09-03 16:41:59
回答 2查看 2.9K关注 0票数 2

我在Liferay 6.2中部署portlet时遇到了问题。我对JAVA和处理这类错误都是新手,所以请原谅我在处理这类问题时有点天真。

以下是我在Eclipse上遇到的错误:

找不到"http://java.sun.com/portlet“的标记库描述符,关于这一行:

代码语言:javascript
复制
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>

我也收到了一个警告:“未知的标签(portlet:defineObjects)”,关于这一行:

代码语言:javascript
复制
<portlet:defineObjects />

最后,关于这一行的错误“在此行发现多个注释:区域设置无法解析为变量,无法解析portletConfig”:

代码语言:javascript
复制
ResourceBundle resourceBundle = portletConfig.getResourceBundle(locale);

这是我的init.jsp (请阅读我结尾处的注释):

代码语言:javascript
复制
<%@ page pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %>

<%@ taglib uri="/WEB-INF/tld/c-rt.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt"%>
<%@ taglib uri="/WEB-INF/tld/fn.tld" prefix="fn"%>

<%@ page isELIgnored ="false" %> 

<%@ page import="java.util.ResourceBundle" %>
<%@ page import="java.util.Locale" %>
<%@ page import="java.util.Enumeration" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %>

<%@ page import="java.text.SimpleDateFormat"%>

<%@ page import="javax.portlet.PortletSession"%>

<%@ page import="com.liferay.portal.kernel.dao.orm.QueryUtil"%>
<%@ page import="com.liferay.portal.kernel.util.ParamUtil"%>
<%@ page import="com.liferay.portal.kernel.util.LocaleUtil"%>

<%@ page import="net.opentrends.caoc.portlet.valisa.util.*"%>
<%@ page import="net.opentrends.caoc.portlet.valisa.model.*"%>
<%@ page import="net.opentrends.caoc.portlet.valisa.support.model.*" %>
<%@ page import="net.opentrends.caoc.portlet.valisa.portlet.missatges.*"%>

<liferay-theme:defineObjects />
<portlet:defineObjects />

<%
ResourceBundle resourceBundle = portletConfig.getResourceBundle(locale);
PropsUtil mailProperties = PropsUtil.getInstance("/email.properties");
int maxFileSize = Integer.valueOf(mailProperties.getProperty("email.valisa.maxAttachmentSize"));
String maxFileSizeText = mailProperties.getProperty("email.valisa.maxAttachmentSize.text");
int maxTotalFilesSize = Integer.valueOf(mailProperties.getProperty("email.valisa.maxTotalAttachmentSize"));
String maxTotalFilesSizeText = mailProperties.getProperty("email.valisa.maxTotalAttachmentSize.text");
%>
<script type="text/javascript">
<!--
// Variables
var midaMaximaAnnex = <%= maxFileSize %>;
var midaMaximaAnnexText = '<%= maxFileSizeText %>';
var midaMaximaTotalAnnexos = <%= maxTotalFilesSize %>;
var missatgeErrorMidaMaximaCarregantAnnex = "No es pot carregar el document annex: la mida màxima admesa és de "+midaMaximaAnnexText + " per document.";
var midaMaximaTotalAnnexosText = '<%= maxTotalFilesSizeText %>';
var missatgeInfoMidaMaximaAnnexPermesa = "<p>Atenció, tingui en compte que en cas que els annexos superin la mida de  " + midaMaximaAnnexText + ", només s'enviarà el justificant com a annex del correu-e</p>";
var missatgeAlertaMidaMaximaTotalAnnexosSuperada = "<p>El document o documents annexos no s'enviaran perquè superen els " + midaMaximaTotalAnnexosText + " (màx. autoritzat)</p>";
var missatgeErrorMidaMaximaCarregantTotsAnnexos = "No es pot carregar el document annex: s'ha arribat al màxim de " + midaMaximaTotalAnnexosText + " permesos com a màxim per a tots els documents adjunts.";
var valisaContexte = "${pageContext.request.contextPath}";
//-->
</script>

<c:set var="usuari" value="${sessionScope.VALISA_USER_BEAN }"/>
<c:set var="menu" value="${sessionScope.VALISA_MENU_BEAN }"/>

<portlet:actionURL var="processActionURL" />

<portlet:actionURL var="ajaxProcessActionURL" windowState="exclusive" />

<portlet:actionURL var="safataEntradaURL">
    <portlet:param name="<%=WebKeys.VALISA_CMD%>" value="<%= WebKeys.VALISA_CMD_SAFATA_ENTRADA %>" />
</portlet:actionURL>

<portlet:actionURL var="safataHistoricEntradaURL">
    <portlet:param name="<%=WebKeys.VALISA_CMD%>" value="<%= WebKeys.VALISA_CMD_SAFATA_HISTORIC_ENTRADA %>" />
</portlet:actionURL>

<portlet:actionURL var="safataEnviadesURL">
    <portlet:param name="<%=WebKeys.VALISA_CMD%>" value="<%= WebKeys.VALISA_CMD_SAFATA_ENVIADES %>" />
</portlet:actionURL>

<portlet:actionURL var="safataHistoricEnviadesURL">
    <portlet:param name="<%=WebKeys.VALISA_CMD%>" value="<%= WebKeys.VALISA_CMD_SAFATA_HISTORIC_ENVIADES %>" />
</portlet:actionURL>

<portlet:actionURL var="safataNoLlegidesEnTerminiURL">
    <portlet:param name="<%=WebKeys.VALISA_CMD%>" value="<%= WebKeys.VALISA_CMD_SAFATA_NO_LLEGIDES_TERMINI %>" />
</portlet:actionURL>

<portlet:actionURL var="safataEsborranysURL">
    <portlet:param name="<%=WebKeys.VALISA_CMD%>" value="<%= WebKeys.VALISA_CMD_SAFATA_ESBORRANYS %>" />
</portlet:actionURL>

<portlet:actionURL var="safataVistiplausURL">
    <portlet:param name="<%=WebKeys.VALISA_CMD%>" value="<%= WebKeys.VALISA_CMD_SAFATA_VISTIPLAUS %>" />
</portlet:actionURL>

我知道我收到的许多错误都与缺少一些所需的tld有关,我尝试将这些tld添加到我的webinf/tld文件夹中,但从那时起,我开始在控制台上收到奇怪的错误消息,并且无法看到我的portlet工作(Portlet暂时不可用)。我现在得到的部署错误是关于这一行的:

代码语言:javascript
复制
ResourceBundle resourceBundle = portletConfig.getResourceBundle(locale);

Duplicate local variable resourceBundle__60: <portlet:defineObjects />__61: __62: <%__63: ResourceBundle resourceBundle = portletConfig.getResourceBundle(locale);

下面是我的portlet web-inf/tld文件夹中的tld:

代码语言:javascript
复制
aui.tld
c-rt.tld
liferay-portlet-ext.tld
liferay-security.tld
liferay-theme.tld
liferay-ui.tld
liferay-util.tld

我曾尝试将liferay portlet.tld添加到此文件夹,但也不起作用,正如您所看到的,这是我的web.xml,我在其中定义了portlet.tld

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" 

xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<display-name>Valisa</display-name>
<context-param>
    <param-name>company_id</param-name>
    <param-value>aoc</param-value>
</context-param>

<listener>
    <listener-class>com.liferay.portal.kernel.servlet.PortletContextListener</listener-class>
</listener>

<listener>
    <listener-class>net.opentrends.caoc.portlet.valisa.portlet.ListenerStartup</listener-class>
</listener>

<servlet>
    <servlet-name>valisa</servlet-name>
    <servlet-class>com.liferay.portal.kernel.servlet.PortletServlet</servlet-class>
    <init-param>
        <param-name>portlet-class</param-name>
        <param-value>net.opentrends.caoc.portlet.valisa.portlet.ValisaPortlet</param-value>
    </init-param>
    <load-on-startup>0</load-on-startup>
</servlet>
<servlet>
    <servlet-name>dwr-invoker</servlet-name>
    <servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
    <init-param>
        <param-name>debug</param-name>
        <param-value>true</param-value>
    </init-param>
</servlet>
    <servlet>
    <servlet-name>DescarregarDocumentAdjuntServlet</servlet-name>
    <servlet-class>cat.aoc.eacatpl.valisa.servlet.DescarregarDocumentAdjuntServlet</servlet-class>
</servlet>
<servlet>
    <servlet-name>ObtenirCorreuElectronicAjaxServlet</servlet-name>
    <servlet-class>cat.aoc.eacatpl.valisa.servlet.ObtenirCorreuElectronicAjaxServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>valisa</servlet-name>
    <url-pattern>/valisa2014-portlet/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>dwr-invoker</servlet-name>
    <url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>DescarregarDocumentAdjuntServlet</servlet-name>
    <url-pattern>/ajax/descarregarDocumentAdjunt</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>ObtenirCorreuElectronicAjaxServlet</servlet-name>
    <url-pattern>/ajax/obtenirCorreuContactes</url-pattern>
</servlet-mapping>


<jsp-config>    
    <taglib>
        <taglib-uri>http://java.sun.com/portlet</taglib-uri>
        <taglib-location>/WEB-INF/tld/liferay-portlet.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://liferay.com/tld/theme</taglib-uri>
        <taglib-location>/WEB-INF/tld/liferay-theme.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://liferay.com/tld/ui</taglib-uri>
        <taglib-location>/WEB-INF/tld/liferay-ui.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://liferay.com/tld/util</taglib-uri>
        <taglib-location>/WEB-INF/tld/liferay-util.tld</taglib-location>
    </taglib>
</jsp-config>

任何帮助都将不胜感激。

EN

回答 2

Stack Overflow用户

发布于 2015-09-03 23:34:16

  1. TLDs

Liferay在部署时自动添加TLD。只需查看容器中已部署的portlet的目录,例如在tomcat中,它将是${catalina.home}/webapps/your-portlet (它还稍微改变了web.xml,您可以将其视为更好地理解Liferay)。

当然,Eclipse不会知道这一点,但是如果您将您的TLD放在完全相同的位置,则应该没问题。请确保为正确的Liferay版本使用TLDs您可以简单地使用在部署的portlet中找到的TLD。

  1. 无法解析的变量

Eclipse也很难推断出来自不同标签的所有副作用。很可能一切都很好,因为localeportletConfig是由defineObjects标记添加的,我可以看到您的JSP中确实有。这些警告很烦人,但我真的不知道是否有人能做些什么。

  1. The exception

正如其中一条注释中提到的,您可能会尝试定义一个已在其他地方定义的变量。可能在某个标记中,如第2点所述。要么重命名变量,要么删除赋值并使用已定义的变量。

票数 1
EN

Stack Overflow用户

发布于 2015-09-03 23:30:42

尝试在您的web.xml中更改此设置:

代码语言:javascript
复制
<taglib>
    <taglib-uri>http://java.sun.com/portlet</taglib-uri>
    <taglib-location>/WEB-INF/tld/liferay-portlet.tld</taglib-location>
</taglib>

并将其替换为

代码语言:javascript
复制
<taglib>
    <taglib-uri>http://java.sun.com/portlet_2_0</taglib-uri>
    <taglib-location>/WEB-INF/tld/liferay-portlet.tld</taglib-location>
</taglib>

因为portlet_2_0是这个标记库的实际namespace。清洗重复-这将开始摆脱最初的错误-因为它是关于编译的,通常修复根本原因会修复更多的东西。如果没有,请报告。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32370896

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档