You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by dg...@comcast.net on 2012/04/28 22:11:20 UTC

Running Swing app under Tomcat 6 on Linux

My version info: 

    • Tomcat 6.0.28 
    • Java 1.6 
    • Ubuntu 10.4 


I have a small debugging/monitoring app written in Java/Swing that I'd like to run inside Tomcat to help with debugging. The app is started by dynamically loading the monitoring class from a webservice running under Tomcat. The works in Windows (multiple flavors) but I'm having problems getting this running on Ubuntu. What I've tried so far: 

1) First error I got was an Headless exception. Since the app is a GUI app I can't run in headless mode. After searching around I changed Tomcat's library path (via -Djava.library.path in catalina.sh) to point to the client lib (ie. .../java-6-sun-1.6.0.26/jre/lib/i386/client) instead of the server lib. 

2) After changing the libs the next error was that DISPLAY wasn't set. After setting DISPLAY=0.0 in catalina.sh I get "Can't connect to X11 with DISPLAY=0.0" error. I've tried different values for DISPLAY (e.g. localhost:0.0) and nothing makes a difference. I've also tried fiddling around with the policies in case there's a permissions error. See below for the call stack. 

The webservice app is a simple RESTEasy implementation. Since this works in Windows I'm assuming (perhaps erroneously) that this can work in Linux. Any help would be appreciated. 

Thanks, 
DG 

java . lang . InternalError : Can 't connect to X11 window server using ' : 0 . 0 ' as the value of the DISPLAY variable. 
sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) 
sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52) 
sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155) 
java.security.AccessController.doPrivileged(Native Method) 
sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131) 
java.lang.Class.forName0(Native Method) 
java.lang.Class.forName(Class.java:169) 
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68) 
java.awt.Window.init(Window.java:380) 
java.awt.Window.<init>(Window.java:433) 
java.awt.Frame.<init>(Frame.java:403) 
java.awt.Frame.<init>(Frame.java:368) 
javax.swing.JFrame.<init>(JFrame.java:158) 
com.quinsoft.zeidon.objectbrowser.ObjectBrowser.startup(ObjectBrowser.java:60) 


Re: Running Swing app under Tomcat 6 on Linux

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

DG,

On 5/1/12 12:44 PM, dgchristensen@comcast.net wrote:
> jhat displays the raw data but the object browser allows the 
> developer to view the data in a structured format.  At the risk of 
> using another lousy analogy, the application data is formated in a 
> sort of high-functioning, hierarchical DOM.  The browser lets the 
> developer peruse (or, uh, browse) the data in this hierarchical 
> format in real-time.  It's sort of like the DOM viewer in Firebug 
> (but better! of course).  The first time developers see their data 
> displayed by the browser there is almost always ooh-ing and
> ahh-ing.

Yeah, I guess jhat was a bad example. I just meant that jhat doesn't
include its own client... you provide your own (web browser).

If your data is hierarchical, it sounds like it would be natural to
express it in XML. It's fairly easy to write an XSL stylesheet that can
convert that into something that can expand/collapse with clicks, etc.

> I agree that some sort of remoting is the best solution.  That
> just takes time and I was hoping for a quick solution.  Woe is
> life. ;)
> 
> If you want to continue this further feel free to contact me 
> directly.  I'm always open to informed opinions.  For the long run 
> I'm looking at http://sites.google.com/site/simpleremoting/home

I wouldn't recommend JSON for large amounts of data, especially when
it's structured and nested in the way you have described. On the other
hand, XML is typically very verbose.

Good luck,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+gT5cACgkQ9CaO5/Lv0PAYbwCcD/RhCQ0D0EaLVlIi6KW883zC
XIYAn2QwWXytJh7HRuGSjRROHgvx6GHC
=dC81
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running Swing app under Tomcat 6 on Linux

Posted by dg...@comcast.net.
----- Original Message -----
> From: "Christopher Schultz" <ch...@christopherschultz.net>
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Sent: Tuesday, May 1, 2012 10:18:22 AM
> Subject: Re: Running Swing app under Tomcat 6 on Linux
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> DG,
> 
> At this point, we're way off-topic but I'll keep playing if you want
> to ;)

I appreciate your input.  Hopefully this isn't too far off and annoying other readers. :)

> This sounds a lot like what jhat does (gives you access to underlying
> data in a "browser"). You might consider using the jhat model and
> providing a web-based interface for the same data instead of swing.

jhat displays the raw data but the object browser allows the developer to view the data in a structured format.  At the risk of using another lousy analogy, the application data is formated in a sort of high-functioning, hierarchical DOM.  The browser lets the developer peruse (or, uh, browse) the data in this hierarchical format in real-time.  It's sort of like the DOM viewer in Firebug (but better! of course).  The first time developers see their data displayed by the browser there is almost always ooh-ing and ahh-ing.

> If the swing interface makes the user experience that much better
> (e.g. because you have certain widgets available, etc.) then you can
> still use swing... just browsing a web-based interface (say,
> delivering XML, binary data, or even serialized Java objects if you
> really want to do that kind of thing).
> 
> > The browser is written using Swing, originally on Windows, and the
> >  users (who are engineers) like it. Now I'm trying to get it
> > working on Linux. A better long-term solution would perhaps be to
> > create a JMX API but that's a lot of changes for something that
> > already works on Windows.
> 
> I don't think JMX is appropriate, here.
> 
> > As always, engineering time is short and I'm looking for the
> > quickest solution that doesn't confine me in the future. I'm open
> > to any alternative ideas if they are relatively quick to
> > implement.
> 
> My suggestion would be to use HTTP as your transport protocol (you
> *are* running on an HTTP-based application server so why not?) and
> either a pure web-based interface or a swing app that actually runs on
> the client and connects "remotely" (even if it's on the same box) to
> the server.
> 
> At this point, you may be too far down the road to re-tool, but I
> think you'll gain more flexibility if your users don't have to be
> sitting on localhost in order to browse this data. Plus, you won't
> have to go through these crazy hoops to get it to work.

I agree that some sort of remoting is the best solution.  That just takes time and I was hoping for a quick solution.  Woe is life. ;)

If you want to continue this further feel free to contact me directly.  I'm always open to informed opinions.  For the long run I'm looking at http://sites.google.com/site/simpleremoting/home

DG

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running Swing app under Tomcat 6 on Linux

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

DG,

At this point, we're way off-topic but I'll keep playing if you want to ;)

On 4/30/12 12:46 PM, dgchristensen@comcast.net wrote:
> Thanks for the input.  I guess I should give more rationale on why 
> I want to do this.  My webservice(s) use an open source project 
> that acts as a DB engine for retrieving data from the DB (google 
> 'zeidonjoe' if any of you are interested).  The data engine has a 
> browser that lets a developer view all the retrieved data in a 
> structured GUI.  In a way it would be like viewing all your active
>  Hibernate objects, showing data and relationships.  It can be a 
> very powerful tool while debugging.  The browser is dynamically 
> loaded+started by the data engine and it (the browser) has access 
> to the engine's internal objects so that the DB data can be 
> displayed.

This sounds a lot like what jhat does (gives you access to underlying
data in a "browser"). You might consider using the jhat model and
providing a web-based interface for the same data instead of swing.

If the swing interface makes the user experience that much better
(e.g. because you have certain widgets available, etc.) then you can
still use swing... just browsing a web-based interface (say,
delivering XML, binary data, or even serialized Java objects if you
really want to do that kind of thing).

> The browser is written using Swing, originally on Windows, and the
>  users (who are engineers) like it.  Now I'm trying to get it 
> working on Linux.  A better long-term solution would perhaps be to 
> create a JMX API but that's a lot of changes for something that 
> already works on Windows.

I don't think JMX is appropriate, here.

> As always, engineering time is short and I'm looking for the 
> quickest solution that doesn't confine me in the future.  I'm open 
> to any alternative ideas if they are relatively quick to 
> implement.

