Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.6.1
-
Component/s: ICE-Components
-
Labels:None
-
Environment:win xp
-
Support Case References:
-
Workaround Exists:Yes
-
Workaround Description:use expanded war
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)
<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
- duplicates
-
ICE-2112 OutputChart throws java.lang.ClassCastException when running a portlet
- Closed
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) {
}