2 Replies Latest reply on Nov 2, 2012 12:42 AM by Dave Chen

    Migration to JSF2/Richfaces4: NullPointerException: Resource input stream is null

    Dave Chen Master

      I am migrating web app from JBoss 5.1 to JBoss 7/JSF2/Richfaces4, using facelet,  got the following exception:

       

      14:48:46,921 ERROR [stderr] (http--127.0.0.1-8080-4) java.lang.NullPointerException: Resource input stream is null

      14:48:46,937 ERROR [stderr] (http--127.0.0.1-8080-4)    at org.richfaces.resource.CachedResourceImpl.readContent(CachedResourceImpl.java:139)

      14:48:46,937 ERROR [stderr] (http--127.0.0.1-8080-4)    at org.richfaces.resource.CachedResourceImpl.initialize(CachedResourceImpl.java:176)

      14:48:46,953 ERROR [stderr] (http--127.0.0.1-8080-4)    at org.richfaces.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:168)

      14:48:46,953 ERROR [stderr] (http--127.0.0.1-8080-4)    at javax.faces.application.ResourceHandlerWrapper.handleResourceRequest(ResourceHandlerWrapper.java:125)

      14:48:46,953 ERROR [stderr] (http--127.0.0.1-8080-4)    at org.apache.myfaces.custom.captcha.CAPTCHAResourceHandlerWrapper.handleResourceRequest(CAPTCHAResourceHandlerWrapper.java:208)

      14:48:46,968 ERROR [stderr] (http--127.0.0.1-8080-4)    at javax.faces.application.ResourceHandlerWrapper.handleResourceRequest(ResourceHandlerWrapper.java:125)

      14:48:46,968 ERROR [stderr] (http--127.0.0.1-8080-4)    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:591)

       

      what might be the cause? the exception did not give me much information.

      Thanks for help.

      Dave

        • 1. Re: Migration to JSF2/Richfaces4: NullPointerException: Resource input stream is null
          Dave Chen Master

          Debugging ...

           

          when trying to access

          /javax.faces.resource/calendar.ecss.xhtml?ln=org.richfaces

           

          CompiledCSSResource.java

          styleSheet = parser.parseStyleSheet(source, null, null);

          return  null styleSheet.

           

          I am using the cssparser-0.9.7.jar,   com.steadystate.css.parser.CSSOMParser,

          which is not from richfaces download. This is the right jar to use?

           

          but the the ecss is in the richfaces jar ( 4.2.3.Final).

          META-INF/resources/org.richfaces/calendar.ecss

           

          Thanks for help.

          Dave

           

          CompiledCSSResource.java

           

             @Override

              public InputStream getInputStream() throws IOException {

                  FacesContext ctx = FacesContext.getCurrentInstance();

                  InputStream stream = null;

                  CSSStyleSheet styleSheet = null;

                  try {

                      stream = getResourceInputStream();

                      if (null == stream) {

                          return null;

                      }

                      InputSource source = new InputSource(new InputStreamReader(stream));

                      CSSOMParser parser = new CSSOMParser();

                      ErrorHandlerImpl errorHandler = new ErrorHandlerImpl(this, ctx.isProjectStage(ProjectStage.Production));

           

                      parser.setErrorHandler(errorHandler);

           

                      // parse and create a stylesheet composition

                      styleSheet = parser.parseStyleSheet(source, null, null);  ------> return null.

                  } catch (Exception e) {

                      LOGGER.error(e.getMessage(), e);

                  } finally {

                      if (stream != null) {

                          try {

                              stream.close();

                          } catch (IOException e) {

                              LOGGER.warn(e.getMessage(), e);

                          }

                      }

                  }

           

                  if (styleSheet != null) {

                      // TODO nick - handle encoding

                      String encoding = ctx.getExternalContext().getResponseCharacterEncoding();

                      CSSVisitorImpl cssVisitor = new CSSVisitorImpl(ctx);

                      cssVisitor.setEncoding(encoding != null ? encoding : "UTF-8");

                      cssVisitor.visitStyleSheet(styleSheet);

           

                      String cssText = cssVisitor.getCSSText();

           

                      return new ByteArrayInputStream(cssText.getBytes(cssVisitor.getEncoding()));

                  } else {

                      if (!ctx.isProjectStage(ProjectStage.Production)) {

                          LOGGER.info(MessageFormat.format(NULL_STYLESHEET, getLibraryName(), getResourceName()));

                      }

                      return null;

                  }

              }

          • 2. Re: Migration to JSF2/Richfaces4: NullPointerException: Resource input stream is null
            Dave Chen Master

            has anyone used JSF2/Richfaces 4 successfully? I trying 4.2.3.Final, but not successful.

            The show case:  http://showcase.richfaces.org/ 

            is for RF 4 features. I am wondering if I can download the war somewhere, to see if it works

            in my JBoss 7 environment.

             

            Thanks for any info.

            Dave