4 Replies Latest reply on Jan 9, 2007 5:14 PM by Arnie Morein

    Error from JSF app deployed as portlet

    Arnie Morein Novice

      I have a working two-page JSF application which I'm trying to deploy as a portlet. The various XML files are built and being deployed, the new tab shows up when /portal/ is accessed. I have to tweak security a bit, but otherwise, the portlet seems to be auto-configuring correctly. The first page is a user login page only. The second page is where the inquiry is done. The top of the page has fields and a search and cancel buttons. If records are found, the form is repainted and the first 10 records (paged, up to a 100) are shown below the form.

      I've tried debugging to the first line of the method that is supposed be being called, but it is never invoked. The error seems to be coming from the JSF libraries.

      It works fine as a JSF app. I get the following error when I hit the "search" button in the portlet:


      2007-01-09 08:27:04,812 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/DpsLicenseInquiry]] Error calling action method of component with id jbpfe08a106_id6:cmdSubmit
      javax.faces.FacesException: Error calling action method of component with id jbpfe08a106_id6:cmdSubmit
      at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
      at javax.faces.component.UICommand.broadcast(UICommand.java:106)
      at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)

      ...

      Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{driverSearchBean.doSearch}
      at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153)
      at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
      ... 226 more
      Caused by: java.lang.ClassCastException: org.jboss.portal.portlet.impl.jsr168.PortletSessionImpl
      at us.tx.state.oag.DpsLicenseInquiry.DriverSearchBean.doSearch(DriverSearchBean.java:356)


      and the error repeats a few times. I've googled around and this error doesn't show up.

      JBoss XML Portal Files:

      <?xml version="1.0" encoding="UTF-8"?>
      <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_1.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"
       version="1.0">
      
       <portlet>
       <portlet-name>DpsLicenseInquiryPortlet</portlet-name>
       <display-name>DPS License Inquiry Portlet</display-name>
      
       <header-content>
       <link href="/resources/stylesheet.css" rel="stylesheet" type="text/css"/>
       <script type="text/javascript" src="/resources/toggleLayers.js"></script>
       </header-content>
      
       <portlet-class>org.apache.myfaces.portlet.MyFacesGenericPortlet</portlet-class>
      
       <init-param>
       <name>default-view</name>
       <value>/userLogin.jsp</value>
       </init-param>
      
       <supports>
       <mime-type>text/html</mime-type>
       <portlet-mode>VIEW</portlet-mode>
       </supports>
      
       <portlet-info>
       <title>DPS License Inquiry</title>
       </portlet-info>
      
       </portlet>
      
      </portlet-app>
      
      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <deployments>
       <deployment>
       <instance>
       <instance-id>DpsLicenseInquiryInstance</instance-id>
       <portlet-ref>DpsLicenseInquiryPortlet</portlet-ref>
       <security-constraint>
       <unchecked/>
       </security-constraint>
       </instance>
       </deployment>
      </deployments>
      
      <?xml version="1.0" encoding="UTF-8"?>
      <deployments>
       <deployment>
       <if-exists>overwrite</if-exists>
       <parent-ref>default.OAG Intranet</parent-ref>
       <window>
       <window-name>DpsLicenseInquiryWindow</window-name>
       <instance-ref>DpsLicenseInquiryInstance</instance-ref>
       <region>center</region>
       <height>1</height>
       </window>
       </deployment>
      </deployments>
      



        • 1. Re: Error from JSF app deployed as portlet
          Thomas Heute Master

          What's in:
          us.tx.state.oag.DpsLicenseInquiry.DriverSearchBean.doSearch(DriverSearchBean.java:356)
          ?

          • 2. Re: Error from JSF app deployed as portlet
            Arnie Morein Novice

            The code is below. But like I said, as a portlet, it never gets called (the debugger never stops there).

             public String doSearch () {
             // get the current user by pulling from the session object
             String ls_user_name = null; OagIdVaultAccount oagIdVaultAccount = null;
             ApplicationSecurity applicationSecurity = null;
             HttpSession lo_HttpSession = (HttpSession)FacesContext.getCurrentInstance().
             getExternalContext().getSession(false);
             Object lo_security = lo_HttpSession.getAttribute(DpsLicenseInquiryConstants.CS_VISIT_KEY);
             if ( lo_security instanceof OagIdVaultAccount ) {
             oagIdVaultAccount = (OagIdVaultAccount)lo_security;
             ls_user_name = oagIdVaultAccount.getCommonName();
             } else {
             applicationSecurity = (ApplicationSecurity)lo_security;
             ls_user_name = applicationSecurity.getUserLogin();
             }
             // reset the record pointer
             ci_rowIndex = 0;
             // bundle up the search criteria
             DpsDriverCriteria lo_DpsDriverCriteria = new DpsDriverCriteria();
             lo_DpsDriverCriteria.setLicenseNumber(cs_search_dl);
             lo_DpsDriverCriteria.setDriverName(cs_search_name);
             lo_DpsDriverCriteria.setDriverAddress(cs_search_address);
             lo_DpsDriverCriteria.setDriverCity(cs_search_city);
             lo_DpsDriverCriteria.setDriverClass(cs_search_class);
             lo_DpsDriverCriteria.setDriverDob(cs_search_dob);
             lo_DpsDriverCriteria.setUserName(ls_user_name);
             if ( !lo_DpsDriverCriteria.validCriteria() ) {
             getFacesContext().addMessage(null,
             new FacesMessage(FacesMessage.SEVERITY_WARN, "You must enter at least one criteria.", null));
             return DpsLicenseInquiryConstants.CS_FAILURE;
             }
            
             try {
             // attempt to connect to the database
             DpsLicenseRepository lo_DpsLicenseRepository = new DpsLicenseRepository();
             // do the search
             co_search_results_list = lo_DpsLicenseRepository.getDrivers(lo_DpsDriverCriteria);
             cs_elapsed_time = OagStringUtils.formatElapsedTime(lo_DpsLicenseRepository.getElapsedSearchTime());
             } catch (SQLException e) {
             getFacesContext().addMessage(null,
             new FacesMessage(FacesMessage.SEVERITY_FATAL, "Unable to connect to database!",
             e.toString()));
             e.printStackTrace();
             }
            
             if ( co_search_results_list != null ) {
             return DpsLicenseInquiryConstants.CS_SUCCESS;
             } else {
             return DpsLicenseInquiryConstants.CS_FAILURE;
             }
             }
            


            • 3. Re: Error from JSF app deployed as portlet
              Thomas Heute Master

              It is called, check your debugger settings.

              And the error is supposed to happen:
              HttpSession lo_HttpSession = (HttpSession)FacesContext.getCurrentInstance().
              getExternalContext().getSession(false);

              You mustn't cast it:
              FacesContext.getCurrentInstance().
              getExternalContext().getSession(false)

              returns a PortletSession in a portlet environment

              • 4. Re: Error from JSF app deployed as portlet
                Arnie Morein Novice

                Ah, so. My bad. Forgot about that. Thanks.