0 Replies Latest reply on Aug 22, 2012 6:03 PM by Gerry Matte

    Context attribute richSkin throws NullPointerException in servlet

    Gerry Matte Apprentice

      Hello.

      While converting a SnoopServet to Jboss 7.1.1.Final and Richfaces 4.2.2.Final, I encountered an unexpected exception when my servlet iterated over an enumeration of servlet context attributes:

       

      {code}

              ServletContext context = getServletContext();

              out.println("Context attributes:");

              e = context.getAttributeNames();

              while (e.hasMoreElements()) {

                  String key = (String)e.nextElement();

                  Object value = context.getAttribute(key);

                  try {

                            out.println("   " + key + " = " + value );

                  }

                  catch (NullPointerException npe) {

                            out.println("   " + key + " = [NullPointerException]" );

                  };{code}

       

      The attributes are all correctly listed on the HTML output except for context attribute "richSkin".  Prior to implementaing the try/catch for a NullPointerException that attribute always threw a NullPointerException:

      {code} java.lang.NullPointerException      org.richfaces.skin.SkinFactoryImpl.getSkin(SkinFactoryImpl.java:57)      org.richfaces.skin.SkinBean.getSkin(SkinBean.java:85)      org.richfaces.skin.SkinBean.toString(SkinBean.java:95)      java.lang.String.valueOf(String.java:2826)      java.lang.StringBuilder.append(StringBuilder.java:115)      ca.gerrymatte.tests.SnoopServlet.doGet(SnoopServlet.java:72)      javax.servlet.http.HttpServlet.service(HttpServlet.java:734)      javax.servlet.http.HttpServlet.service(HttpServlet.java:847)      org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) {code}

      The richSkin attribute was not something that I defined in my application ...... I assume it is created by richFaces itself.  If so, richFaces should not create a context attribute that triggers a NullPointerException when one attempts to retrieve it.

      This error was also reported on the internet at [http://code.google.com/p/psi-probe/issues/detail?id=229]

      .