My suggestion would be to use HTTP as your transport protocol (you
*are* running on an HTTP-based application server so why not?) and
either a pure web-based interface or a swing app that actually runs on
the client and connects "remotely" (even if it's on the same box) to
the server.

At this point, you may be too far down the road to re-tool, but I
think you'll gain more flexibility if your users don't have to be
sitting on localhost in order to browse this data. Plus, you won't
have to go through these crazy hoops to get it to work.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+f8K4ACgkQ9CaO5/Lv0PD43QCdEW5+83VIVBQ/g4997N+IM+zt
ROIAn1mGHEKATUy//HhdyjPYNRHpideI
=BHtV
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running Swing app under Tomcat 6 on Linux

Posted by dg...@comcast.net.

----- Original Message -----
> From: "Christopher Schultz" <ch...@christopherschultz.net>
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Sent: Monday, April 30, 2012 10:40:17 AM
> Subject: Re: Running Swing app under Tomcat 6 on Linux
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> DG,
> 
> On 4/28/12 4:11 PM, dgchristensen@comcast.net wrote:
> > I have a small debugging/monitoring app written in Java/Swing that
> >  I'd like to run inside Tomcat to help with debugging.
> 
> You are asking for all kinds of pain, here.
> 
> > The app is started by dynamically loading the monitoring class from
> > a webservice running under Tomcat.
> 
> So, the GUI monitoring app loads classes from a webservice hosted by
> the webapp? Elsewhere in this thread, you said it had to run in the
> same JVM because it directly-accesses some of the objects. Those two
> statements seem to contradict one another.
 
Thanks for the input.  I guess I should give more rationale on why I want to do this.  My webservice(s) use an open source project that acts as a DB engine for retrieving data from the DB (google 'zeidonjoe' if any of you are interested).  The data engine has a browser that lets a developer view all the retrieved data in a structured GUI.  In a way it would be like viewing all your active Hibernate objects, showing data and relationships.  It can be a very powerful tool while debugging.  The browser is dynamically loaded+started by the data engine and it (the browser) has access to the engine's internal objects so that the DB data can be displayed.

The browser is written using Swing, originally on Windows, and the users (who are engineers) like it.  Now I'm trying to get it working on Linux.  A better long-term solution would perhaps be to create a JMX API but that's a lot of changes for something that already works on Windows.  As always, engineering time is short and I'm looking for the quickest solution that doesn't confine me in the future.  I'm open to any alternative ideas if they are relatively quick to implement.

DG

> > The works in Windows (multiple flavors) but I'm having problems
> > getting this running on Ubuntu.
> 
> The presence of the always-running GUI environment in Microsoft
> Windows is the reason stuff like this works there.
> 
> > What I've tried so far:
> >
> > 1) First error I got was an Headless exception. Since the app is a
> >  GUI app I can't run in headless mode. After searching around I
> > changed Tomcat's library path (via -Djava.library.path in
> > catalina.sh) to point to the client lib (ie.
> > .../java-6-sun-1.6.0.26/jre/lib/i386/client)> instead of the
> > server lib.
> 
> You should be able to do this with the "-client" command-line
> parameter. I'm not sure why you would need this at all, except maybe
> - -server in your environment also implies "headless", which can also
> be
> changed using a command-line parameter. You shouldn't have to mess
> with the java.library.path.
> 
> > 2) After changing the libs the next error was that DISPLAY wasn't
> > set. After setting DISPLAY=0.0 in catalina.sh I get "Can't connect
> > to X11 with DISPLAY=0.0" error. I've tried different values for
> > DISPLAY (e.g. localhost:0.0) and nothing makes a difference. I've
> > also tried fiddling around with the policies in case there's a
> > permissions error. See below for the call stack.
> 
> As Mark says, you'll need to set this to your actual DISPLAY. When
> you're logged-in to your laptop, open an xterm and type "echo
> $DISPLAY". Use whatever value that is to attach to your X display.
> 
> If Tomcat is running as a user other than you, then you might also
> have to do an "xhost +" as yourself to allow any client to connect to
> your X server.
> 
> > The webservice app is a simple RESTEasy implementation. Since this
> > works in Windows I'm assuming (perhaps erroneously) that this can
> > work in Linux. Any help would be appreciated.
> 
> I'm sure it *can* work in Linux, but the whole thing sounds insane to
> me.
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk+epFEACgkQ9CaO5/Lv0PD5TQCfaHXWYeFPrDR2H5OMjOyFMHsI
> fjQAniXwykkxw5sMfWlCvI9n0zHYNRT8
> =LHQA
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running Swing app under Tomcat 6 on Linux

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

DG,

On 4/28/12 4:11 PM, dgchristensen@comcast.net wrote:
> I have a small debugging/monitoring app written in Java/Swing that
>  I'd like to run inside Tomcat to help with debugging.

You are asking for all kinds of pain, here.

> The app is started by dynamically loading the monitoring class from
> a webservice running under Tomcat.

So, the GUI monitoring app loads classes from a webservice hosted by
the webapp? Elsewhere in this thread, you said it had to run in the
same JVM because it directly-accesses some of the objects. Those two
statements seem to contradict one another.

> The works in Windows (multiple flavors) but I'm having problems 
> getting this running on Ubuntu.

The presence of the always-running GUI environment in Microsoft
Windows is the reason stuff like this works there.

> What I've tried so far:
> 
> 1) First error I got was an Headless exception. Since the app is a
>  GUI app I can't run in headless mode. After searching around I 
> changed Tomcat's library path (via -Djava.library.path in 
> catalina.sh) to point to the client lib (ie. 
> .../java-6-sun-1.6.0.26/jre/lib/i386/client)> instead of the
> server lib.

You should be able to do this with the "-client" command-line
parameter. I'm not sure why you would need this at all, except maybe
- -server in your environment also implies "headless", which can also be
changed using a command-line parameter. You shouldn't have to mess
with the java.library.path.

> 2) After changing the libs the next error was that DISPLAY wasn't 
> set. After setting DISPLAY=0.0 in catalina.sh I get "Can't connect
> to X11 with DISPLAY=0.0" error. I've tried different values for
> DISPLAY (e.g. localhost:0.0) and nothing makes a difference. I've
> also tried fiddling around with the policies in case there's a
> permissions error. See below for the call stack.

As Mark says, you'll need to set this to your actual DISPLAY. When
you're logged-in to your laptop, open an xterm and type "echo
$DISPLAY". Use whatever value that is to attach to your X display.

If Tomcat is running as a user other than you, then you might also
have to do an "xhost +" as yourself to allow any client to connect to
your X server.

> The webservice app is a simple RESTEasy implementation. Since this 
> works in Windows I'm assuming (perhaps erroneously) that this can 
> work in Linux. Any help would be appreciated.

I'm sure it *can* work in Linux, but the whole thing sounds insane to me.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+epFEACgkQ9CaO5/Lv0PD5TQCfaHXWYeFPrDR2H5OMjOyFMHsI
fjQAniXwykkxw5sMfWlCvI9n0zHYNRT8
=LHQA
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running Swing app under Tomcat 6 on Linux

Posted by Mark Eggers <it...@yahoo.com>.
----- Original Message -----

