java.lang.NullPointerException

Spring JIRA | Noel Hernandez | 5 years ago
  1. 0

    What steps will reproduce the problem? 1. Create any dynamic streamed context 2. Make a reference to the resulting image on page of a Spring Web Flow view-state 3. The image is show but you get a null pointer exception in {code} java.lang.NullPointerException at org.springframework.faces.webflow.JsfViewFactory.viewAlreadySet(JsfViewFactory.java:138) {code} in spring web flow source code 2.3.0 {code:java} private boolean viewAlreadySet(FacesContext facesContext, String viewName) { if (facesContext.getViewRoot() != null && facesContext.getViewRoot().getViewId().equals(viewName)) { // the corner case where a before RESTORE_VIEW PhaseListener has handled setting the UIViewRoot return true; } else { return false; } } {code} facesContext.getViewRoot().getViewId() is null because in the primefaces library in DynamicContentStreamer set the viewRoot to an UIViewRoot without ID on this line facesContext.setViewRoot(new UIViewRoot()); {code:java} private void finalizeResponse(FacesContext facesContext) throws IOException { HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse(); response.setStatus(200); response.getOutputStream().flush(); facesContext.setViewRoot(new UIViewRoot()); facesContext.responseComplete(); } {code} What is the PrimeFaces version? 2.2.1 What is the expected output? What do you see instead? null pointer exception Which JSF implementation with version are you using?(Mojarra or MyFaces) Mojarra What is the version of your JSF implementation? 2.0.6 Which component libraries are you using in addition to PrimeFaces? none Which application server or servlet container are you using? tomcat To help PrimeFaces team when working on your issue, please paste a reproducible test case below. Example; Page; {code:xml} <p:graphicImage value="#{mainEntityController.createDynamicImage()}" /> .... {code} Bean {code:java} public class Bean { .... public StreamedContent createDynamicImage() { try { StreamedContent chart; DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int i = 0; i < list.size(); i++) { dataset.addValue((Integer)list.get(i).get("value"), "serie1", (String)list.get(i).get("description")); } SpiderWebPlot plot = new SpiderWebPlot(dataset); plot.setStartAngle(90); plot.setInteriorGap(0.30); plot.setMaxValue(10); plot.setOutlineVisible(true); plot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); JFreeChart jfreechart = new JFreeChart("", TextTitle.DEFAULT_FONT, plot, false); ChartUtilities.applyCurrentTheme(jfreechart); File chartFile = new File("test.png"); ChartUtilities.saveChartAsPNG(chartFile, jfreechart, 512, 400); chart = new DefaultStreamedContent(new FileInputStream(chartFile), "image/png"); return chart; } catch (Exception e) { e.printStackTrace(); return null; } } } {code}

    Spring JIRA | 5 years ago | Noel Hernandez
    java.lang.NullPointerException
  2. 0

    What steps will reproduce the problem? 1. Create any dynamic streamed context 2. Make a reference to the resulting image on page of a Spring Web Flow view-state 3. The image is show but you get a null pointer exception in {code} java.lang.NullPointerException at org.springframework.faces.webflow.JsfViewFactory.viewAlreadySet(JsfViewFactory.java:138) {code} in spring web flow source code 2.3.0 {code:java} private boolean viewAlreadySet(FacesContext facesContext, String viewName) { if (facesContext.getViewRoot() != null && facesContext.getViewRoot().getViewId().equals(viewName)) { // the corner case where a before RESTORE_VIEW PhaseListener has handled setting the UIViewRoot return true; } else { return false; } } {code} facesContext.getViewRoot().getViewId() is null because in the primefaces library in DynamicContentStreamer set the viewRoot to an UIViewRoot without ID on this line facesContext.setViewRoot(new UIViewRoot()); {code:java} private void finalizeResponse(FacesContext facesContext) throws IOException { HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse(); response.setStatus(200); response.getOutputStream().flush(); facesContext.setViewRoot(new UIViewRoot()); facesContext.responseComplete(); } {code} What is the PrimeFaces version? 2.2.1 What is the expected output? What do you see instead? null pointer exception Which JSF implementation with version are you using?(Mojarra or MyFaces) Mojarra What is the version of your JSF implementation? 2.0.6 Which component libraries are you using in addition to PrimeFaces? none Which application server or servlet container are you using? tomcat To help PrimeFaces team when working on your issue, please paste a reproducible test case below. Example; Page; {code:xml} <p:graphicImage value="#{mainEntityController.createDynamicImage()}" /> .... {code} Bean {code:java} public class Bean { .... public StreamedContent createDynamicImage() { try { StreamedContent chart; DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int i = 0; i < list.size(); i++) { dataset.addValue((Integer)list.get(i).get("value"), "serie1", (String)list.get(i).get("description")); } SpiderWebPlot plot = new SpiderWebPlot(dataset); plot.setStartAngle(90); plot.setInteriorGap(0.30); plot.setMaxValue(10); plot.setOutlineVisible(true); plot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); JFreeChart jfreechart = new JFreeChart("", TextTitle.DEFAULT_FONT, plot, false); ChartUtilities.applyCurrentTheme(jfreechart); File chartFile = new File("test.png"); ChartUtilities.saveChartAsPNG(chartFile, jfreechart, 512, 400); chart = new DefaultStreamedContent(new FileInputStream(chartFile), "image/png"); return chart; } catch (Exception e) { e.printStackTrace(); return null; } } } {code}

    Spring JIRA | 5 years ago | Noel Hernandez
    java.lang.NullPointerException
  3. 0

    Android: Saving Map State in Google map

    Stack Overflow | 11 months ago | Junie Negentien
    java.lang.RuntimeException: Unable to resume activity {com.ourThesis.junieNegentien2015/com.ourThesis.junieNegentien2015.MainActivity}: java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.springframework.faces.webflow.JsfViewFactory.viewAlreadySet()
    2. org.springframework.faces
      JsfViewFactory.viewAlreadySet
      1. org.springframework.faces.webflow.JsfViewFactory.viewAlreadySet(JsfViewFactory.java:138)
      1 frame