Vamos a crear un portlet con un poquito de chicha utilizando Liferay IDE, no es el típico hola mundo, sino un pequeño formulario, así aprenderemos como procesar un formulario con Liferay.
Lo primero será crear el portlet, como vemos aquí:
Lo añadimos a Tomcat.
Con esto tenemos creado un portlet “Hola mundo”, pero vamos a ir un poco más allá, vamos a procesar un formulario para ver cómo se trabaja con los distintos modos del portlet y así tener un portlet con algo de funcionalidad.
Lo primero que vamos a hacer es crear una clase llamada UserRegistrationPortlet que extienda a GenericPortlet, esta clase estará dentro de la carpeta src, en el paquete com.jesuslc
Aunque antes vamos a explicar un poco el diseño del portlet.
Construiremos un portlet como este, donde tenemos un formulario con 3 cajas de texto y con 2 botones (enviar y reset). Además carga el dominio por defecto (especificado en portlet.xml) (@liferay.com)
Solo tiene un campo obligatorio (email) si lo rellenamos todo nos muestra los datos así. Este portlet no guarda nada en base de datos, solo muestra los datos del formulario.
Como vimos en otro post tenemos 3 modos (VIEW,EDIT y HELP) el modo view es que vemos al arrastrar el portlet a Liferay, los otros dos modos los explicaremos más adelante.
Para que todo nos quede claro, este es el diagrama de flujo del portlet.
Ahora vamos manos a la obra.
Lo primero es sobrescribir el método init() para que aparezca por defecto el dominio.
Después creamos los métodos para renderizar cada uno de los modos. Así que vallamos por partes.
Creamos el método renderForm para renderizar VIEW, esté método comprueba que primero si estamos en la página 2 (con los datos metidos) de ser así nos redirige a la página “success.jsp” (no creada), después comprueba si ha habido error al procesar el formulario (email no válido), en este caso muestra el mensaje de error. Si todo ha ido bien es que estamos al principio, es decir, el método nos lleva a la página de inicio (registration.jsp)
package com.jesuslc; import java.io.IOException; import java.util.ResourceBundle; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.GenericPortlet; import javax.portlet.PortletException; import javax.portlet.PortletURL; import javax.portlet.ProcessAction; import javax.portlet.RenderMode; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; /** * UseRegistrationPortlet class extends the GenericPortlet abstract class to * implement the portlet functionality. * * @author jesuslc * */ public class UserRegistrationPortlet extends GenericPortlet { private String defaultEmail; /* * Overrides the init method of the GenericPortlet class to obtain the value * of the defaultEmail initialization parameter specified in portlet.xml * file. (non-Javadoc) * * @see javax.portlet.GenericPortlet#init() */ public void init() { defaultEmail = getPortletConfig().getInitParameter("defaultEmail"); } /** * Renders the registration form or success JSP based on the value of * request attribute actionStatus. * * @param request * @param response * @throws PortletException * @throws IOException */ @RenderMode(name = "VIEW") public void renderForm(RenderRequest request, RenderResponse response) throws PortletException, IOException { // -- dispatch request to success.jsp if actionStatus is success if ("success".equalsIgnoreCase((String) request .getAttribute("actionStatus"))) { PortletURL homeUrl = response.createRenderURL(); request.setAttribute("homeUrl", homeUrl); getPortletContext() .getRequestDispatcher("/WEB-INF/jsp/success.jsp").include( request, response); return; } // -- create action and render URLs for the registration form. // -- Reset hyperlink fires a render request and Submit button // -- results in an action request PortletURL registerUserActionUrl = response.createActionURL(); registerUserActionUrl.setParameter(ActionRequest.ACTION_NAME, "registerUserAction"); PortletURL resetRenderUrl = response.createRenderURL(); request.setAttribute("registerUserActionUrl", registerUserActionUrl); request.setAttribute("resetRenderUrl", resetRenderUrl); // -- if actionStatus is error then show the registration form populated // -- with values that were entered by the user if (!"error".equalsIgnoreCase((String) request .getAttribute("actionStatus"))) { request.setAttribute("email", defaultEmail); } getPortletContext().getRequestDispatcher( "/WEB-INF/jsp/registrationForm.jsp").include(request, response); } /** * Registers the user with the system. The current implementation of this * method doesn't save user information. * * @param request * @param response * @throws PortletException * @throws IOException */ @ProcessAction(name = "registerUserAction") public void registerUser(ActionRequest request, ActionResponse response) throws PortletException, IOException { String email = request.getParameter("email"); // --set the information entered by the user on the registration // --form as request attribute. // -- NOTE : You can't transfer complex objects // -- from action request to render request using setRenderParameter //-- method request.setAttribute("user", new User( request.getParameter("firstName"), request .getParameter("lastName"), email)); //-- if email is not entered, show an error message. the //-- message is read from the resource bundle and forwarded //-- to render request as request attribute if (email == null || email.trim().equals("")) { ResourceBundle bundle = getPortletConfig().getResourceBundle( request.getLocale()); request.setAttribute("errorMsg", bundle .getString("email.errorMsg.missing")); //--set actionStatus to error request.setAttribute("actionStatus", "error"); } else { // --save the user information in the database - not implemented yet // -- to show the success page, pass the information of success to // render method request.setAttribute("actionStatus", "success"); } } /** * Renders the preferences page for the portlet. * * @param request * @param response * @throws PortletException * @throws IOException */ @RenderMode(name = "EDIT") public void renderPrefs(RenderRequest request, RenderResponse response) throws PortletException, IOException { getPortletContext() .getRequestDispatcher("/WEB-INF/jsp/preferences.jsp").include( request, response); } /** * Renders the help page for the portlet. * * @param request * @param response * @throws PortletException * @throws IOException */ @RenderMode(name = "HELP") public void renderHelp(RenderRequest request, RenderResponse response) throws PortletException, IOException { getPortletContext().getRequestDispatcher("/WEB-INF/jsp/help.jsp") .include(request, response); } }
Ahora tenemos que crear el método que procesa el formulario (@ProcessAction(name = «registerUserAction») este método lo único que hace es establecer las variables con los valores recogidos en el formulario y crear un objeto de la Clase User (todavía no la hemos creado), por tanto dará un error.
Consejo: Puede que por defecto se nos importe un clase del paquete HSQLDB, eliminar ese import. Lo que nosotros queremos es crear la clase User.
Creamos la Clase User con un constructor con 3 parámetros, hacemos que implemente Serializable, también creamos los métodos getter.
package com.jesuslc.userregistration; import java.io.Serializable; public class User implements Serializable { private static final long serialVersionUID = 1309605526151913956L; private String firstName; private String lastName; private String email; public User(String parameter, String parameter2, String email) { firstName = parameter; lastName = parameter2; this.email = email; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } }
En este momento ya podemos crear nuestra primera página JSP, para ello creamos un nuevo archivo JSP dentro de WEB-INF/jsp
Y este es el formulario que tenemos que crear:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@ page contentType="text/html" isELIgnored="false" %> <fmt:setBundle basename="content.Language"/> <form action="<c:out value='${requestScope.registerUserActionUrl}'/>" method="POST"> <table width="200px"> <tr> <td colspan="2"> <font color="#FF0000"><c:out value="${requestScope.errorMsg}"/></font> </td> </tr> <tr> <td><fmt:message key="label.firstName"/></td> <td><input type="text" name="firstName" value="${requestScope.user.firstName}"></input></td> </tr> <tr> <td> </td> </tr> <tr> <td><fmt:message key="label.lastName"/></td> <td><input type="text" name="lastName" value="${requestScope.user.lastName}"></input></td> </tr> <tr> <td> </td> </tr> <tr> <td><font color="#FF0000"><b>*</b></font> <fmt:message key="label.email"/></td> <td><input type="text" name="email" value="${requestScope.email}"></input></td> </tr> <tr> <td> </td> </tr> <tr align="center"> <td colspan="2"> <input type="submit"/> <a href="<c:out value='${requestScope.resetRenderUrl}'/>"> <b><fmt:message key="label.reset"/></b> </a> </td> </tr> </table> </form>
TIP: Puede que nos aparezca un error como este “Can not find the tag library descriptor for http://java.sun.com/jsp/jstl/core ” tan solo debemos copiar estas librerías en la carpeta lib
De la misma forma que hemos creado registrationForm.jsp, creamos ahora success.jsp. Esta página es la que se muestra después de rellenar el formulario y pulsar en “Enviar”.
Este es el código:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@ page contentType="text/html" isELIgnored="false" %> <fmt:setBundle basename="content.Language"/> <table> <tr> <td colspan="2"><fmt:message key="success.message"/></td> </tr> <tr> <td align="right"><b><fmt:message key="label.firstName"/></b></td> <td><c:out value="${requestScope.user.firstName}"/></td> </tr> <tr> <td align="right"><b><fmt:message key="label.lastName"/></b></td> <td><c:out value="${requestScope.user.lastName}"/></td> </tr> <tr> <td align="right"><b><fmt:message key="label.email"/></b></td> <td><c:out value="${requestScope.user.email}"/></td> </tr> <tr> <td colspan="3"> <a href="<c:out value='${requestScope.homeUrl}'/>"> <b><fmt:message key="label.home"/></b> </a> </td> </tr> </table>
Volvemos a hacer lo mismo para crear help.jsp
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<fmt:setBundle basename="content.Language"/>
<table width="200px">
<tr>
<td>
<fmt:message key="help.message"/>
</td>
</tr>
</table>
Y por último para preferences.jsp
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<fmt:setBundle basename="content.Language"/>
<table width="200px">
<tr>
<td>
<fmt:message key="preferences.message"/>
</td>
</tr>
</table>
TIP: Puede algunas cosas os parezcan raras, pero no os preocupéis. En sucesivos post iré entrando más a fondo en cada uno de los componentes de un portlet.
Ahora vamos a crear un archivo para el soporte del idioma. Como hemos visto los elementos que aparecen por pantalla como “Last name” aparecen en distintos archivos, por ello lo mejor es tener un punto común. Un archivo de properties que podemos modificar y que se modifiquen todos los items. Este archivo servirá en un futuro para explicar los portlets multiidioma.
Por ello ahora debemos crear un nuevo package llamado content que cuelga del proyecto y dentro de ese nuevo package un archivo llamado languaje.properties así.
Este archivo tiene el siguiente contenido:
category.com.jesuslc=Demos Jesus LC
javax.portlet.title=Test Register
label.registerUser=Register
label.reset=Reset
label.firstName=First Name
label.lastName=Last Name
label.email=Email:
label.home=Home
email.errorMsg.missing=Please enter Email
success.message=User information successfully saved
preferences.message=No personalization options available for the portlet
help.message=This is a help message
*Es importante que añadamos esa carpeta (content) al builth path, así que tan solo tenemos que pulsar botón derecho y…
Ya solo nos queda configurar el archivo portlet.xml de la siguiente manera:
<?xml version="1.0"?> <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0"> <portlet> <portlet-name>UserRegistration</portlet-name> <display-name>UserRegistration</display-name> <portlet-class>com.jesuslc.UserRegistrationPortlet</portlet-class> <init-param> <name>defaultEmail</name> <value>@liferay.com</value> </init-param> <supports> <mime-type>text/html</mime-type> <portlet-mode>VIEW</portlet-mode> <portlet-mode>EDIT</portlet-mode> <portlet-mode>HELP</portlet-mode> </supports> <resource-bundle>content.Language</resource-bundle> <container-runtime-option> <name>javax.portlet.actionScopedRequestAttributes</name> <value>true</value> </container-runtime-option> </portlet> </portlet-app>
Por otro lado configuramos el archivo portlet-liferay.xml así:
<?xml version="1.0"?> <!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.1.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_1_0.dtd"> <liferay-portlet-app> <portlet> <portlet-name>UserRegistration</portlet-name> <icon>/icon.png</icon> <instanceable>true</instanceable> <remoteable>true</remoteable> <header-portlet-css>/css/main.css</header-portlet-css> <footer-portlet-javascript>/js/main.js</footer-portlet-javascript> <css-class-wrapper>UserRegistration-portlet</css-class-wrapper> </portlet> </liferay-portlet-app>
Ya tenemos nuestro portlet listo para que funcione. Esto será lo que tenemos:
Referencias
- Libro Manning Portlets in Action de A. Sarin
– http://www.liferay.com/es/community/wiki/-/wiki/Main/Localization+of+Portlets+Outside+of+Liferay
Saludos Jesus estoy tratando de ejecutar este protlet en mi liferay 6.1 el terminar todos los pasos voy a cargar mi portlet del repositorio para colocarlo en la pagina y el portlet muestra el siguiente mensaje «UserRegistration no está disponible temporalmente» investigando un poco en el log del servidor dice «22:44:38,529 ERROR [http-bio-8080-exec-4][render_portlet_jsp:157] org.apache.jasper.JasperException: La uri absoluta: http://java.sun.com/jsp/jstl/core no puede resolverse o en web.xml o el los archivos jar desplegados con esta aplicación» seguí investigando en desarrolloweb.com y dicen que pueda ser por mis librerías añadidas al classpath pero la verdad creo que están bn muchas gracias por tu atencion.
Me gustaMe gusta
Voy a realizar una serie de suposiciones, ya que con la información que proporcionas es un poco complicado dar con la respuesta.
Supongo que:
-Tienes instalado Liferay sobre MySQL de manera estandar y que este funciona correctamente.
– Tienes instalado Liferay IDE (plugin de Eclipse) y que al crear un nuevo portlet vacío y hacer un deploy con la tarea Ant, el portlet se crea y visualiza correctamente en el portal.
– Esta correctamente configurado el class path con las librerías .jar
– Están bien configurados los taglib en los archivos JSP y tambien en el archivo de configuración.
Si todo esto está OK debería funcionar correctamente.
Por lo que comentas parece algo del ultimo punto, no estan configurados los tag libs.
Un saludo y espero haberte ayudado
Me gustaMe gusta
Hola Jesús,
mi único problema es que a la hora de añadir el portlet en la página este no me aparece en la ventana de «añadir» y no me ha dado ningún problema en el proyecto de Eclipse.
Un saludo!
Me gustaMe gusta
Eso es que ha habido algún problema con el deploy en tomcat. Échale un vistazo a los logs de Tomcat para comprobar si hubo algún error
Me gustaMe gusta
El .war lo creo incluso a parte y nada… te dejo en este enlace a nuestro gran amigo el «chorizo»
http://pastebin.com/QYekbt9Q
Ahora me sale para añadirlo pero no funciona solo me da ese pedazo de salida en Eclipse :S,
Gracias!
Me gustaMe gusta
Según veo en el lógica, hay algún problema don el jslt, quizás no esté bien configurado.
Por sí te sirve de ayuda en mi cuenta de github https://github.com/jeslopcru está el código de este post.
Un saludo
Me gustaMe gusta
Hola Jesús,
Llevo varios días peleándome con este portlet y he tenido varios problemas, algunos de ellos los he podido solucionar y otros no.
Estoy en una fase en la que me ocurre lo siguiente: puedo añadir el portlet a liferay si no modifico los ficheros .xml, tanto el portlet.xml como el porlet-liferay.xml (que curiosamente en mi proyecto se llama al revés, liferay-portlet.xml).
¿Qué explicación puede tener?
Por otra parte, cuando lo añado (sin añadir el código que comentas a los xml), únicamente puedo ver un mensaje que dice «This is the UserRegistration portlet». Dicho código he investigado que se carga en el view.xml que está en la raíz del proyecto. En ningún momento consigo que se cargue el formulario.
Además de todo esto, también existen varias excepciones en los ficheros jsp que dicen: «Unknown tag (c:out)» y «Unknown tag (fmt:message)».
Y ya por último, cuando inicio Tomcat, en la consola me sale el siguiente mensaje:
log4j:ERROR Could not instantiate class [org.apache.log4j.EnhancedPatternLayout].
java.lang.SecurityException: class «org.apache.log4j.EnhancedPatternLayout»‘s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(Unknown Source)
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:179)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:320)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:121)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:676)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:647)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:544)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:440)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:476)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:471)
at org.apache.log4j.LogManager.(LogManager.java:125)
at org.apache.log4j.Logger.getLogger(Logger.java:105)
at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:262)
at org.apache.commons.logging.impl.Log4JLogger.(Log4JLogger.java:108)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(LogFactoryImpl.java:1116)
at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:914)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:604)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:336)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:310)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
at org.apache.commons.configuration.AbstractFileConfiguration.(AbstractFileConfiguration.java:121)
at org.apache.commons.configuration.AbstractFileConfiguration.(AbstractFileConfiguration.java:136)
at org.apache.commons.configuration.PropertiesConfiguration.(PropertiesConfiguration.java:237)
at com.liferay.portal.configuration.easyconf.ClassLoaderAggregateProperties._addFileProperties(ClassLoaderAggregateProperties.java:155)
at com.liferay.portal.configuration.easyconf.ClassLoaderAggregateProperties._addPropertiesSource(ClassLoaderAggregateProperties.java:263)
at com.liferay.portal.configuration.easyconf.ClassLoaderAggregateProperties.addGlobalFileName(ClassLoaderAggregateProperties.java:76)
at com.liferay.portal.configuration.easyconf.ClassLoaderComponentConfiguration._getAvailableProperties(ClassLoaderComponentConfiguration.java:115)
at com.liferay.portal.configuration.easyconf.ClassLoaderComponentConfiguration.getProperties(ClassLoaderComponentConfiguration.java:77)
at com.liferay.portal.configuration.ConfigurationImpl.getComponentProperties(ConfigurationImpl.java:414)
at com.liferay.portal.configuration.ConfigurationImpl.printSources(ConfigurationImpl.java:429)
at com.liferay.portal.configuration.ConfigurationImpl.(ConfigurationImpl.java:78)
at com.liferay.portal.configuration.ConfigurationImpl.(ConfigurationImpl.java:55)
at com.liferay.portal.configuration.ConfigurationFactoryImpl.getConfiguration(ConfigurationFactoryImpl.java:32)
at com.liferay.portal.kernel.configuration.ConfigurationFactoryUtil.getConfiguration(ConfigurationFactoryUtil.java:27)
at com.liferay.portal.deploy.hot.PluginPackageHotDeployListener.initServiceComponent(PluginPackageHotDeployListener.java:206)
at com.liferay.portal.deploy.hot.PluginPackageHotDeployListener.doInvokeDeploy(PluginPackageHotDeployListener.java:132)
at com.liferay.portal.deploy.hot.PluginPackageHotDeployListener.invokeDeploy(PluginPackageHotDeployListener.java:61)
at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:205)
at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:96)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:27)
at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(PluginContextListener.java:164)
at com.liferay.portal.kernel.servlet.PluginContextListener.doPortalInit(PluginContextListener.java:154)
at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:44)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:64)
at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:56)
at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:54)
at com.liferay.portal.kernel.servlet.PluginContextListener.contextInitialized(PluginContextListener.java:116)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:656)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1635)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
feb 20, 2014 1:15:10 PM org.apache.catalina.core.ApplicationContext log
Información: Initializing Spring root WebApplicationContext
13:15:10,854 INFO [localhost-startStop-10][PortletHotDeployListener:343] Registering portlets for UserRegistration-portlet
13:15:10,961 INFO [localhost-startStop-10][PortletHotDeployListener:490] 1 portlet for UserRegistration-portlet is available for use
MUCHAS GRACIAS.
Me gustaMe gusta
Gracias por comentar, yo para generar los portlets utilice el plugin de eclipse de Liferay, es bastante cómodo y genera la mayor parte de los archivos necesarios.
En mi cuenta de github (github.com/jeslopcru) están todos los ejemplos del blog, espero que te sirvan 😉
Sobre el log que adjuntas, no veo nada claro lo que puede ser, por eso no puedo daré una respuesta clara.
Me gustaMe gusta
Hola Jesús.
He seguido este tutorial paso a paso, pero me ha salido un aviso cuando compilo con el ant y después un error a la hora de refrescar la página web de liferay (localhost:8080).
El aviso es este:
21:40:11,368 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][BaseDeployer:859] Deploying calculadora-portlet-6.2.0.1.war
21:40:11,369 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][BaseDeployer:962] Updating Calculadora from version 6.2.1 to version 6.2.0.1
21:40:11,369 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][BaseDeployer:971] Not updating Calculadora because version 6.2.1 is newer than version 6.2.0.1
Y el error (con excepción incluida) es este:
23:04:40,594 ERROR [http-bio-8080-exec-10][IncludeTag:129] Current URL /web/guest/welcome?p_p_id=145&p_p_lifecycle=0&p_p_state=exclusive&p_p_mode=view&_145_stateMaximized=false&_145_viewEntries=true&_145_struts_action=%2Fdockbar%2Fadd_panel generates exception: null
java.lang.NullPointerException
at org.apache.jsp.html.portlet.dockbar.view_005fcategory_jsp._jspService(view_005fcategory_jsp.java:741)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at com.liferay.portal.servlet.DirectRequestDispatcher.include(DirectRequestDispatcher.java:57)
at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.doDispatch(ClassLoaderRequestDispatcherWrapper.java:78)
at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.include(ClassLoaderRequestDispatcherWrapper.java:53)
at com.liferay.taglib.util.IncludeTag.include(IncludeTag.java:295)
at com.liferay.taglib.util.IncludeTag.doInclude(IncludeTag.java:192)
at com.liferay.taglib.util.IncludeTag.doEndTag(IncludeTag.java:83)
at org.apache.jsp.html.portlet.dockbar.add_005fapplication_jsp._jspService(add_005fapplication_jsp.java:990)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
He supuesto que el error y la excepción son fruto de las notificaciones anteriores, pero no veo manera de solucionarlo.
El entorno que utilizo es:
IDE: eclipse luna.
Tomcat: Tomcat 7.0.42
Liferay: liferay-portal-6.2-ce-ga2
Gracias.
Me gustaMe gusta
Lo primero gracias comentar 🙂
Así a bote pronto no sabría decirte que es lo que está pasando. Yo lo que haría sería eliminar todos los portlets que tengas en esa página y solo tener el que estás desarrollando. Con ello conseguirás evitar cualquier colisión/inconveniente con otros portlets.
En mi cuenta de github está subido el proyecto (https://github.com/jeslopcru/PortletsDemos) así que puedes echarle un vistazo al código por si te sirve de ayuda.
Un saludo
Me gustaMe gusta
Hola
Donde puedo descargar las librerias, estoy usando la version 6.1.1?
Me gustaMe gusta
Tienes todo el código del proyecto en mi cuenta de github
Me gustaMe gusta
Ok!! Muchas gracias. En realidad, al final ya lo solucioné… no sé muy bien lo que hice, pero creo que fue eliminar el paso 2: Añadirlo al Tomcat. Simplemente con indicarle, durante el proceso de creación del plugin, que el servidor es el que se había instanciado, no hacer falta hacer ese otro paso. Gracias.
Me gustaMe gusta