5 Replies Latest reply on Sep 13, 2010 4:17 AM by Somnath Mallick

    New to GateIn 3.1.... Need Help Starting Off...

    Somnath Mallick Newbie

      Hi Everyone,


         I have some POC work to design a new Portal in GateIn. I will be Eclipse Helios package. Since I am new this will be a mixed question about Eclipse and GateIn. So kindly help me out. So far I have not had any luck in creating Portals in Eclipse and GateIn. I have searched a whole bunch of plugins for Eclipse to create portlets. But none of them worked. So here's what I did:

      1. I created a Dynamic Web Project in eclipse.

      2. Created a Hello World portlet.

      3. Created a portlet.xml file in the WEB-INF folder.

      4. Created the WAR of the project.

      5. Deployed the WAR in the JBoss Application Server.

      6. But I did not see the the portlet show up in the Application Registry page of  the GateIn.


      Am I doing something wrong here? Please do let me know. If you guys need any other info, i'll be glad to provide it.

        • 1. Re: New to GateIn 3.1.... Need Help Starting Off...
          Trong Tran Master

          Assume that you have implemented the Hello World portlet correctly, I let you check some points :

           

          1. Ensure the Hello World portlet is declared correctly in portlet.xml  file

           

          2. Make sure your web.xml file includes :

           

             <!-- This for portlet registration in GateIn -->
             <servlet>
                <servlet-name>PortletWrapper</servlet-name>
                <servlet-class>org.exoplatform.services.portletcontainer.impl.servlet.ServletWrapper</servlet-class>
             </servlet>
             <servlet-mapping>
                <servlet-name>PortletWrapper</servlet-name>
                <url-pattern>/PortletWrapper</url-pattern>
             </servlet-mapping>
          

           

          3. In Application Registry page, the portlet could be imported by clicking on the "Import Applications" button

          • 2. Re: New to GateIn 3.1.... Need Help Starting Off...
            Matt Wringe Master

            You do not need to add anything special to the web.xml, your web.xml can be just an empty <web-app></web-app> and GateIn will still pick up your portlets (assuming of course your web-application itself doesn't need anything add here). Just leave the web.xml alone.

             

            You can add the GateInServlet to the web.xml if you want, but its not going to do anything special (its mainly meant for testing purposes and if people want to run some sort of custom setup on non-supported web containers):

             

              <servlet>
                  <servlet-name>GateInServlet</servlet-name>
                  <servlet-class>org.gatein.wci.api.GateInServlet</servlet-class>
                  <load-on-startup>1</load-on-startup>
               </servlet>
               <servlet-mapping>
                  <servlet-name>GateInServlet</servlet-name>
                  <url-pattern>/gateinservlet</url-pattern>
               </servlet-mapping>
            

             

            The PortletWrapper was the way for doing things in eXo Portal, and is just a wrapper around the GateInServlet for backwards compatibility. So its not needed and is not going to do anything unless you are trying to run a custom setup. And the proper way to use PortletWrapper is to also include the PortletApplicationListener:

             

              <listener>
                <listener-class>org.exoplatform.services.portletcontainer.impl.servlet.PortletApplicationListener</listener-class>
              </listener>
            
              <servlet>
                <servlet-name>PortletWrapper</servlet-name>
                <servlet-class>org.exoplatform.services.portletcontainer.impl.servlet.ServletWrapper</servlet-class>
              </servlet>
            
              <servlet-mapping>
                <servlet-name>PortletWrapper</servlet-name>
                <url-pattern>/PortletWrapper</url-pattern>
              </servlet-mapping>
            

             

            Adding these extra listeners and servlets are just going to confuse people when they realise it works without them. They are not meant to be used in normal portlet applications.

            • 3. Re: New to GateIn 3.1.... Need Help Starting Off...
              Trong Tran Master

              You are right, Matt.

               

              I did not notice that point, thanks for your information.

              • 4. Re: New to GateIn 3.1.... Need Help Starting Off...
                Julien Viet Apprentice

                Actually this is incorrect, doing without the GateIn servlet is a facility solution but it is not portable accross all application servers.

                 

                Omitting the declaration works for Tomcat and JBoss Application Server version of GateIn but it might not work for other application servers in which GateIn could deploy in the future.

                • 5. Re: New to GateIn 3.1.... Need Help Starting Off...
                  Somnath Mallick Newbie

                  Thanks for your reply guys! Here is what i did after going through your posts. I have attached all the details needed. Please take a look and let me know if i did everything correctly. Here is my HelloWorldPortlet.java file:

                   

                  package com.test;
                  
                  import java.io.IOException;
                  import java.io.PrintWriter;
                  
                  import javax.portlet.GenericPortlet;
                  import javax.portlet.PortletConfig;
                  import javax.portlet.PortletException;
                  import javax.portlet.RenderRequest;
                  import javax.portlet.RenderResponse;
                  
                  public class HelloWorldPortlet extends GenericPortlet
                  {
                     
                    public void init(PortletConfig pConfig) throws PortletException
                    {
                      super.init(pConfig);
                    }
                   
                    public void doView(RenderRequest pRequest, RenderResponse pResponse)
                      throws PortletException, IOException
                    {
                      
                      pResponse.setContentType("text/html");
                      PrintWriter printWriter = pResponse.getWriter();
                      
                      printWriter.println("Hello, World");
                   
                    }  
                  }
                  

                   

                   

                  web.xml file:

                  <?xml version="1.0" encoding="UTF-8"?>
                  <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
                    <display-name>TempTry</display-name>
                    
                     <servlet>
                      <servlet-name>PortletWrapper</servlet-name>
                      <servlet-class>org.exoplatform.services.portletcontainer.impl.servlet.ServletWrapper</servlet-class>
                    </servlet>
                    
                    <servlet>
                        <servlet-name>GateInServlet</servlet-name>
                        <servlet-class>org.gatein.wci.api.GateInServlet</servlet-class>
                        <load-on-startup>1</load-on-startup>
                     </servlet>
                     
                     <servlet-mapping>
                      <servlet-name>PortletWrapper</servlet-name>
                      <url-pattern>/PortletWrapper</url-pattern>
                    </servlet-mapping>
                    
                    <servlet-mapping>
                        <servlet-name>GateInServlet</servlet-name>
                        <url-pattern>/gateinservlet</url-pattern>
                     </servlet-mapping>
                     
                    <listener>
                      <listener-class>org.exoplatform.services.portletcontainer.impl.servlet.PortletApplicationListener</listener-class>
                    </listener>
                      
                  </web-app>

                   

                   

                  Also my portelt.xml file.

                  <?xml version="1.0" encoding="UTF-8"?>
                  <portlet-app version="1.0" xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
                           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
                    <portlet>
                      <description xml:lang="EN">My First Hello World Portlet</description>
                      <portlet-name>HelloWorld</portlet-name>
                      <display-name xml:lang="EN">Hello World</display-name>
                      <portlet-class>com.test.HelloWorldPortlet</portlet-class>
                  
                      <expiration-cache>-1</expiration-cache>
                  
                      <supports>
                        <mime-type>text/html</mime-type>
                        <portlet-mode>view</portlet-mode>
                      </supports>
                  
                      <supported-locale>en</supported-locale>
                  
                      <portlet-info>
                        <title>Hello World</title>
                        <short-title>Hello</short-title>
                        <keywords>hello</keywords>
                      </portlet-info>
                    </portlet>
                  
                  </portlet-app>
                  

                   

                  I have also attached a small pic of my Eclipse packaging of the dynamic web project. Please a look at that as well. The project is named as TempTry. Any guidance would be appreciated.