> From: "dgchristensen@comcast.net" <dg...@comcast.net>
> To: Tomcat Users List <us...@tomcat.apache.org>; Mark Eggers <it...@yahoo.com>
> Cc: 
> Sent: Tuesday, May 1, 2012 10:39 AM
> Subject: Re: Running Swing app under Tomcat 6 on Linux
> 
> 
> ----- Original Message -----
>>  From: "Mark Eggers" <it...@yahoo.com>
>>  To: "Tomcat Users List" <us...@tomcat.apache.org>
>>  Sent: Monday, April 30, 2012 12:23:57 AM
>>  Subject: Re: Running Swing app under Tomcat 6 on Linux
>>  Comment inline.
>>  ====== Comment ======
>> 
>> 
>>  I don't know what magic the Ubuntu repackaging does. If it's 
> anything
>>  like the CentOS repackaging, it's pretty involved.
>> 
>>  One thing you might try is the following:
>> 
>>  1. sudo service tomcat6 stop
>>  2. Download a copy of Tomcat from Apache
>>  3. Unpack it in your home directory
>>  4. Edit $CATALINA_HOME/conf/tomcat-users.xml
>>  5. Add your application to $CATALINA_HOME/webapps
>>  6. export JRE_HOME=[your Java JRE installation]
>>  7. cd $CATALINA_HOME/bin
>>  8. Make sure startup.sh is executable
>>  9. ./startup.sh
>> 
>>  And see what happens.
> 
> Mark, you are a genius.  I followed the above and the Swing app starts without a 
> problem.  If anybody's willing to explain it, I'd like to understand 
> what the difference is between starting Tomcat via startup.sh and starting it as 
> a service.


You're welcome. I'm glad it worked. See my response to Christopher's message concerning what I think is going on and one way maybe to get around it.

. . . . just my two cents.
/mde/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running Swing app under Tomcat 6 on Linux

Posted by Mark Eggers <it...@yahoo.com>.
----- Original Message -----

> From: Christopher Schultz <ch...@christopherschultz.net>
> To: Tomcat Users List <us...@tomcat.apache.org>
> Cc: 
> Sent: Tuesday, May 1, 2012 2:00 PM
> Subject: Re: Running Swing app under Tomcat 6 on Linux
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> DG,
> 
> On 5/1/12 1:39 PM, dgchristensen@comcast.net wrote:
>>  Mark, you are a genius.  I followed the above and the Swing app 
>>  starts without a problem.  If anybody's willing to explain it, I'd 
>>  like to understand what the difference is between starting Tomcat
>>  via startup.sh and starting it as a service.
> 
> If you run Tomcat as a "service" (whatever that means under Linux),
> then it probably runs as some user other than "you" (the one who owns
> the X environment). When you run it as "you", then you get access to 
> X.
> 
> It would work as a service if:
> 
> 1. X starts before Tomcat

+1

At least on CentOS Tomcat starts at run level 3, so you won't have an X server available. You could try the following, but again I don't know if you can enforce the order.

As root, do the following:

chkconfig --levels 34 tomcat6 off

chkconfig --list tomcat6

You should only see tomcat6 start up on run level 5, which is multi-user plus X.

Now, add the display variable (DISPLAY=localhost:0.0 or maybe DISPLAY=localhost.localdomain:0.0) to setenv.sh. This is provided that the Ubuntu scripts do the right thing and execute setenv.sh . . .

I of course have no idea what happens when a person runs your web application remotely.

I'm not sure that this will help, but at least it's a shot.

/mde/

> 2. X is configured with "xhost +" for whatever user it is
> 3. Tomcat's startup can have the proper DISPLAY variable set
> (localhost:0?)
> 
> - -chris
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk+gTuoACgkQ9CaO5/Lv0PBh6QCbBMXdRUUp6ZQyd+X4YzIahs8O
> GB0An35Yf17m5FdrQXrW6OlRaUFvFput
> =w5WE
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running Swing app under Tomcat 6 on Linux

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

DG,

On 5/1/12 1:39 PM, dgchristensen@comcast.net wrote:
> Mark, you are a genius.  I followed the above and the Swing app 
> starts without a problem.  If anybody's willing to explain it, I'd 
> like to understand what the difference is between starting Tomcat
> via startup.sh and starting it as a service.

If you run Tomcat as a "service" (whatever that means under Linux),
then it probably runs as some user other than "you" (the one who owns
the X environment). When you run it as "you", then you get access to X.

It would work as a service if:

1. X starts before Tomcat
2. X is configured with "xhost +" for whatever user it is
3. Tomcat's startup can have the proper DISPLAY variable set
(localhost:0?)

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+gTuoACgkQ9CaO5/Lv0PBh6QCbBMXdRUUp6ZQyd+X4YzIahs8O
GB0An35Yf17m5FdrQXrW6OlRaUFvFput
=w5WE
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running Swing app under Tomcat 6 on Linux

Posted by dg...@comcast.net.
----- Original Message -----
> From: "Mark Eggers" <it...@yahoo.com>
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Sent: Monday, April 30, 2012 12:23:57 AM
> Subject: Re: Running Swing app under Tomcat 6 on Linux
> Comment inline.
> ====== Comment ======
> 
> 
> I don't know what magic the Ubuntu repackaging does. If it's anything
> like the CentOS repackaging, it's pretty involved.
> 
> One thing you might try is the following:
> 
> 1. sudo service tomcat6 stop
> 2. Download a copy of Tomcat from Apache
> 3. Unpack it in your home directory
> 4. Edit $CATALINA_HOME/conf/tomcat-users.xml
> 5. Add your application to $CATALINA_HOME/webapps
> 6. export JRE_HOME=[your Java JRE installation]
> 7. cd $CATALINA_HOME/bin
> 8. Make sure startup.sh is executable
> 9. ./startup.sh
> 
> And see what happens.

Mark, you are a genius.  I followed the above and the Swing app starts without a problem.  If anybody's willing to explain it, I'd like to understand what the difference is between starting Tomcat via startup.sh and starting it as a service.

Thanks again,
DG

