Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Liferay portlet deployment Java Error

Im having problems trying to deploy a portlet in Liferay 6.2. 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.

These are the errors that im getting on Eclipse:

Can not find the tag library descriptor for "http://java.sun.com/portlet", regarding this line:

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

Im also getting an alert: "Unknown tag (portlet:defineObjects)" regarding this line:

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

ResourceBundle resourceBundle = portletConfig.getResourceBundle(locale);

Heres my init.jsp (please read my notes at the end):

<%@ 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). 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:

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

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

like image 408
Lowtrux Avatar asked Aug 07 '26 11:08

Lowtrux


1 Answers

  1. TLDs

Liferay adds TLDs automatically on deployment. Just take a look at the deployed portlet's directory in your container, e.g. 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).

Of course Eclipse won't know about this, but if you put your TLDs in exactly the same place you should be fine. Be sure to use TLDs for correct Liferay version – you can simply use the ones you will find in deployed portlet.

  1. Unresolvable variables

Eclipse also has a hard time inferring all the side effects from different tags. Everything is most probably fine, as locale and portletConfig are added by the defineObjects tag I can see you do have in your 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.

like image 176
Michal M Avatar answered Aug 10 '26 00:08

Michal M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!