Google 网上论坛不再支持新的 Usenet 帖子或订阅项。历史内容仍可供查看。

Swing and X

已查看 1 次
跳至第一个未读帖子

Klaus Kristianse

未读,
2001年10月24日 04:18:462001/10/24
收件人
I am not sure if this problem is with Swing, or with Sitraka Software's
JClass Chart. But the
exception comes from deep within Swing, so it is probably Swing.

I am trying to draw a graph as part of a web page. The graph is sent as a
jpeg. It is not
displayed at the server.

This works on an NT and on a Solaris machine, both inside our firewall. But
when
moved to the production machine, which is outside the firewall, it gives
this exception:

Root cause:
java.lang.InternalError: Can't connect to X11 window server using 'klkr:0'
as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at <Unloaded Method>
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:124)
at
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment
.java:63)
at java.awt.Font.initializeFont(Font.java:262)
at java.awt.Font.<init>(Font.java:292)
at
javax.swing.plaf.metal.DefaultMetalTheme.<init>(DefaultMetalTheme.java:59)
at
javax.swing.plaf.metal.MetalLookAndFeel.createDefaultTheme(MetalLookAndFeel.
java:709)
at
javax.swing.plaf.metal.MetalLookAndFeel.getDefaults(MetalLookAndFeel.java:71
3)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:363)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:390)
at javax.swing.UIManager.initializeDefaultLAF(UIManager.java:850)
at javax.swing.UIManager.initialize(UIManager.java:926)
at javax.swing.UIManager.maybeInitialize(UIManager.java:948)
at javax.swing.UIManager.getUI(UIManager.java:559)
at javax.swing.JLabel.updateUI(JLabel.java:244)
at javax.swing.JLabel.<init>(JLabel.java:138)
at javax.swing.JLabel.<init>(JLabel.java:209)
at
com.klg.jclass.util.DefaultComponentLayout.<init>(DefaultComponentLayout.jav
a:68)
at com.klg.jclass.chart.JCChart.init(JCChart.java:188)
at com.klg.jclass.chart.JCChart.<init>(JCChart.java:470)
at
_0002fMaPic_0002ejspMaPic_jsp_1._jspService(_0002fMaPic_0002ejspMaPic_jsp_1.
java:156)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
va:177)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:210)
at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:479)

Does Swing need X to run? Can anything be done about that?

The machine does have X. I can even login from my PC. The display variable
gets set to klkr:0 in that case. (The machine is actually inside the
firewall right
now, to make installing various things easier. I expect that the X login
will
stop working once it is moved outside again).

I only run the server as klkr (my login) during testing. It will run as
nobody in
production.

Any ideas?

Klaus Kristiansen
Q8


Babu Kalakrishnan

未读,
2001年10月24日 08:19:032001/10/24
收件人
On Wed, 24 Oct 2001 10:18:46 +0200, Klaus Kristianse <kl...@q8.dk> wrote:
>I am not sure if this problem is with Swing, or with Sitraka Software's
>JClass Chart. But the
>exception comes from deep within Swing, so it is probably Swing.
>
>I am trying to draw a graph as part of a web page. The graph is sent as a
>jpeg. It is not
>displayed at the server.
>
>This works on an NT and on a Solaris machine, both inside our firewall. But
>when
>moved to the production machine, which is outside the firewall, it gives
>this exception:

[Exception snipped]

I suppose you're not running an X server on your production machine. The
current JDKs can't function without an X server display if your program
use s any of the classes in the awt/swing hierarchy (there may be some
exceptions here - but it is true for most classes) even if you aren't
going to display anything on it.

I've heard that JDK 1.4 will have some options to do it without an X
server (the so-called headless operating mode). Current workarounds are
to either run X on your machine or run something like a framebuffer
device on Linux (I'm not clear on how the latter solves the problem, but
this has been one of the workarounds suggested in newsgroups).

BK

Gordon Beaton

未读,
2001年10月24日 08:41:392001/10/24
收件人
On Wed, 24 Oct 2001 10:18:46 +0200, Klaus Kristianse wrote:
> I am not sure if this problem is with Swing, or with Sitraka
> Software's JClass Chart. But the exception comes from deep within
> Swing, so it is probably Swing.
>
> I am trying to draw a graph as part of a web page. The graph is sent
> as a jpeg. It is not displayed at the server.
>
> This works on an NT and on a Solaris machine, both inside our
> firewall. But when moved to the production machine, which is outside
> the firewall, it gives this exception:
>
> Root cause:
> java.lang.InternalError: Can't connect to X11 window server using
> 'klkr:0' as the value of the DISPLAY variable.