> 
> Also, run /sbin/chkconfig tomcat6
> 
> If it's on at level 3, then it's been started before there's an X
> display. However, you'd think running
> 
> sudo service tomcat6 start
> 
> would then fail since it should already be running. I wonder if you're
> running two copies of Tomcat 6, and you've placed your application in
> the webapps directory started at run level 3.
> 
> ====== Comment ======
> 
> 
> >>  I've tried running startup.sh directly from the console but it
> > doesn't work. It looks like /etc/init.d/tomcat6 sets up some env
> > vars
> > before starting Tomcat. I can try updating my environment so I can
> > run
> > startup.sh if you think it worth attempting.
> >
> >>  Please don't top-post. Answer inline instead.
> >>
> >>  Tomcat has no knowledge of Swing, so or UI components of this
> >>  nature.
> >>  Is there a reason it has to be started from Tomcat?
> >
> > The app needs to be running in the same JVM as the Tomcat
> > applications so it can
> > access some of the application's objects. Some day I may re-write it
> > to use
> > JMX but that's a big change that won't happen soon. Getting it to
> > run
> > as a "normal" Swing app under Tomcat is the expedient solution for
> > now.
> >
> > I was assuming (perhaps wrongly) that Swing was just a collection of
> > classes
> > that didn't need any special environment (other than a running X
> > server).
> >
> >>  p
> >
> >>  Thanks,
> >>  DG
> >>
> >>  ----- Original Message -----
> >>  From: "Mark Eggers" <it...@yahoo.com>
> >>  To: "Tomcat Users List" <us...@tomcat.apache.org>
> >>  Sent: Saturday, April 28, 2012 6:50:07 PM
> >>  Subject: Re: Running Swing app under Tomcat 6 on Linux
> >>
> >>  Comments and questions are in line. Please note I run Fedora /
> >>  CentOS /
> > Redhat and I'm not so familiar with Ubuntu.
> >>
> >>  ----- Original Message -----
> >>
> >>>  From: "dgchristensen@comcast.net"
> > <dg...@comcast.net>
> >>>  To: users@tomcat.apache.org
> >>>  Cc:
> >>>  Sent: Saturday, April 28, 2012 1:11 PM
> >>>  Subject: Running Swing app under Tomcat 6 on Linux
> >>>
> >>>  My version info:
> >>>
> >>>  • Tomcat 6.0.28
> >>>  • Java 1.6
> >>>  • Ubuntu 10.4
> >>>
> >>>
> >>>  I have a small debugging/monitoring app written in Java/Swing
> >>>  that
> > I'd like
> >>>  to run inside Tomcat to help with debugging. The app is started
> >>>  by
> >>>  dynamically loading the monitoring class from a webservice
> >>>  running
> > under
> >>>  Tomcat. The works in Windows (multiple flavors) but I'm having
> > problems
> >>>  getting this running on Ubuntu. What I've tried so far:
> >>
> >>  What does this give you that monitoring the application via JMX
> >>  (see
> > VisualVM, jconsole), and debugging with your favorite IDE (NetBeans,
> > Eclipse,
> > IntelliJ) doesn't give you? You can actually do both locally as well
> > as
> > remotely (with a little bit of setup).
> >>
> >>>
> >>>  1) First error I got was an Headless exception. Since the app is
> >>>  a GUI
> > app I
> >>>  can't run in headless mode. After searching around I changed
> > Tomcat's
> >>>  library path (via -Djava.library.path in catalina.sh) to point to
> >>>  the
> >>>  client lib (ie. .../java-6-sun-1.6.0.26/jre/lib/i386/client)
> >>>  instead of
> > the
> >>>  server lib.
> >>
> >>  Try setting JRE_HOME in the environment to point to a JRE
> >>  installation
> > instead. Or use JAVA_HOME and point to the JDK. Tomcat will figure
> > things out.
> >>
> >>  If your environment is not set up by default to do that (mine is
> >>  with
> > custom.sh in /etc/profiles.d), create and use a setenv.sh script in
> > CATALINA_HOME. In this set any CATALINA_OPTS, JAVA_OPTS, and other
> > environment
> > variables you need to.
> >>
> >>>
> >>>  2) After changing the libs the next error was that DISPLAY wasn't
> > set. After
> >>>  setting DISPLAY=0.0 in catalina.sh I get "Can't connect to X11
> > with
> >>>  DISPLAY=0.0" error. I've tried different values for DISPLAY
> > (e.g.
> >>>  localhost:0.0) and nothing makes a difference. I've also tried
> > fiddling
> >>>  around with the policies in case there's a permissions error. See
> > below for
> >>>  the call stack.
> >>
> >>  Are you running an X server? By that, are I mean is Ubuntu showing
> >>  up in
> > whatever GUI you've chosen (I guess Gnome 2 is that version's
> > default)?
> >>
> >>  If you only have a command line interface, then there's no place
> >>  to
> > create the screen. You can play games with a virtual frame buffer,
> > but that will
> > just allow your program to run, but without any screen output
> > (obviously).
> >>
> >>  Again, don't set the DISPLAY environment variable in catalina.sh.
> >>  Set
> > this in setenv.sh in the bin directory of CATALINA_HOME. There are
> > lots of
> > scenarios here. Three common ones come to mind.
> >>
> >>  1. Local X server
> >>
> >>  You're at the console and running in a GUI environment. The
> >>  display
> > environment variable should already be set (typically :0.0). If you
> > start Tomcat
> > with your application in this environment, the GUI interface should
> > just appear.
> >
> >>
> >>  2. Remote client, accessing the GUI via a VNC server (such as
> >>  TightVNC)
> >>
> >>  Your display environment should already be set. For example, I'm
> > currently on a remote CentOS 5.8 system via VNC. My DISPLAY
> > environment variable
> > is set to :0.2. If you start Tomcat with your application in this
> > environment,
> > the GUI interface should just appear in the VNC viewer (for example
> > TightVNC).
> >>
> >>  3. Remote client, X server
> >>
> >>  Note that an X server means your PC is serving the screen,
> >>  keyboard, and
> > mouse to a remote client (your application). To accomplish this
> > you'll have
> > to have an X server running (if you're on Windows, try XMing), and
> > you'll have to set the DISPLAY variable appropriately. Running Java
> > swing
> > applications in this fashion is not very pleasant especially if your
> > program is
> > graphics-intensive.
> >>
> >>>  The webservice app is a simple RESTEasy implementation. Since
> >>>  this
> > works in
> >>>  Windows I'm assuming (perhaps erroneously) that this can work in
> > Linux. Any
> >>>  help would be appreciated.
> >>>
> >>>  Thanks,
> >>>  DG
> >>>
> >>>  java . lang . InternalError : Can 't connect to X11 window server
> > using
> >>>  ' : 0 . 0 ' as the value of the DISPLAY variable.
> >>>  sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
> >>>
> > sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52)
> >>>  sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155)
> >>>  java.security.AccessController.doPrivileged(Native Method)
> >>>
> > sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131)
> >>>  java.lang.Class.forName0(Native Method)
> >>>  java.lang.Class.forName(Class.java:169)
> >>>
> > java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
> >
> >>>
> >>>  java.awt.Window.init(Window.java:380)
> >>>  java.awt.Window.<init>(Window.java:433)
> >>>  java.awt.Frame.<init>(Frame.java:403)
> >>>  java.awt.Frame.<init>(Frame.java:368)
> >>>  javax.swing.JFrame.<init>(JFrame.java:158)
> >>>
> > com.quinsoft.zeidon.objectbrowser.ObjectBrowser.startup(ObjectBrowser.java:60)
> >>>
> >>
> >>
> >>  This should work just fine if you're running an X server on your
> >>  Ubuntu
> > system. The DISPLAY environment variable should be :0.0 (no spaces)
> > for a local
> > machine.
> >>
> >>  . . . . just my two cents.
> >>  /mde/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running Swing app under Tomcat 6 on Linux

Posted by Mark Eggers <it...@yahoo.com>.
Comment inline.

Search for ====== Comment ======

----- Original Message -----

