Download (direct link):
|©1 Btowsei <.i,iph - Mk losoft Internet Explore! - ?11É|
Fie E dr. view Fawttes Tods Heb 4*
?) hctp://claysvatD/(errt0/t»¹ss9fGraph.|5p V
GOHgle*| flKear.-hWeb vl, i- Ã'«*Â4Ã‘ ô lr<o I^JUp * ? ;
Usage of Site by Browser
[ ß Internet EjqilOKi Btunoapt È MozlllJ opt è ll
'J Lu.d irfjaiet
?)MiuoMUlnlernetEx... r~^m 7<i'9 -4BC
Figure 40.1 Rendered chart example (Windows).
Image Obsession 351
Biows«?i Graph - i losoft Internet Explorer Ulett
j Fie Ech view Favorites Tods Heb *
"¦ -'J 4É http://claysvatD/rer40/trass9fGraph.|sp - a«»
Google *| Search Web ô. . P«ge»Mrfc Q gjUp >t'irl t,
Usage of Site by Browser
«jDm. Lu.d Þë let
E*v«ef •j»«jI -1'».i . •4ÂÉ »:ß PM
Figure 40.2 Example (Solaris 8).
After bragging about our new graph tool and showing it off on our development boxes, our stomach turned when we saw what showed up on our deployment systems. Figure 40.2 shows the source of our nightmare.
What happened to the image? We ran the exact same code with the same configuration. When we examine the stack trace, we see the problem, shown in Listing 40.2 (abridged).
01: 2002-08-15 17:53:43 StandardWrapperValve[chart]: Servlet.service() ^ for servlet chart threw exception
02: javax.servlet.ServletException: Servlet execution threw an exception 03: at org.apache.catalina.core.ApplicationFilterChain ^
04: at org.apache.catalina.core.ApplicationFilterChain.doFilter ^
05: at org.apache.catalina.core.StandardWrapperValve.invoke ^
06: at org.apache.catalina.core.StandardPipeline.invokeNext ^
08: at org.apache.catalina.connector.http.HttpProcessor.run ^
09: at j ava.lang.Thread.run(Thread.j ava:53 6)
10: -----Root Cause-----
11: java.lang.NoClassDefFoundError: com.jrefinery.chart.AxisConstants
12: at com.jrefinery.chart.ChartFactory.createPieChart(Unknown Source)
Listing 40.2 Stack trace (continued)
352 Item 40
13 at de.laures.cewolf.DefaultChartRenderer.getChartInstance 2
14 at de.laures.cewolf.AbstractChartRenderer.renderChart
15 at de.laures.cewolf.CewolfRenderer.renderChart(CewolfRenderer 2
16 at de.laures.cewolf.CewolfRenderer.doGet(CewolfRenderer.j ava:71)
17 at j avax.servlet.http.HttpServlet.service(HttpServlet.j ava:740)
18 at j avax.servlet.http.HttpServlet.service(HttpServlet.j ava:853)
Listing 40.2 (continued)
We get a NoClassDefFoundError. We look to see if the class is not within the CLASSPATH. Searching through the JFreeChart JAR file, we find the named class, AxisConstants, is there. So we check to see if the jar is somehow not getting loaded. Searching through the Tomcat logs, we find the line that shows it mounts the jar just like the rest of the (working) JARs.
NoClassDefFoundError clearly doesn't make sense. After all, it means that the JVM cannot find the definition of a particular class, when, in fact, it can. Rather than continue to try to chase this inexplicable phenomenon, we follow the stack trace a bit further. It comes from rendering a pie chart in the CewolfRenderer. This causes us to think about it a little closer.
What has changed? The operating system has, but that isn't supposed to matter in Java! As it turns out, we have a small anomaly in how Windows and Unix handle their windowing environments. Windows, as the name implies, is tied to its windowing environment. However, Unix does not require a windowing environment and uses an X server to generate its user interface.
Actually, the heart of the problem has to do with the way the Abstract Windowing Toolkit (AWT) is implemented. The implementation expects to find an X server running when it is created, despite the fact that no user interface components are going to be used. This is relevant to our problem because certain classes out of the Java image classes use the AWT (e.g., BufferedImage).
So, there are a couple of solutions to this problem. First, attach a monitor and run the server as a logged-in user. (You should ignore any random images that pop up on the screen as you are working.) However, this is not a very elegant or useful solution.
The real solution depends on which version of the JDK you are using. If you are running on JDK 1.3 or earlier, you should download an X emulator. One you can download is called xvfb, which is at http://wwwx.org.
However, JDK 1.4 comes with what is known as the "headless AWT." This allows the J2SE components to be run on the server side without an X server. To use this, you need to specify the following JVM option:
The Problem with Multiple Concurrent Result Sets 353
|©1 Btowsei <jioph - Miciosoft Internet Explore! 1- ?11É|
Fie EA view Fawttes Tods Heb
?) http://claysvatD/(en40/t»ass9fGraph.|5p - a*.
Gorgle-I _*J ® iwri Q gjUp . f