ICEfaces
  1. ICEfaces
  2. ICE-2261

OutputChart NPE in WebLogic 9.2

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.1
    • Fix Version/s: 1.7DR#1, 1.7
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      win xp

      Description

      Problem Description: Using a simple example of charts on Weblogic 9.2:

      <ice:outputChart type="pie2d" labels="pass, fail"
      data="70, 30"
      colors="green, red"/>

      java.lang.NullPointerException
              at java.io.File.<init>(File.java:194)
              at com.icesoft.faces.component.outputchart.OutputChart.getFolder(OutputC
      hart.java:529)
              at com.icesoft.faces.component.outputchart.OutputChart.getNewOutputStrea
      m(OutputChart.java:510)

        Issue Links

          Activity

          Hide
          Philip Breau added a comment -

          The main issue here is that we rely on ServletContext.getRealPath() to determine the absolute file path on the server to write out the image files to. getRealPath() is not guaranteed by the servlet spec to return a non-null value, and will return null on WebLogic when running an unexploded war (which is why the workaround listed above works). My recommendation would be to avoid using ServletContext.getRealPath() and instead use the temporary file creation mechanism in java.io.File:

          try

          { // Create temp file. File temp = File.createTempFile("pattern", ".suffix"); // Delete temp file when program exits. temp.deleteOnExit(); // Write to temp file BufferedWriter out = new BufferedWriter(new FileWriter(temp)); out.write("aString"); out.close(); }

          catch (IOException e) {
          }

          Show
          Philip Breau added a comment - The main issue here is that we rely on ServletContext.getRealPath() to determine the absolute file path on the server to write out the image files to. getRealPath() is not guaranteed by the servlet spec to return a non-null value, and will return null on WebLogic when running an unexploded war (which is why the workaround listed above works). My recommendation would be to avoid using ServletContext.getRealPath() and instead use the temporary file creation mechanism in java.io.File: try { // Create temp file. File temp = File.createTempFile("pattern", ".suffix"); // Delete temp file when program exits. temp.deleteOnExit(); // Write to temp file BufferedWriter out = new BufferedWriter(new FileWriter(temp)); out.write("aString"); out.close(); } catch (IOException e) { }
          Hide
          yip.ng added a comment -

          Suggested fix will create a temp file outside of the app. context. How do you serve that temp file to the browser?

          Show
          yip.ng added a comment - Suggested fix will create a temp file outside of the app. context. How do you serve that temp file to the browser?
          Hide
          Ken Fyten added a comment -

          The fix for ICE-2112 also resolves this issue on WebLogic.

          Show
          Ken Fyten added a comment - The fix for ICE-2112 also resolves this issue on WebLogic.

            People

            • Assignee:
              Unassigned
              Reporter:
              Philip Breau
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: