in black and white
Main menu
Share a book About us Home
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics

More Java Pitfalls Share Reactor - Daconta M,C.

Daconta M,C. More Java Pitfalls Share Reactor - Wiley publishing, 2003. - 476 p.
ISBN: 0-471-23751-5
Download (direct link): morejavapitfallssharereactor2003.pdf
Previous << 1 .. 121 122 123 124 125 126 < 127 > 128 129 130 131 132 133 .. 166 >> Next

|1 Btowsei <.i,iph - Mk losoft Internet Explore! - ?11|
Fie E dr. view Fawttes Tods Heb 4*
?) hctp://claysvatD/(errt0/tss9fGraph.|5p V
GOHgle*| flKear.-hWeb vl, i- '*4Ñ lr<o I^JUp * ? ;
Usage of Site by Browser
Browser Usage
[ 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 . . PgeMrfc Q gjUp >t'irl t,
Usage of Site by Browser
jDm. Lu.d let
E*vef jjI -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 ^
.internalDoFilter( 69)
04: at org.apache.catalina.core.ApplicationFilterChain.doFilter ^
05: at org.apache.catalina.core.StandardWrapperValve.invoke ^
06: at org.apache.catalina.core.StandardPipeline.invokeNext ^
07: {...}
08: at ^
09: at 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)
19 {...}
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
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/tass9fGraph.|5p - a*.
Gorgle-I _*J iwri Q gjUp . f
Previous << 1 .. 121 122 123 124 125 126 < 127 > 128 129 130 131 132 133 .. 166 >> Next