> From: "dgchristensen@comcast.net" <dg...@comcast.net>
> To: Tomcat Users List <us...@tomcat.apache.org>
> Cc: 
> Sent: Sunday, April 29, 2012 6:49 PM
> Subject: Re: Running Swing app under Tomcat 6 on Linux
> 
> 
> 
> ----- Original Message -----
> From: "Pid" <pi...@pidster.com>
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Sent: Sunday, April 29, 2012 5:53:43 PM
> Subject: Re: Running Swing app under Tomcat 6 on Linux
> 
> On 29/04/2012 22:08, dgchristensen@comcast.net wrote:
>>  Thanks for the response Mark. I've done as you've suggested and 
> moved the env vars to setenv.sh and explicitly set JAVA_HOME. Setting JAVA_HOME 
> means I no longer need to change the -Djava.library.path but I still get the 
> same error (X11 not found). 
>> 
>>  I definitely have an X11 server running on the server (which is really my 
> laptop; I'm running all of this locally on my laptop--no remoting). Is it 
> possible that the problem occurs because I am running Tomcat as a daemon? The 
> command I use to start Tomcat is: 
>> 
>>  sudo service tomcat6 start 
>>

====== Comment ====== 


I don't know what magic the Ubuntu repackaging does. If it's anything like the CentOS repackaging, it's pretty involved.

One thing you might try is the following:

1. sudo service tomcat6 stop
2. Download a copy of Tomcat from Apache
3. Unpack it in your home directory
4. Edit $CATALINA_HOME/conf/tomcat-users.xml
5. Add your application to $CATALINA_HOME/webapps
6. export JRE_HOME=[your Java JRE installation]
7. cd $CATALINA_HOME/bin
8. Make sure startup.sh is executable
9. ./startup.sh

And see what happens.

Also, run /sbin/chkconfig tomcat6

If it's on at level 3, then it's been started before there's an X display. However, you'd think running 

sudo service tomcat6 start

would then fail since it should already be running. I wonder if you're running two copies of Tomcat 6, and you've placed your application in the webapps directory started at run level 3.

====== Comment ======  


>>  I've tried running startup.sh directly from the console but it 
> doesn't work.  It looks like /etc/init.d/tomcat6 sets up some env vars 
> before starting Tomcat.  I can try updating my environment so I can run 
> startup.sh if you think it worth attempting.
> 
>>  Please don't top-post.  Answer inline instead.
>> 
>>  Tomcat has no knowledge of Swing, so or UI components of this nature.
>>  Is there a reason it has to be started from Tomcat?
> 
> The app needs to be running in the same JVM as the Tomcat applications so it can 
> access some of the application's objects.  Some day I may re-write it to use 
> JMX but that's a big change that won't happen soon.  Getting it to run 
> as a "normal" Swing app under Tomcat is the expedient solution for 
> now.
> 
> I was assuming (perhaps wrongly) that Swing was just a collection of classes 
> that didn't need any special environment (other than a running X server).
> 
>>  p
> 
>>  Thanks,
>>  DG
>> 
>>  ----- Original Message ----- 
>>  From: "Mark Eggers" <it...@yahoo.com> 
>>  To: "Tomcat Users List" <us...@tomcat.apache.org> 
>>  Sent: Saturday, April 28, 2012 6:50:07 PM 
>>  Subject: Re: Running Swing app under Tomcat 6 on Linux 
>> 
>>  Comments and questions are in line. Please note I run Fedora / CentOS / 
> Redhat and I'm not so familiar with Ubuntu. 
>> 
>>  ----- Original Message ----- 
>> 
>>>  From: "dgchristensen@comcast.net" 
> <dg...@comcast.net> 
>>>  To: users@tomcat.apache.org 
>>>  Cc: 
>>>  Sent: Saturday, April 28, 2012 1:11 PM 
>>>  Subject: Running Swing app under Tomcat 6 on Linux 
>>> 
>>>  My version info: 
>>> 
>>>  • Tomcat 6.0.28 
>>>  • Java 1.6 
>>>  • Ubuntu 10.4 
>>> 
>>> 
>>>  I have a small debugging/monitoring app written in Java/Swing that 
> I'd like 
>>>  to run inside Tomcat to help with debugging. The app is started by 
>>>  dynamically loading the monitoring class from a webservice running 
> under 
>>>  Tomcat. The works in Windows (multiple flavors) but I'm having 
> problems 
>>>  getting this running on Ubuntu. What I've tried so far: 
>> 
>>  What does this give you that monitoring the application via JMX (see 
> VisualVM, jconsole), and debugging with your favorite IDE (NetBeans, Eclipse, 
> IntelliJ) doesn't give you? You can actually do both locally as well as 
> remotely (with a little bit of setup). 
>> 
>>> 
>>>  1) First error I got was an Headless exception. Since the app is a GUI 
> app I 
>>>  can't run in headless mode. After searching around I changed 
> Tomcat's 
>>>  library path (via -Djava.library.path in catalina.sh) to point to the 
>>>  client lib (ie. .../java-6-sun-1.6.0.26/jre/lib/i386/client) instead of 
> the 
>>>  server lib. 
>> 
>>  Try setting JRE_HOME in the environment to point to a JRE installation 
> instead. Or use JAVA_HOME and point to the JDK. Tomcat will figure things out. 
>> 
>>  If your environment is not set up by default to do that (mine is with 
> custom.sh in /etc/profiles.d), create and use a setenv.sh script in 
> CATALINA_HOME. In this set any CATALINA_OPTS, JAVA_OPTS, and other environment 
> variables you need to. 
>> 
>>> 
>>>  2) After changing the libs the next error was that DISPLAY wasn't 
> set. After 
>>>  setting DISPLAY=0.0 in catalina.sh I get "Can't connect to X11 
> with 
>>>  DISPLAY=0.0" error. I've tried different values for DISPLAY 
> (e.g. 
>>>  localhost:0.0) and nothing makes a difference. I've also tried 
> fiddling 
>>>  around with the policies in case there's a permissions error. See 
> below for 
>>>  the call stack. 
>> 
>>  Are you running an X server? By that, are I mean is Ubuntu showing up in 
> whatever GUI you've chosen (I guess Gnome 2 is that version's default)? 
>> 
>>  If you only have a command line interface, then there's no place to 
> create the screen. You can play games with a virtual frame buffer, but that will 
> just allow your program to run, but without any screen output (obviously). 
>> 
>>  Again, don't set the DISPLAY environment variable in catalina.sh. Set 
> this in setenv.sh in the bin directory of CATALINA_HOME. There are lots of 
> scenarios here. Three common ones come to mind. 
>> 
>>  1. Local X server 
>> 
>>  You're at the console and running in a GUI environment. The display 
> environment variable should already be set (typically :0.0). If you start Tomcat 
> with your application in this environment, the GUI interface should just appear. 
> 
>> 
>>  2. Remote client, accessing the GUI via a VNC server (such as TightVNC) 
>> 
>>  Your display environment should already be set. For example, I'm 
> currently on a remote CentOS 5.8 system via VNC. My DISPLAY environment variable 
> is set to :0.2. If you start Tomcat with your application in this environment, 
> the GUI interface should just appear in the VNC viewer (for example TightVNC). 
>> 
>>  3. Remote client, X server 
>> 
>>  Note that an X server means your PC is serving the screen, keyboard, and 
> mouse to a remote client (your application). To accomplish this you'll have 
> to have an X server running (if you're on Windows, try XMing), and 
> you'll have to set the DISPLAY variable appropriately. Running Java swing 
> applications in this fashion is not very pleasant especially if your program is 
> graphics-intensive. 
>> 
>>>  The webservice app is a simple RESTEasy implementation. Since this 
> works in 
>>>  Windows I'm assuming (perhaps erroneously) that this can work in 
> Linux. Any 
>>>  help would be appreciated. 
>>> 
>>>  Thanks, 
>>>  DG 
>>> 
>>>  java . lang . InternalError : Can 't connect to X11 window server 
> using 
>>>  ' : 0 . 0 ' as the value of the DISPLAY variable. 
>>>  sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) 
>>> 
> sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52) 
>>>  sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155) 
>>>  java.security.AccessController.doPrivileged(Native Method) 
>>> 
> sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131) 
>>>  java.lang.Class.forName0(Native Method) 
>>>  java.lang.Class.forName(Class.java:169) 
>>> 
> java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68) 
> 
>>> 
>>>  java.awt.Window.init(Window.java:380) 
>>>  java.awt.Window.<init>(Window.java:433) 
>>>  java.awt.Frame.<init>(Frame.java:403) 
>>>  java.awt.Frame.<init>(Frame.java:368) 
>>>  javax.swing.JFrame.<init>(JFrame.java:158) 
>>> 
> com.quinsoft.zeidon.objectbrowser.ObjectBrowser.startup(ObjectBrowser.java:60) 
>>> 
>> 
>> 
>>  This should work just fine if you're running an X server on your Ubuntu 
> system. The DISPLAY environment variable should be :0.0 (no spaces) for a local 
> machine. 
>> 
>>  . . . . just my two cents. 
>>  /mde/ 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running Swing app under Tomcat 6 on Linux

Posted by dg...@comcast.net.

----- Original Message -----
From: "Pid" <pi...@pidster.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Sunday, April 29, 2012 5:53:43 PM
Subject: Re: Running Swing app under Tomcat 6 on Linux

