Comment inline.

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

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

> From: "dgchristen...@comcast.net" <dgchristen...@comcast.net>
> To: Tomcat Users List <users@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" <p...@pidster.com>
> To: "Tomcat Users List" <users@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, dgchristen...@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" <its_toas...@yahoo.com> 
>>  To: "Tomcat Users List" <users@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: "dgchristen...@comcast.net" 
> <dgchristen...@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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to