JFreeチャートを使用しています。最後に、使用時に例外が発生します
Java ファイル:
ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart,
1150, 450);
JSP ファイル:
<img src="${pageContext.request.contextPath}/weeklyDlvyInstancesDashboardReportPost.do?method=generateParetoInstanceBasedChart" alt="Graph" width="100%" height="450" border="0"/></br>
サーバ:
IBM Webspere 6.0.1
チャートは正常に動作します。しかし、コンソールにはエラーが表示されます
[11/22/12 18:31:28:243 IST] 0000002f ServletWrappe E SRVE0068E: Uncaught exception thrown in one of the service methods of the servlet: /jsp/layout/layout.jsp. Exception thrown : java.lang.IllegalStateException: SRVE0199E: OutputStream already obtained
at com.ibm.ws.webcontainer.srt.SRTServletResponse.getWriter(SRTServletResponse.java:601)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:196)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:184)
at org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:240)
at org.apache.struts.tiles.taglib.InsertTag$InsertHandler.doEndTag(InsertTag.java:893)
at org.apache.struts.tiles.taglib.InsertTag.doEndTag(InsertTag.java:465)
at com.ibm._jsp._layout._jspx_meth_tiles_insert_0(_layout.java:568)
at com.ibm._jsp._layout._jspService(_layout.java:162)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:87)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1146)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1087)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:118)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:848)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:691)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:588)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:525)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:232)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:639)
at org.apache.struts.action.RequestProcessor.doInclude(RequestProcessor.java:1110)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:292)
at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:271)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:332)
at com.ford.it.strutscore.context.ScTilesRequestProcessor.processForwardConfig(ScTilesRequestProcessor.java:863)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:232)
at com.ford.it.strutscore.context.ScTilesRequestProcessor.processRequest(ScTilesRequestProcessor.java:199)
at com.ford.it.strutscore.context.ScTilesRequestProcessor.process(ScTilesRequestProcessor.java:143)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1146)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1087)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:145)
at com.ford.it.persistencecore.context.PcRequestContextFilter.doFilter(PcRequestContextFilter.java:153)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ford.mpl.supergweb.context.I18NUserProfileFilter.doFilterChain(I18NUserProfileFilter.java:139)
at com.ford.mpl.supergweb.context.I18NUserProfileFilter.doFilter(I18NUserProfileFilter.java:79)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ford.it.context.RequestContextFilter.doFilter(RequestContextFilter.java:123)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ford.mpl.supergweb.context.EncodingFilter.doFilter(EncodingFilter.java:50)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:848)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:691)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:588)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:525)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:90)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:764)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1478)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:133)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1818)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:196)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:751)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:881)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1497)
---- Begin backtrace for Nested Throwables
java.lang.IllegalStateException: SRVE0199E: OutputStream already obtained
at com.ibm.ws.webcontainer.srt.SRTServletResponse.getWriter(SRTServletResponse.java:601)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:196)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:184)
at org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:240)
at org.apache.struts.tiles.taglib.InsertTag$InsertHandler.doEndTag(InsertTag.java:893)
at org.apache.struts.tiles.taglib.InsertTag.doEndTag(InsertTag.java:465)
at com.ibm._jsp._layout._jspx_meth_tiles_insert_0(_layout.java:568)
at com.ibm._jsp._layout._jspService(_layout.java:162)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:87)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1146)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1087)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:118)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:848)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:691)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:588)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:525)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:232)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:639)
at org.apache.struts.action.RequestProcessor.doInclude(RequestProcessor.java:1110)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:292)
at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:271)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:332)
at com.ford.it.strutscore.context.ScTilesRequestProcessor.processForwardConfig(ScTilesRequestProcessor.java:863)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:232)
at com.ford.it.strutscore.context.ScTilesRequestProcessor.processRequest(ScTilesRequestProcessor.java:199)
at com.ford.it.strutscore.context.ScTilesRequestProcessor.process(ScTilesRequestProcessor.java:143)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1146)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1087)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:145)
at com.ford.it.persistencecore.context.PcRequestContextFilter.doFilter(PcRequestContextFilter.java:153)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ford.mpl.supergweb.context.I18NUserProfileFilter.doFilterChain(I18NUserProfileFilter.java:139)
at com.ford.mpl.supergweb.context.I18NUserProfileFilter.doFilter(I18NUserProfileFilter.java:79)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ford.it.context.RequestContextFilter.doFilter(RequestContextFilter.java:123)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ford.mpl.supergweb.context.EncodingFilter.doFilter(EncodingFilter.java:50)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:848)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:691)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:588)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:525)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:90)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:764)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1478)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:133)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1818)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:196)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:751)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:881)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1497)
[11/22/12 18:31:28:368 IST] 0000002f SRTServletRes W WARNING: Cannot set status. Response already committed.
[11/22/12 18:31:28:368 IST] 0000002f SRTServletRes W WARNING: Cannot set header. Response already committed.)
Javaページ:
try
{
CategoryDataset dataset1 = createDataSetForInstanceBasedChart();
String instancesCountLabelName = I18nMessageUtil.getMessage(CommonUtil.getLocale(), "label.reports.wdid.instcnt");
JFreeChart chart = ChartFactory.createBarChart(
"", // chart title
"", // domain axis label
instancesCountLabelName, // range axis label
dataset1, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips?
false // URLs?
);
// NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
// set the background color for the chart...
chart.setBackgroundPaint(Color.white);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setBackgroundPaint(Color.lightGray);
/*CategoryDataset dataset2 = createDataset2();
plot.setDataset(1, dataset2);
plot.mapDatasetToRangeAxis(1, 1);*/
CategoryItemRenderer renderer1 = plot.getRenderer();
renderer1.setSeriesItemLabelGenerator(0,new CategoryItemLabelGenerator() {
public String generateRowLabel(final CategoryDataset arg0, final int arg1) {
// TODO Auto-generated method stub
return null;
}
public String generateLabel(final CategoryDataset dataset1,final int series,final int category) {
String result = null;
//CHAPTER 12. ITEM LABELS 91
final Number value = dataset1.getValue(series, category);
if (value != null) {
final double v = value.doubleValue();
if (v > 0) {
result = value.toString(); // could apply formatting here
}
}
return result;
}
public String generateColumnLabel(final CategoryDataset arg0, final int arg1) {
// TODO Auto-generated method stub
return null;
}
});
renderer1.setSeriesItemLabelsVisible(0,true);
System.out.println("+++++++++++++++++++++++++++++++++renderer1" +renderer1);
BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
renderer.setSeriesOutlinePaint(0,Color.BLACK);
renderer.setDrawBarOutline(true);
renderer.setMaximumBarWidth(0.02);
renderer.setSeriesPaint(0,new Color(170, 0, 85));
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!renderer" +renderer);
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(.6));
domainAxis.setLabelFont(new Font("Helvetica", Font.BOLD, 14));
domainAxis.setTickLabelFont(new Font("Helvetica", Font.BOLD, 14));
System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@domainAxis" +domainAxis);
/*String numOfSupplrs = I18nMessageUtil.getMessage(CommonUtil.getLocale(), "label.rateElement.history.numOfSupplrs");
ValueAxis axis2 = new NumberAxis(numOfSupplrs);
axis2.setLabelFont(new Font("Helvetica", Font.BOLD, 14));
axis2.setTickLabelFont(new Font("Helvetica", Font.PLAIN, 14));
//if(!this.isValueDataZeros)
//axis2.setRange(0,13);
plot.setRangeAxis(1, axis2);*/
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
// if(!this.isNumberDataZeros)
//rangeAxis.setRange(0,90);
//rangeAxis.setTickUnit(new NumberTickUnit(1));
rangeAxis.setLabelFont(new Font("Helvetica", Font.BOLD, 14));
rangeAxis.setTickLabelFont(new Font("Helvetica", Font.PLAIN, 14));
/*LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
renderer2.setSeriesPaint(0, Color.BLUE);
Start
renderer2.setSeriesItemLabelGenerator(0,new CategoryItemLabelGenerator() {
public String generateRowLabel(final CategoryDataset arg0, final int arg1) {
// TODO Auto-generated method stub
return null;
}
public String generateLabel(final CategoryDataset dataset1,final int series,final int category) {
String result = null;
//CHAPTER 12. ITEM LABELS 91
final Number value = dataset1.getValue(series, category);
if (value != null) {
final double v = value.doubleValue();
if (v > 0) {
result = value.toString(); // could apply formatting here
}
}
return result;
}
public String generateColumnLabel(final CategoryDataset arg0, final int arg1) {
// TODO Auto-generated method stub
return null;
}
});
renderer2.setSeriesItemLabelsVisible(0,true);*/
/* End */
//plot.setRenderer(1, renderer2);
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
System.out.println("#########################plot" +plot);
ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart,
1150, 450);
log.exiting(CLASS_NAME, METHOD_NAME);
}
catch(Exception writeInstanceBasedParetoChartException)
{
System.out.println("Exception in writeInstanceBasedParetoChartException: "+writeInstanceBasedParetoChartException.getMessage());
}
私が欲しいもの:
コンソールでエラーを回避するにはどうすればよいですか? 提案をお願いします。前もって感謝します。