5 Replies Latest reply on Jul 1, 2005 9:12 AM by vinkh

    Exception with custom portlet: content type is null

    vinkh Newbie

      I have deployed a custom portlet and when the portlet invokes the Jsp, it gives error -

      java.lang.IllegalStateException: No content type defined
      at org.jboss.portal.server.output.FragmentResult.getWriter(FragmentResult.java:93)
      at org.jboss.portal.portlet.impl.RenderResponseImpl.getWriter(RenderResponseImpl.java:81)
      at org.jboss.portal.portlet.impl.DispatchedHttpServletResponse.getWriter(DispatchedHttpServletResponse.java:118)
      at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:111)
      at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:124)
      at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:117)
      at org.apache.jasper.runtime.JspWriterImpl.write(JspWriterImpl.java:325)
      at org.apache.jasper.runtime.JspWriterImpl.write(JspWriterImpl.java:336)
      at org.apache.jsp.jsp.dashboardmain_jsp._jspService(org.apache.jsp.jsp.dashboardmain_jsp:244)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      ............
      Can you tell me how the content type is set in the class FragmentResult as it is null in that class. ?.

      I guess, the portlet/jsp as such are ok, since it was working well on another portal and i am trying to move it to jboss portal. Any one had similar issues ?. Any thing to do with the xml descriptor definitions for the portlet ?
      eg - in -pages.xml, --<portal-name>default</portal-name>)--

        • 1. Re: Exception with custom portlet: content type is null
          Woodler Expert

          is your portlet code setting the content type at all, and is that content type supported according to your portlet.xml ?

          • 2. Re: Exception with custom portlet: content type is null
            vinkh Newbie

            The portlet just dispatch to a jsp

            PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(mainPage);
             prd.include(request, response);


            In the servlet compiled from the jsp, the content type is set.
            _jspxFactory = JspFactory.getDefaultFactory();
             response.setContentType("text/html");
             pageContext = _jspxFactory.getPageContext(this, request, response,
             null, true, 8192, true);
             _jspx_page_context = pageContext;


            Do i need to explicitely set the content type in the portlet ?. guess not

            The problem is contentType is not set in the class org.jboss.portal.server.output.FragmentResult

            I am using only the standard classes like RenderRequest, RenderResponse and NOT JBossRenderRequest, JBossRenderResponse etc... Is it like i have to use JBoss* classes ?
            I could send the code if you want to have a quick look!

            • 3. Re: Exception with custom portlet: content type is null
              vinkh Newbie

              Sorry, i missed one part of your ques. The portlet.xml supports the content type

              <supports>
               <mime-type>text/html</mime-type>
               <portlet-mode>EDIT</portlet-mode>
               <portlet-mode>HELP</portlet-mode>
               </supports>


              • 4. Re: Exception with custom portlet: content type is null
                Woodler Expert

                I see the same behaviour. I can get around it by :
                renderResponse.setContentType("text/html");
                PortletRequestDispatcher rd = this.getPortletContext().getRequestDispatcher(uri);

                if (rd != null)
                {
                rd.include(renderRequest, renderResponse);
                }
                else
                {
                writeError(renderResponse, uri);
                }

                Not sure if this is a bug, or a feature.....

                • 5. Re: Exception with custom portlet: content type is null
                  vinkh Newbie

                  It works with renderResponse.setContentType("text/html"); .

                  So its setting this in the class org.jboss.portal.server.output.FragmentResult. But this makes an additional step from specifications and shouldn't have been this way (my opinion :-))

                  Thanks for your help, Martin!