简体   繁体   English

Liferay Portlet部署Java错误

[英]Liferay portlet deployment Java Error

Im having problems trying to deploy a portlet in Liferay 6.2. 我在尝试在Liferay 6.2中部署portlet时遇到问题。 I'm really new to JAVA and also with dealing with this kind of errors so forgive me if im kind of naive when it comes to dealing with this issues. 我真的是JAVA的新手,而且还处理这种错误,因此请原谅我,如果我在处理此问题时有点天真。

These are the errors that im getting on Eclipse: 这些是我在Eclipse上遇到的错误:

Can not find the tag library descriptor for " http://java.sun.com/portlet ", regarding this line: 关于此行,找不到“ http://java.sun.com/portlet ”的标记库描述符:

<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>

Im also getting an alert: "Unknown tag (portlet:defineObjects)" regarding this line: 我还收到一条警报:关于此行的“未知标签(portlet:defineObjects)”:

<portlet:defineObjects />

And finally this error "Multiple annotations found at this line:locale cannot be resolved to a variable, portletConfig cannot be resolved" regarding this line: 最后,关于此行的错误“在此行找到的多个注释:语言环境无法解析为变量,portletConfig无法解析”:

ResourceBundle resourceBundle = portletConfig.getResourceBundle(locale);

Heres my init.jsp (please read my notes at the end): 这是我的init.jsp(请最后阅读我的注释):

<%@ 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>

I know that a lot of the errors im getting are related to the absence of some tlds needed, i have tried to add those tlds to my webinf/tld folder but since then im starting to get weird ERROR messages on the console and not able to see my portlet working (Portlet Temporarily Unavailable). 我知道我收到的许多错误与缺少所需的tlds有关,我曾尝试将这些tlds添加到我的webinf / tld文件夹中,但此后我开始在控制台上收到奇怪的错误消息,并且无法看到我的Portlet工作正常(Portlet暂时不可用)。 The deployement error that im getting now is this regarding this line: 我现在得到的关于此行的部署错误是这样的:

ResourceBundle resourceBundle = portletConfig.getResourceBundle(locale);

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

These are the TLD's i have on my portlet web-inf/tld folder: 这些是我在portlet的web-inf / tld文件夹中拥有的TLD:

aui.tld
c-rt.tld
liferay-portlet-ext.tld
liferay-security.tld
liferay-theme.tld
liferay-ui.tld
liferay-util.tld

I have tried to add the liferay-portlet.tld to this folder but it didn't work either, this is my web.xml where as you can see i define the portlet.tld 我试图将liferay-portlet.tld添加到此文件夹,但是它也不起作用,这是我的web.xml,如您所见,我在其中定义了portlet.tld

<?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>

Any help will be REALLY appreciated. 任何帮助将不胜感激。

Try changing this in your web.xml: 尝试在web.xml中更改此设置:

<taglib>
    <taglib-uri>http://java.sun.com/portlet</taglib-uri>
    <taglib-location>/WEB-INF/tld/liferay-portlet.tld</taglib-location>
</taglib>

and replace it with 并替换为

<taglib>
    <taglib-uri>http://java.sun.com/portlet_2_0</taglib-uri>
    <taglib-location>/WEB-INF/tld/liferay-portlet.tld</taglib-location>
</taglib>

because portlet_2_0 is the actual namespace of this taglibrary. 因为portlet_2_0是此标记库的实际名称空间 Rinse repeat - this will start getting rid of the first mistakes - as it's about compilation, often fixing the root cause fixes more stuff. 冲洗重复-这将开始摆脱第一个错误-因为它是关于编译的,因此经常解决根本原因可以解决更多的问题。 Report back if it doesn't. 如果没有,请报告。

  1. TLDs 顶级域名

Liferay adds TLDs automatically on deployment. Liferay在部署时自动添加TLD。 Just take a look at the deployed portlet's directory in your container, eg in tomcat it would be ${catalina.home}/webapps/your-portlet (it also changes web.xml a bit, you can take look as ot better understand Liferay). 只需查看容器中已部署的Portlet的目录即可,例如,在tomcat中,目录为${catalina.home}/webapps/your-portlet (它也会稍微更改web.xml,您可以看一下以更好地了解Liferay )。

Of course Eclipse won't know about this, but if you put your TLDs in exactly the same place you should be fine. 当然,Eclipse对此一无所知,但是如果将TLD放在完全相同的位置,那应该没问题。 Be sure to use TLDs for correct Liferay version – you can simply use the ones you will find in deployed portlet. 确保为正确的Liferay版本使用TLD-您可以简单地使用在已部署的Portlet中找到的TLD。

  1. Unresolvable variables 无法解析的变量

Eclipse also has a hard time inferring all the side effects from different tags. Eclipse很难推断出不同标签的所有副作用。 Everything is most probably fine, as locale and portletConfig are added by the defineObjects tag I can see you do have in your JSP. 一切都可能很好,因为localeportletConfig是由defineObjects标记添加的,我可以看到您在JSP中确实有。 These warnings are annoying but I don't really know if one can do something about them. 这些警告很烦人,但我真的不知道是否有人可以对此做些什么。

  1. The exception 例外

As mentioned in one of the comments, you probably try to define a variable that is already defined elsewhere. 如其中一条注释中所述,您可能尝试定义一个已在其他位置定义的变量。 Probably in some tag, as mentioned in point 2. Either rename your variable or delete your assignment and use the one already defined. 如第2点所述,可能在某个标记中。要么重命名变量,要么删除您的赋值,然后使用已经定义的变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM