Meaningless Drivel is fun!
The moose likes Linux / UNIX and the fly likes Need help configuring X11 server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Need help configuring X11 server" Watch "Need help configuring X11 server" New topic

Need help configuring X11 server

Vanessa Hall

Joined: Dec 11, 2003
Posts: 15

We are using JBoss on Red Hat Linux with Java SDK version 1.3. One of our session EJBs does some manipulation of JPEG files, and thus uses the java.awt graphics and image objects. This causes the "can't connect to X11 server" exception to occur, unless we first run xhost +. (we cannot use the java.awt.headless feature because we are stuck on Java 1.3).

Our problem/question is that we can only get xhost + to run successfully if it is run from an xterm. Since this is a server, we cannot have any dependencies on a GUI. The requirement is that the machine boot up and run our JBoss application without any intervention. It is not acceptible to have a person log in and start up JBoss from an xterm.

Can anyone tell me how to configure the X server so that the machine will boot up with JBoss able to access X11? Any help would be greatly appreciated.


Vanessa<br />SCJP,SCJD,IBM OOAD w/UML,Project+
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

The best solution in my opinion (and also perhaps the easiest to implement) is to run a special X server for JBoss to use. You can use Xvfb, the X Virtual Frame Buffer, which you should already have on your system. Start it like this (do this in a startup script if you like

/usr/X11R6/bin/Xvfb -auth /dev/null :5 2>/dev/null &

Now you've got a second X server on display :5. Then just put something like

export DISPLAY=:5

into the script you use to startup JBoss, and Bob's your uncle!

[Jess in Action][AskingGoodQuestions]
Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

So long as you are stuck on JDK 1.3, I don't believe there is a solution. The condition lies between Sun's AWT library in this version, which relies on an underlying X server.

What you need in this case is either a) an AWT library that does not require an Xserver; or b) an Xserver that does not require display hardware to run.

For a), consider an alternate AWT library such as PJA.

For b), take a look at Xvfb, a virtual Xserver that runs without having a display adapter present.

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Vanessa Hall

Joined: Dec 11, 2003
Posts: 15
Thanks for the help. We went with the Xvfb solution and it works great.
Don't get me started about those stupid light bulbs.
subject: Need help configuring X11 server
It's not a secret anymore!