On 29/04/2012 22:08, dgchristensen@comcast.net wrote:
> Thanks for the response Mark. I've done as you've suggested and moved the env vars to setenv.sh and explicitly set JAVA_HOME. Setting JAVA_HOME means I no longer need to change the -Djava.library.path but I still get the same error (X11 not found). 
> 
> I definitely have an X11 server running on the server (which is really my laptop; I'm running all of this locally on my laptop--no remoting). Is it possible that the problem occurs because I am running Tomcat as a daemon? The command I use to start Tomcat is: 
> 
> sudo service tomcat6 start 
> 
> I've tried running startup.sh directly from the console but it doesn't work.  It looks like /etc/init.d/tomcat6 sets up some env vars before starting Tomcat.  I can try updating my environment so I can run startup.sh if you think it worth attempting.

> Please don't top-post.  Answer inline instead.
>
> Tomcat has no knowledge of Swing, so or UI components of this nature.
> Is there a reason it has to be started from Tomcat?

The app needs to be running in the same JVM as the Tomcat applications so it can access some of the application's objects.  Some day I may re-write it to use JMX but that's a big change that won't happen soon.  Getting it to run as a "normal" Swing app under Tomcat is the expedient solution for now.

I was assuming (perhaps wrongly) that Swing was just a collection of classes that didn't need any special environment (other than a running X server).

> p

> Thanks,
> DG
> 
> ----- Original Message ----- 
> From: "Mark Eggers" <it...@yahoo.com> 
> To: "Tomcat Users List" <us...@tomcat.apache.org> 
> Sent: Saturday, April 28, 2012 6:50:07 PM 
> Subject: Re: Running Swing app under Tomcat 6 on Linux 
> 
> Comments and questions are in line. Please note I run Fedora / CentOS / Redhat and I'm not so familiar with Ubuntu. 
> 
> ----- Original Message ----- 
> 
>> From: "dgchristensen@comcast.net" <dg...@comcast.net> 
>> To: users@tomcat.apache.org 
>> Cc: 
>> Sent: Saturday, April 28, 2012 1:11 PM 
>> Subject: Running Swing app under Tomcat 6 on Linux 
>>
>> My version info: 
>>
>> • Tomcat 6.0.28 
>> • Java 1.6 
>> • Ubuntu 10.4 
>>
>>
>> I have a small debugging/monitoring app written in Java/Swing that I'd like 
>> to run inside Tomcat to help with debugging. The app is started by 
>> dynamically loading the monitoring class from a webservice running under 
>> Tomcat. The works in Windows (multiple flavors) but I'm having problems 
>> getting this running on Ubuntu. What I've tried so far: 
> 
> What does this give you that monitoring the application via JMX (see VisualVM, jconsole), and debugging with your favorite IDE (NetBeans, Eclipse, IntelliJ) doesn't give you? You can actually do both locally as well as remotely (with a little bit of setup). 
> 
>>
>> 1) First error I got was an Headless exception. Since the app is a GUI app I 
>> can't run in headless mode. After searching around I changed Tomcat's 
>> library path (via -Djava.library.path in catalina.sh) to point to the 
>> client lib (ie. .../java-6-sun-1.6.0.26/jre/lib/i386/client) instead of the 
>> server lib. 
> 
> Try setting JRE_HOME in the environment to point to a JRE installation instead. Or use JAVA_HOME and point to the JDK. Tomcat will figure things out. 
> 
> If your environment is not set up by default to do that (mine is with custom.sh in /etc/profiles.d), create and use a setenv.sh script in CATALINA_HOME. In this set any CATALINA_OPTS, JAVA_OPTS, and other environment variables you need to. 
> 
>>
>> 2) After changing the libs the next error was that DISPLAY wasn't set. After 
>> setting DISPLAY=0.0 in catalina.sh I get "Can't connect to X11 with 
>> DISPLAY=0.0" error. I've tried different values for DISPLAY (e.g. 
>> localhost:0.0) and nothing makes a difference. I've also tried fiddling 
>> around with the policies in case there's a permissions error. See below for 
>> the call stack. 
> 
> Are you running an X server? By that, are I mean is Ubuntu showing up in whatever GUI you've chosen (I guess Gnome 2 is that version's default)? 
> 
> If you only have a command line interface, then there's no place to create the screen. You can play games with a virtual frame buffer, but that will just allow your program to run, but without any screen output (obviously). 
> 
> Again, don't set the DISPLAY environment variable in catalina.sh. Set this in setenv.sh in the bin directory of CATALINA_HOME. There are lots of scenarios here. Three common ones come to mind. 
> 
> 1. Local X server 
> 
> You're at the console and running in a GUI environment. The display environment variable should already be set (typically :0.0). If you start Tomcat with your application in this environment, the GUI interface should just appear. 
> 
> 2. Remote client, accessing the GUI via a VNC server (such as TightVNC) 
> 
> Your display environment should already be set. For example, I'm currently on a remote CentOS 5.8 system via VNC. My DISPLAY environment variable is set to :0.2. If you start Tomcat with your application in this environment, the GUI interface should just appear in the VNC viewer (for example TightVNC). 
> 
> 3. Remote client, X server 
> 
> Note that an X server means your PC is serving the screen, keyboard, and mouse to a remote client (your application). To accomplish this you'll have to have an X server running (if you're on Windows, try XMing), and you'll have to set the DISPLAY variable appropriately. Running Java swing applications in this fashion is not very pleasant especially if your program is graphics-intensive. 
> 
>> The webservice app is a simple RESTEasy implementation. Since this works in 
>> Windows I'm assuming (perhaps erroneously) that this can work in Linux. Any 
>> help would be appreciated. 
>>
>> Thanks, 
>> DG 
>>
>> java . lang . InternalError : Can 't connect to X11 window server using 
>> ' : 0 . 0 ' as the value of the DISPLAY variable. 
>> sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) 
>> sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52) 
>> sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155) 
>> java.security.AccessController.doPrivileged(Native Method) 
>> sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131) 
>> java.lang.Class.forName0(Native Method) 
>> java.lang.Class.forName(Class.java:169) 
>> java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68) 
>>
>> java.awt.Window.init(Window.java:380) 
>> java.awt.Window.<init>(Window.java:433) 
>> java.awt.Frame.<init>(Frame.java:403) 
>> java.awt.Frame.<init>(Frame.java:368) 
>> javax.swing.JFrame.<init>(JFrame.java:158) 
>> com.quinsoft.zeidon.objectbrowser.ObjectBrowser.startup(ObjectBrowser.java:60) 
>>
> 
> 
> This should work just fine if you're running an X server on your Ubuntu system. The DISPLAY environment variable should be :0.0 (no spaces) for a local machine. 
> 
> . . . . just my two cents. 
> /mde/ 
> 
> --------------------------------------------------------------------- 
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org 
> For additional commands, e-mail: users-help@tomcat.apache.org 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


-- 

[key:62590808]


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running Swing app under Tomcat 6 on Linux