[...]

> Does Swing need X to run? Can anything be done about that?
>
> The machine does have X. I can even login from my PC.

"has X" means what, exactly? The fact that you can login is not
relevant here. Nor is the fact that the machine "has" X.

The error is caused because Swing tries to open the display, but your
firewall is preventing the incoming connection through the firewall to
your X server. You most likely get a similar error if you try to run
any X program on the remote machine while the DISPLAY variable points
to your local machine.

You have at least 3 alternatives:

1. Use JDK 1.4, where you can run Swing without a display.

2. Run Xvfb on the remote machine and set the DISPLAY variable
accordingly. Xfvb looks and acts like an X server but without an
actual display, letting Swing think that an X server is available.

3. Connect to the machine using ssh, which supports X tunneling. The
DISPLAY will be set to something on the remote machine, but the actual
display used will be your local workstation (back through the ssh
connection).

/gordon

--
[ do not send me private copies of your followups ]
g o r d o n . b e a t o n @ e r i c s s o n . c o m

Klaus Kristianse

未读,
2001年10月24日 09:47:422001/10/24
收件人

"Gordon Beaton" <n...@for.email> skrev i en meddelelse
news:9r6cu3$e59$1...@news.du.uab.ericsson.se...

> On Wed, 24 Oct 2001 10:18:46 +0200, Klaus Kristianse wrote:
> > I am not sure if this problem is with Swing, or with Sitraka
> > Software's JClass Chart. But the exception comes from deep within
> > Swing, so it is probably Swing.
> >
> > I am trying to draw a graph as part of a web page. The graph is sent
> > as a jpeg. It is not displayed at the server.
> >
> > This works on an NT and on a Solaris machine, both inside our
> > firewall. But when moved to the production machine, which is outside
> > the firewall, it gives this exception:
> >
> > Root cause:
> > java.lang.InternalError: Can't connect to X11 window server using
> > 'klkr:0' as the value of the DISPLAY variable.
>
> [...]
>
> > Does Swing need X to run? Can anything be done about that?
> >
> > The machine does have X. I can even login from my PC.
>
> "has X" means what, exactly? The fact that you can login is not
> relevant here. Nor is the fact that the machine "has" X.

Sorry about that. That was not very clearly expressed. There is an X
client running.
I can login via X. File manager, shells and so on running on the production
machine, windows shown on my PC.

> The error is caused because Swing tries to open the display, but your
> firewall is preventing the incoming connection through the firewall to
> your X server. You most likely get a similar error if you try to run
> any X program on the remote machine while the DISPLAY variable points
> to your local machine.
>
> You have at least 3 alternatives:
>
> 1. Use JDK 1.4, where you can run Swing without a display.
>
> 2. Run Xvfb on the remote machine and set the DISPLAY variable
> accordingly. Xfvb looks and acts like an X server but without an
> actual display, letting Swing think that an X server is available.

This would seem a good solution. Where can I get Xfvb?

> 3. Connect to the machine using ssh, which supports X tunneling. The
> DISPLAY will be set to something on the remote machine, but the actual
> display used will be your local workstation (back through the ssh
> connection).

But this needs to work even when my PC is turned off.

Thanks for your help.

Klaus Kristiansen
Q8


Gordon Beaton

未读,
2001年10月24日 10:45:082001/10/24
收件人
On Wed, 24 Oct 2001 15:47:42 +0200, Klaus Kristianse wrote:
> > 2. Run Xvfb on the remote machine and set the DISPLAY variable
> > accordingly. Xfvb looks and acts like an X server but without an
> > actual display, letting Swing think that an X server is available.
>
> This would seem a good solution. Where can I get Xfvb?

Sorry I spelled it wrong: Xvfb (virtual frame buffer). It's part of
the X distribution, available at ftp.x.org:

ftp://ftp.x.org/pub/R6.6/xc/programs/Xserver/hw/vfb/

0 个新帖子