java.lang.NullPointerException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • 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}
    via by Noel Hernandez,
  • 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}
    via by Noel Hernandez,
    • java.lang.NullPointerException at org.springframework.faces.webflow.JsfViewFactory.viewAlreadySet(JsfViewFactory.java:138)
    No Bugmate found.