Posted by Pid <pi...@pidster.com>.
On 29/04/2012 22:08, dgchristensen@comcast.net wrote:
> Thanks for the response Mark. I've done as you've suggested and moved the env vars to setenv.sh and explicitly set JAVA_HOME. Setting JAVA_HOME means I no longer need to change the -Djava.library.path but I still get the same error (X11 not found). 
> 
> I definitely have an X11 server running on the server (which is really my laptop; I'm running all of this locally on my laptop--no remoting). Is it possible that the problem occurs because I am running Tomcat as a daemon? The command I use to start Tomcat is: 
> 
> sudo service tomcat6 start 
> 
> I've tried running startup.sh directly from the console but it doesn't work.  It looks like /etc/init.d/tomcat6 sets up some env vars before starting Tomcat.  I can try updating my environment so I can run startup.sh if you think it worth attempting.

Please don't top-post.  Answer inline instead.

Tomcat has no knowledge of Swing, so or UI components of this nature.
Is there a reason it has to be started from Tomcat?


p

> Thanks,
> DG
> 
> ----- Original Message ----- 
> From: "Mark Eggers" <it...@yahoo.com> 
> To: "Tomcat Users List" <us...@tomcat.apache.org> 
> Sent: Saturday, April 28, 2012 6:50:07 PM 
> Subject: Re: Running Swing app under Tomcat 6 on Linux 
> 
> Comments and questions are in line. Please note I run Fedora / CentOS / Redhat and I'm not so familiar with Ubuntu. 
> 
> ----- Original Message ----- 
> 
>> From: "dgchristensen@comcast.net" <dg...@comcast.net> 
>> To: users@tomcat.apache.org 
>> Cc: 
>> Sent: Saturday, April 28, 2012 1:11 PM 
>> Subject: Running Swing app under Tomcat 6 on Linux 
>>
>> My version info: 
>>
>> • Tomcat 6.0.28 
>> • Java 1.6 
>> • Ubuntu 10.4 
>>
>>
>> I have a small debugging/monitoring app written in Java/Swing that I'd like 
>> to run inside Tomcat to help with debugging. The app is started by 
>> dynamically loading the monitoring class from a webservice running under 
>> Tomcat. The works in Windows (multiple flavors) but I'm having problems 
>> getting this running on Ubuntu. What I've tried so far: 
> 
> What does this give you that monitoring the application via JMX (see VisualVM, jconsole), and debugging with your favorite IDE (NetBeans, Eclipse, IntelliJ) doesn't give you? You can actually do both locally as well as remotely (with a little bit of setup). 
> 
>>
>> 1) First error I got was an Headless exception. Since the app is a GUI app I 
>> can't run in headless mode. After searching around I changed Tomcat's 
>> library path (via -Djava.library.path in catalina.sh) to point to the 
>> client lib (ie. .../java-6-sun-1.6.0.26/jre/lib/i386/client) instead of the 
>> server lib. 
> 
> Try setting JRE_HOME in the environment to point to a JRE installation instead. Or use JAVA_HOME and point to the JDK. Tomcat will figure things out. 
> 
> If your environment is not set up by default to do that (mine is with custom.sh in /etc/profiles.d), create and use a setenv.sh script in CATALINA_HOME. In this set any CATALINA_OPTS, JAVA_OPTS, and other environment variables you need to. 
> 
>>
>> 2) After changing the libs the next error was that DISPLAY wasn't set. After 
>> setting DISPLAY=0.0 in catalina.sh I get "Can't connect to X11 with 
>> DISPLAY=0.0" error. I've tried different values for DISPLAY (e.g. 
>> localhost:0.0) and nothing makes a difference. I've also tried fiddling 
>> around with the policies in case there's a permissions error. See below for 
>> the call stack. 
> 
> Are you running an X server? By that, are I mean is Ubuntu showing up in whatever GUI you've chosen (I guess Gnome 2 is that version's default)? 
> 
> If you only have a command line interface, then there's no place to create the screen. You can play games with a virtual frame buffer, but that will just allow your program to run, but without any screen output (obviously). 
> 
> Again, don't set the DISPLAY environment variable in catalina.sh. Set this in setenv.sh in the bin directory of CATALINA_HOME. There are lots of scenarios here. Three common ones come to mind. 
> 
> 1. Local X server 
> 
> You're at the console and running in a GUI environment. The display environment variable should already be set (typically :0.0). If you start Tomcat with your application in this environment, the GUI interface should just appear. 
> 
> 2. Remote client, accessing the GUI via a VNC server (such as TightVNC) 
> 
> Your display environment should already be set. For example, I'm currently on a remote CentOS 5.8 system via VNC. My DISPLAY environment variable is set to :0.2. If you start Tomcat with your application in this environment, the GUI interface should just appear in the VNC viewer (for example TightVNC). 
> 
> 3. Remote client, X server 
> 
> Note that an X server means your PC is serving the screen, keyboard, and mouse to a remote client (your application). To accomplish this you'll have to have an X server running (if you're on Windows, try XMing), and you'll have to set the DISPLAY variable appropriately. Running Java swing applications in this fashion is not very pleasant especially if your program is graphics-intensive. 
> 
>> The webservice app is a simple RESTEasy implementation. Since this works in 
>> Windows I'm assuming (perhaps erroneously) that this can work in Linux. Any 
>> help would be appreciated. 
>>
>> Thanks, 
>> DG 
>>
>> java . lang . InternalError : Can 't connect to X11 window server using 
>> ' : 0 . 0 ' as the value of the DISPLAY variable. 
>> sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) 
>> sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52) 
>> sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155) 
>> java.security.AccessController.doPrivileged(Native Method) 
>> sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131) 
>> java.lang.Class.forName0(Native Method) 
>> java.lang.Class.forName(Class.java:169) 
>> java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68) 
>>
>> java.awt.Window.init(Window.java:380) 
>> java.awt.Window.<init>(Window.java:433) 
>> java.awt.Frame.<init>(Frame.java:403) 
>> java.awt.Frame.<init>(Frame.java:368) 
>> javax.swing.JFrame.<init>(JFrame.java:158) 
>> com.quinsoft.zeidon.objectbrowser.ObjectBrowser.startup(ObjectBrowser.java:60) 
>>
> 
> 
> This should work just fine if you're running an X server on your Ubuntu system. The DISPLAY environment variable should be :0.0 (no spaces) for a local machine. 
> 
> . . . . just my two cents. 
> /mde/ 
> 
> --------------------------------------------------------------------- 
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org 
> For additional commands, e-mail: users-help@tomcat.apache.org 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


-- 

[key:62590808]


Re: Running Swing app under Tomcat 6 on Linux

Posted by dg...@comcast.net.
Thanks for the response Mark. I've done as you've suggested and moved the env vars to setenv.sh and explicitly set JAVA_HOME. Setting JAVA_HOME means I no longer need to change the -Djava.library.path but I still get the same error (X11 not found). 

I definitely have an X11 server running on the server (which is really my laptop; I'm running all of this locally on my laptop--no remoting). Is it possible that the problem occurs because I am running Tomcat as a daemon? The command I use to start Tomcat is: 

sudo service tomcat6 start 

I've tried running startup.sh directly from the console but it doesn't work.  It looks like /etc/init.d/tomcat6 sets up some env vars before starting Tomcat.  I can try updating my environment so I can run startup.sh if you think it worth attempting.

Thanks,
DG

----- Original Message ----- 
From: "Mark Eggers" <it...@yahoo.com> 
To: "Tomcat Users List" <us...@tomcat.apache.org> 
Sent: Saturday, April 28, 2012 6:50:07 PM 
Subject: Re: Running Swing app under Tomcat 6 on Linux 

Comments and questions are in line. Please note I run Fedora / CentOS / Redhat and I'm not so familiar with Ubuntu. 

----- Original Message ----- 

> From: "dgchristensen@comcast.net" <dg...@comcast.net> 
> To: users@tomcat.apache.org 
> Cc: 
> Sent: Saturday, April 28, 2012 1:11 PM 
> Subject: Running Swing app under Tomcat 6 on Linux 
> 
> My version info: 
> 
> • Tomcat 6.0.28 
> • Java 1.6 
> • Ubuntu 10.4 
> 
> 
> I have a small debugging/monitoring app written in Java/Swing that I'd like 
> to run inside Tomcat to help with debugging. The app is started by 
> dynamically loading the monitoring class from a webservice running under 
> Tomcat. The works in Windows (multiple flavors) but I'm having problems 
> getting this running on Ubuntu. What I've tried so far: 

What does this give you that monitoring the application via JMX (see VisualVM, jconsole), and debugging with your favorite IDE (NetBeans, Eclipse, IntelliJ) doesn't give you? You can actually do both locally as well as remotely (with a little bit of setup). 

> 
> 1) First error I got was an Headless exception. Since the app is a GUI app I 
> can't run in headless mode. After searching around I changed Tomcat's 
> library path (via -Djava.library.path in catalina.sh) to point to the 
> client lib (ie. .../java-6-sun-1.6.0.26/jre/lib/i386/client) instead of the 
> server lib. 

Try setting JRE_HOME in the environment to point to a JRE installation instead. Or use JAVA_HOME and point to the JDK. Tomcat will figure things out. 

If your environment is not set up by default to do that (mine is with custom.sh in /etc/profiles.d), create and use a setenv.sh script in CATALINA_HOME. In this set any CATALINA_OPTS, JAVA_OPTS, and other environment variables you need to. 

