Download the latest version now.
  • Is JForum useful for you? Please consider helping this project.
 
 
 
 
 
  [Login] Login  [Register] Register   [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing  
JForum is available free of charge, but it cost real money to maintain it. Support the project.
HOWTO: Avatars on a headless server  XML
Forum Index » Downloading / Installing
Author Message
time
Forum Baby
[Avatar]

Joined: 03/06/2004 04:56:13
Messages: 80
Offline

Many of you may be deploying your JForum on a headless server. If so, you may discover that you get an error whenever you attempt to upload an avatar.

The problem is that the Java AWT code is attempting to draw the avatar (I believe in order to convert it into a PNG image). In turn, the AWT package is causing the X11 server to open the DISPLAY.

In this case, you will see an error message similar to:

To correct this problem, you need to tell the Java AWT package that the X11 server is headless and has no display. This is done by setting a System Property in the JVM when you start Tomcat (or your appserver of choice).

The property you need to set is: java.awt.headless
The property needs to be set to: true
The way you set this property is to invoke the JVM with the following option: -Djava.awt.headless=true

If you are using Tomcat, the simplest way to accomplish this is to add the following like to your <tomcat>/bin/setenv.sh file:


This will properly send the -D option to the JVM when tomcat starts up.

PLEASE NOTE: This solution will ONLY work with JDK1.4 or later. For those who are stuck with JDK1.3, you will need another solution involving X servers designed for headless operation. A Google search will find the answer for you. Search for "tomcat open display :0.0", and you will find many references.

This message was edited 5 times. Last update was at 25/02/2007 09:27:33

Rafael Steil
Project Leader
[Avatar]

Joined: 23/12/2003 11:39:21
Messages: 4325
Location: Brazil
Offline

Great dude, thanks for the post

Rafael

http://www.flickr.com/photos/rafaelsteil
[Email] [WWW] [MSN]
Anonymous



Sorry, but i now solution for JDK 1.3 platform. In this case just use Pure Java AWT (http://www.eteks.com/pja/en/). You must download and install this toolkit only.
Rafael Steil
Project Leader
[Avatar]

Joined: 23/12/2003 11:39:21
Messages: 4325
Location: Brazil
Offline

Anonymous wrote:Sorry, but i now solution for JDK 1.3 platform. In this case just use Pure Java AWT (http://www.eteks.com/pja/en/). You must download and install this toolkit only.


Hm, interesting.. I'll take a closer look

Thanks,
Rafael

http://www.flickr.com/photos/rafaelsteil
[Email] [WWW] [MSN]
jamesyong
Forum Baby
[Avatar]

Joined: 12/07/2004 02:23:34
Messages: 109
Location: Singapore
Offline

Anonymous wrote:Sorry, but i now solution for JDK 1.3 platform. In this case just use Pure Java AWT (http://www.eteks.com/pja/en/). You must download and install this toolkit only.

Really interesting, since my hosting provider doesn't allow an headless environment.
Anonymous



The difference between phpBB and JForum is that you try to convert all images (avatars) to PNG format - so some unsupported PNG formats would be not correctly converted, and animated GIFs would not be converted to MNGs (very few browsers have support for the animated PNG, or MNG format, and java.image has no support for MNG).
What is the reason for converting all images to PNG format instead of leaving them alone?
Rafael Steil
Project Leader
[Avatar]

Joined: 23/12/2003 11:39:21
Messages: 4325
Location: Brazil
Offline

I can leave the original gif if the image is smaller than the maximum size allowed by the board ( configurable via the admin panel )..

The problem is when we need to resize the image, since javax.imageio does not supporint writing of GIF files due to licensing problems.

Rafael

http://www.flickr.com/photos/rafaelsteil
[Email] [WWW] [MSN]
andowson
Forum Baby
[Avatar]

Joined: 04/09/2004 15:58:57
Messages: 119
Location: Taiwan
Offline

The problem is when we need to resize the image, since javax.imageio does not supporint writing of GIF files due to licensing problems.

As I know, Unisys patent for GIF/LZW technology has expired. Now you could freely output graphs to GIF/TIFF image formats in the desktop applications.
see this http://cloanto.com/users/mcb/19950127giflzw.html
[WWW]
0m4r
Forum Baby
[Avatar]

Joined: 18/02/2005 14:58:42
Messages: 43
Location: Italy
Offline

have u never tried to use the this api: https://jai.dev.java.net/ ?

This message was edited 1 time. Last update was at 24/02/2005 14:35:52

[MSN]
Rafael Steil
Project Leader
[Avatar]

Joined: 23/12/2003 11:39:21
Messages: 4325
Location: Brazil
Offline

0m4r wrote:have u never tried to use the this api: https://jai.dev.java.net/ ?


Nope.. I'll take a look.

Other main problem with regular JDK 1.4 image classes is that they are SO SLOW.

Raael

http://www.flickr.com/photos/rafaelsteil
[Email] [WWW] [MSN]
Anonymous



Rafael Steil wrote:I can leave the original gif if the image is smaller than the maximum size allowed by the board ( configurable via the admin panel )..

The problem is when we need to resize the image, since javax.imageio does not supporint writing of GIF files due to licensing problems.

Rafael


The simplest solution would be to analyse the size (in bytes and in width/height) using some image classes (I know for example http://reader.imagero.com/) and display an error if it is too big. Then the user could resize his/her image as he/she likes it.

just my 2€ct.

Greets,
Christian
kpassey
Forum Baby

Joined: 01/02/2006 12:05:10
Messages: 12
Location: UK
Offline

This is what I did to my tomcat5.conf file - it is simpler.#



the file is /etc/tomcat5/tomcat5.conf

Works fine.

Kev
Anonymous



Rafael Steil wrote:
0m4r wrote:have u never tried to use the this api: https://jai.dev.java.net/ ?


Nope.. I'll take a look.

Other main problem with regular JDK 1.4 image classes is that they are SO SLOW.

Raael


I have done a bunch with JAI and let me tell you it is NOT FUN. I really don't think you want to go there.

I have found that JDK 1.5's image handling is reasonably good, probably as fast as any other options. JForum is doing exactly the right thing: convert them all to PNGs. Come on, it's 2006 already, PNGs are old news.

As for the headless server issue: This is not a problem at all on Java 1.5. You don't need to set anything. Yes in the old days AWT had difficulties dealing with images with no display available, but those days are long over.

Java 1.5 is two years old. Upgrading is painless. It runs faster and starts faster. Tomcat 5.5 is designed for Java 1.5. Wasting time trying to get stuff to run on older JVMs is just that: a waste of time. Java 6 is due out in a few months.

My big question is: When can we run JForum and Tomcat in a pure open Java implementation? In other words, when can we compile all this stuff with gcj/GNU CLASSPATH and have it run without any Sun Java? I realize that's a big question, because Tomcat itself is not yet supported with gcj, but it's coming sometime this year.

By the way, our JForum powered site is really doing well. In two days we've had 66 new members and 50,000 hits:

http://californiaccw.org

I'm very impressed by the software. I did take out the link back to JForum from the templates, but I put in some big text on the front page, and made a few forum posts about how great JForum is. At some point I'll create a whole page where I go through and describe all the software components that go into it: Linux, Tomcat, Java, JForum, etc.
Rafael Steil
Project Leader
[Avatar]

Joined: 23/12/2003 11:39:21
Messages: 4325
Location: Brazil
Offline

Interesting to know that as of JDK 1.5 java.awt.headless is not needed anymore. That's very good.

About the gcj question: I really don't know; never tried to make such test. But for the little I know about gcj, it should compile JForum without any problems.

Rafael

http://www.flickr.com/photos/rafaelsteil
[Email] [WWW] [MSN]
Anonymous



Rafael Steil wrote:Interesting to know that as of JDK 1.5 java.awt.headless is not needed anymore. That's very good.

About the gcj question: I really don't know; never tried to make such test. But for the little I know about gcj, it should compile JForum without any problems.
l


Tomcat doesn't yet run in gcj, so it will be some time before this whole setup can run in gcj. I just tried to compile the latest Postgres JDBC jar and it also does not compile in gcj, so there are some things to be fixed.

Again I strongly recommend using 1.5 if you aren't already.

Our forum now has over a hundred users and has had over 100,000 hits in the first week of operations. JForum is cool!
 
Forum Index » Downloading / Installing
Go to: