From: Nathaniel G. A. <nat...@ya...> - 2004-01-03 14:03:29
|
what jdk are you using? --- Ashley Towers <at...@uk...> wrote: > Im having problems with this X11 (Unix based problem). Basically i got the code working on > windows but not solaris, i've tried the > > try{ System.setProperty("java.awt.headless","true");}catch( Throwable throwable ){} > > fix but it doesn't seem to be working, im not sure if i've got it in the wrong place or if i've > done it wrong or what? Its a servlet running on Sun One WebServer so i can't run it from the > command line and thus add the -D<thingy> > > any one any ideas??? > > > i've got the code: > > import org.jCharts.chartData.ChartDataException; > import org.jCharts.chartData.PieChartDataSet; > import org.jCharts.encoders.ServletEncoderHelper; > import org.jCharts.nonAxisChart.PieChart2D; > import org.jCharts.properties.*; > > import javax.servlet.ServletException; > import javax.servlet.http.*; > import java.awt.*; > import java.io.IOException; > > > public class PieChart2DServlet extends HttpServlet > { > //---all of my pie charts serviced by this Servlet will have the same properties. > private PieChart2DProperties properties; > private LegendProperties legendProperties; > private ChartProperties chartProperties; > > private int width = 550; > private int height = 350; > > > /********************************************************************************************** > * > > **********************************************************************************************/ > public void init() > { > // Solaris code to prevent X11 Server errors > try{ System.setProperty("java.awt.headless","true");}catch( Throwable throwable > ){} > > //---all charts of this type of pie chart are going to share the same > properties. > this.properties = new PieChart2DProperties(); > > this.legendProperties = new LegendProperties(); > this.legendProperties.setNumColumns( 2 ); > this.legendProperties.setPlacement( LegendProperties.RIGHT ); > > this.chartProperties = new ChartProperties(); > } > > > /********************************************************************************************** > * > > **********************************************************************************************/ > public void service( HttpServletRequest req, HttpServletResponse response ) throws > ServletException, IOException > { > > > > > try > { > PieChart2D pieChart2D = new PieChart2D( this.getData(req), this.legendProperties, > this.chartProperties, this.width, this.height ); > ServletEncoderHelper.encodeJPEG13( pieChart2D, 1.0f, response ); > } > catch( Throwable throwable ) > { > //HACK do your error handling here... > throwable.printStackTrace(); > } > } > > > /****************************************************************************************** > * Returns a Tests a 'real' data set and usage. > * > * @throws ChartDataException > ******************************************************************************************/ > private PieChartDataSet getData(HttpServletRequest req) throws ChartDataException > { > > String []y = req.getParameterValues("y"); > // Defines the data > double[] data = new double[y.length]; > > for (int i =0; i < y.length; i++){ > Double d = (Double) Double.valueOf(y[i]); > data[i] = (double) d.doubleValue(); > } > > // Defines the paints > Paint[] paints = new Paint[data.length]; > for (int i = 0; i < paints.length; i++){ > paints[i] = possible_paints[i]; > } > > // Defines labels for each value > String[] labels = req.getParameterValues("x"); > > // Defines the title > String title = ""; > title = req.getParameter("title"); > > return new PieChartDataSet(title, data, labels, paints, this.properties ); > } > > // Defines the possible_paints MAX 9 > private Paint[] possible_paints = new Paint[]{Color.blue, > Color.red, > Color.green, > Color.yellow, > Color.white, > Color.gray, > Color.orange, > Color.pink, > Color.blue, > Color.red, > Color.green, > Color.yellow, > Color.white, > Color.gray, > Color.orange, > Color.pink, > Color.blue}; > } > > > > > > im getting the errors: > > [19/Dec/2003:08:12:18] failure (13591): Internal error: Unexpected error condition thrown > (unknown exception,no description), stack: java.lang.InternalError: Can't connect to X11 window > server using ':0.0' as the value of the DISPLAY variable. > > at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) > > at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:125) > > at java.lang.Class.forName0(Native Method) > > at java.lang.Class.forName(Class.java:140) > > at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62) > > at java.awt.Font.initializeFont(Font.java:303) > > at java.awt.Font.<init>(Font.java:339) > > at org.jCharts.properties.util.ChartFont.<clinit>(Unknown Source) > > at org.jCharts.properties.PieChart2DProperties.<init>(Unknown Source) > > at PieChart2DServlet.init(PieChart2DServlet.java:30) > > at javax.servlet.GenericServlet.init(GenericServlet.java:258) > > at com.iplanet.server.http.servlet.NSServletEntity.load(NSServletEntity.java:405) > > at com.iplanet.server.http.servlet.NSServletEntity.update(NSServletEntity.java:173) > > at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:416) > > > [02/Jan/2004:10:31:45] failure (23997): Internal error: Unexpected error condition thrown > (unknown exception,no description), stack: java.lang.NoClassDefFoundError: > sun/io/ByteToCharEUC_KR > > at sun.awt.font.NativeFontWrapper.registerFonts(Native Method) > > at sun.java2d.SunGraphicsEnvironment.addPathFonts(SunGraphicsEnvironment.java:736) > > at sun.java2d.SunGraphicsEnvironment.registerFonts(SunGraphicsEnvironment.java:587) > > at sun.java2d.SunGraphicsEnvironment.access$100(SunGraphicsEnvironment.java:49) > > at sun.java2d.SunGraphicsEnvironment$2.run(SunGraphicsEnvironment.java:209) > > at java.security.AccessController.doPrivileged(Native Method) > > at sun.java2d.SunGraphicsEnvironment.loadFonts(SunGraphicsEnvironment.java:203) > > at sun.java2d.SunGraphicsEnvironment.initTerminalNames(SunGraphicsEnvironment.java:1029) > > at sun.java2d.SunGraphicsEnvironment.initCompositeFonts(SunGraphicsEnvironment.java:795) > > at sun.java2d.SunGraphicsEnvironment.access$200(SunGraphicsEnvironment.java:49) > > at sun.java2d.SunGraphicsEnvironment$1.run(SunGraphicsEnvironment.java:160) > > at java.security.AccessController.doPrivileged(Native Method) > > at sun.java2d.SunGraphicsEnvironment.<init>(SunGraphicsEnvironment.java:78) > > at sun.awt.X11GraphicsEnvironment.<init>(X11GraphicsEnvironment.java:150) > > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > > at > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) > > at > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) > > > at java.lang.reflect.Constructor.newInstance(Constructor.java:274) > > at java.lang.Class.newInstance0(Class.java:306) > > at java.lang.Class.newInstance(Class.java:259) > > at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62) > > at java.awt.Font.initializeFont(Font.java:303) > > at java.awt.Font.<init>(Font.java:339) > > at org.jCharts.properties.util.ChartFont.<clinit>(Unknown Source) > > at org.jCharts.properties.PieChart2DProperties.<init>(Unknown Source) > > at PieChart2DServlet.init(PieChart2DServlet.java:30) > > at javax.servlet.GenericServlet.init(GenericServlet.java:258) > > at com.iplanet.server.http.servlet.NSServletEntity.load(NSServletEntity.java:405) > > at com.iplanet.server.http.servlet.NSServletEntity.update(NSServletEntity.java:173) > > at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:416) __________________________________ Do you Yahoo!? Find out what made the Top Yahoo! Searches of 2003 http://search.yahoo.com/top2003 |