> 
> 2) After changing the libs the next error was that DISPLAY wasn't set. After 
> setting DISPLAY=0.0 in catalina.sh I get "Can't connect to X11 with 
> DISPLAY=0.0" error. I've tried different values for DISPLAY (e.g. 
> localhost:0.0) and nothing makes a difference. I've also tried fiddling 
> around with the policies in case there's a permissions error. See below for 
> the call stack. 

Are you running an X server? By that, are I mean is Ubuntu showing up in whatever GUI you've chosen (I guess Gnome 2 is that version's default)? 

If you only have a command line interface, then there's no place to create the screen. You can play games with a virtual frame buffer, but that will just allow your program to run, but without any screen output (obviously). 

Again, don't set the DISPLAY environment variable in catalina.sh. Set this in setenv.sh in the bin directory of CATALINA_HOME. There are lots of scenarios here. Three common ones come to mind. 

1. Local X server 

You're at the console and running in a GUI environment. The display environment variable should already be set (typically :0.0). If you start Tomcat with your application in this environment, the GUI interface should just appear. 

2. Remote client, accessing the GUI via a VNC server (such as TightVNC) 

Your display environment should already be set. For example, I'm currently on a remote CentOS 5.8 system via VNC. My DISPLAY environment variable is set to :0.2. If you start Tomcat with your application in this environment, the GUI interface should just appear in the VNC viewer (for example TightVNC). 

3. Remote client, X server 

Note that an X server means your PC is serving the screen, keyboard, and mouse to a remote client (your application). To accomplish this you'll have to have an X server running (if you're on Windows, try XMing), and you'll have to set the DISPLAY variable appropriately. Running Java swing applications in this fashion is not very pleasant especially if your program is graphics-intensive. 

> The webservice app is a simple RESTEasy implementation. Since this works in 
> Windows I'm assuming (perhaps erroneously) that this can work in Linux. Any 
> help would be appreciated. 
> 
> Thanks, 
> DG 
> 
> java . lang . InternalError : Can 't connect to X11 window server using 
> ' : 0 . 0 ' as the value of the DISPLAY variable. 
> sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) 
> sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52) 
> sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155) 
> java.security.AccessController.doPrivileged(Native Method) 
> sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131) 
> java.lang.Class.forName0(Native Method) 
> java.lang.Class.forName(Class.java:169) 
> java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68) 
> 
> java.awt.Window.init(Window.java:380) 
> java.awt.Window.<init>(Window.java:433) 
> java.awt.Frame.<init>(Frame.java:403) 
> java.awt.Frame.<init>(Frame.java:368) 
> javax.swing.JFrame.<init>(JFrame.java:158) 
> com.quinsoft.zeidon.objectbrowser.ObjectBrowser.startup(ObjectBrowser.java:60) 
> 


This should work just fine if you're running an X server on your Ubuntu system. The DISPLAY environment variable should be :0.0 (no spaces) for a local machine. 

. . . . just my two cents. 
/mde/ 

--------------------------------------------------------------------- 
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org 
For additional commands, e-mail: users-help@tomcat.apache.org 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Running Swing app under Tomcat 6 on Linux

Posted by Mark Eggers <it...@yahoo.com>.
Comments and questions are in line. Please note I run Fedora / CentOS / Redhat and I'm not so familiar with Ubuntu.

----- Original Message -----

> From: "dgchristensen@comcast.net" <dg...@comcast.net>
> To: users@tomcat.apache.org
> Cc: 
> Sent: Saturday, April 28, 2012 1:11 PM
> Subject: Running Swing app under Tomcat 6 on Linux
> 
> My version info: 
> 
>     • Tomcat 6.0.28 
>     • Java 1.6 
>     • Ubuntu 10.4 
> 
> 
> I have a small debugging/monitoring app written in Java/Swing that I'd like 
> to run inside Tomcat to help with debugging. The app is started by
> dynamically  loading the monitoring class from a webservice running under
> Tomcat. The works in Windows (multiple flavors) but I'm having problems
> getting this running on Ubuntu. What I've tried so far: 

What does this give you that monitoring the application via JMX (see VisualVM, jconsole), and debugging with your favorite IDE (NetBeans, Eclipse, IntelliJ) doesn't give you? You can actually do both locally as well as remotely (with a little bit of setup).

> 
> 1) First error I got was an Headless exception. Since the app is a GUI app I 
> can't run in headless mode. After searching around I changed Tomcat's 
> library path (via -Djava.library.path in catalina.sh) to point to the 
> client lib (ie. .../java-6-sun-1.6.0.26/jre/lib/i386/client) instead of the
> server lib. 

Try setting JRE_HOME in the environment to point to a JRE installation instead. Or use JAVA_HOME and point to the JDK. Tomcat will figure things out.

If your environment is not set up by default to do that (mine is with custom.sh in /etc/profiles.d), create and use a setenv.sh script in CATALINA_HOME. In this set any CATALINA_OPTS, JAVA_OPTS, and other environment variables you need to.

> 
> 2) After changing the libs the next error was that DISPLAY wasn't set. After 
> setting DISPLAY=0.0 in catalina.sh I get "Can't connect to X11 with 
> DISPLAY=0.0" error. I've tried different values for DISPLAY (e.g. 
> localhost:0.0) and nothing makes a difference. I've also tried fiddling 
> around with the policies in case there's a permissions error. See below for 
> the call stack. 

Are you running an X server? By that, are I mean is Ubuntu showing up in whatever GUI you've chosen (I guess Gnome 2 is that version's default)?

If you only have a command line interface, then there's no place to create the screen. You can play games with a virtual frame buffer, but that will just allow your program to run, but without any screen output (obviously).

Again, don't set the DISPLAY environment variable in catalina.sh. Set this in setenv.sh in the bin directory of CATALINA_HOME. There are lots of scenarios here. Three common ones come to mind.

1. Local X server

You're at the console and running in a GUI environment. The display environment variable should already be set (typically :0.0). If you start Tomcat with your application in this environment, the GUI interface should just appear.

2. Remote client, accessing the GUI via a VNC server (such as TightVNC)

Your display environment should already be set. For example, I'm currently on a remote CentOS 5.8 system via VNC. My DISPLAY environment variable is set to :0.2. If you start Tomcat with your application in this environment, the GUI interface should just appear in the VNC viewer (for example TightVNC).

3. Remote client, X server

Note that an X server means your PC is serving the screen, keyboard, and mouse to a remote client (your application). To accomplish this you'll have to have an X server running (if you're on Windows, try XMing), and you'll have to set the DISPLAY variable appropriately. Running Java swing applications in this fashion is not very pleasant especially if your program is graphics-intensive.

> The webservice app is a simple RESTEasy implementation. Since this works in 
> Windows I'm assuming (perhaps erroneously) that this can work in Linux. Any 
> help would be appreciated. 
> 
> Thanks, 
> DG 
> 
> java . lang . InternalError : Can 't connect to X11 window server using 
> ' : 0 . 0 ' as the value of the DISPLAY variable. 
> sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) 
> sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:52) 
> sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155) 
> java.security.AccessController.doPrivileged(Native Method) 
> sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131) 
> java.lang.Class.forName0(Native Method) 
> java.lang.Class.forName(Class.java:169) 
> java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68) 
> 
> java.awt.Window.init(Window.java:380) 
> java.awt.Window.<init>(Window.java:433) 
> java.awt.Frame.<init>(Frame.java:403) 
> java.awt.Frame.<init>(Frame.java:368) 
> javax.swing.JFrame.<init>(JFrame.java:158) 
> com.quinsoft.zeidon.objectbrowser.ObjectBrowser.startup(ObjectBrowser.java:60) 
>


This should work just fine if you're running an X server on your Ubuntu system. The DISPLAY environment variable should be :0.0 (no spaces) for a local machine.

. . . . just my two cents.
/mde/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org