jFreechart不在linux机器上显示

时间:2012-05-26 09:41:39

标签: java jsp jfreechart

JSP

<img alt="" src='<%=url+"/chartDemo/servlet/ChartDemoServlet"%>'>

我在jsp中有上层代码使用jfreechart。我已经在窗口机器的tomcat中部署了这个应用程序,并且它的工作完美。但是当我在我的linux机器的tomcat中复制相同的文件时,显示除了图表之外的所有其他jsp内容。

为什么不显示图表当我使用linux tomcat运行Web应用程序时?

当我直接输入servlet作为我在异常后找到的URL

java.lang.Error: Probable fatal error:No fonts found.
    sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1088)
    sun.font.FontManager.initialiseDeferredFont(FontManager.java:967)
    sun.font.CompositeFont.doDeferredInitialisation(CompositeFont.java:254)
    sun.font.CompositeFont.getSlotFont(CompositeFont.java:334)
    sun.font.CompositeStrike.getStrikeForSlot(CompositeStrike.java:77)
    sun.font.CompositeStrike.getFontMetrics(CompositeStrike.java:93)
    sun.font.FontDesignMetrics.initMatrixAndMetrics(FontDesignMetrics.java:358)
    sun.font.FontDesignMetrics.<init>(FontDesignMetrics.java:349)
    sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:301)
    sun.java2d.SunGraphics2D.getFontMetrics(SunGraphics2D.java:790)
    org.jfree.text.G2TextMeasurer.getStringWidth(G2TextMeasurer.java:79)
    org.jfree.text.TextUtilities.nextLineBreak(TextUtilities.java:294)
    org.jfree.text.TextUtilities.createTextBlock(TextUtilities.java:235)
    org.jfree.chart.title.TextTitle.arrangeRR(TextTitle.java:628)
    org.jfree.chart.title.TextTitle.arrange(TextTitle.java:497)
    org.jfree.chart.JFreeChart.drawTitle(JFreeChart.java:1316)
    org.jfree.chart.JFreeChart.draw(JFreeChart.java:1204)
    org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1404)
    org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1384)
    org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:183)
    org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:136)
    com.ChartDemoServlet.doPost(ChartDemoServlet.java:170)
    com.ChartDemoServlet.doGet(ChartDemoServlet.java:64)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

1 个答案:

答案 0 :(得分:1)

是的,@汤姆是对的;寻找使用过的字体。早些时候,没有桌面的Linux也没有可用的字体(所谓的无头环境),可由GraphicsEnvironment.isHeadless()和System.getProperty("java.awt.headless");测试。您可能只是可以复制字体并执行registerFont。