Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Stuck Building Cocoa Wrapper for Tomcat

Stuck Building Cocoa Wrapper for Tomcat
Thread Tools
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
May 16, 2003, 11:34 AM
 
There are several Java based Tomcat wrappers out there but I'm interested in building one in Cocoa. I started yesterday (went to bed pretty late) and so far I can read the Tomcat log files but I'm unable to start Tomcat -dough!

I need to set environment variables but how does one do this from Cocoa since NSTask is not binded to a specific shell. This means that I don't know if sentenv or export is the way to go. For the moment being neither of these is working.

Here's a snipplet:

// -----------------------------------
// this doesn't work
// -----------------------------------

commandStart =[[TaskWrapper alloc] initWithController:self arguments:[NSArray arrayWithObjects:@"/bin/sh", @"/Users/bido/Dev/bin/start_tomcat", nil]];
[commandStart startProcess];

// -----------------------------------
// this works as expected
// -----------------------------------

command=[[TaskWrapper alloc] initWithController:self arguments:[NSArray arrayWithObjects:@"/usr/bin/tail",@"-f",@"/usr/local/jakarta-tomcat-4.1.24/logs/catalina.out",nil]];
[command startProcess];

// -----------------------------------

I borrowed TaskWrapper(which returns an NSString and makes asynchronous system calls) from somewhere on the web and it works as expected.

Any ideas on how to set environment variables? I need to set JAVA_HOME and the CATALINA_HOME variables before starting Tomcat.

I realize that the above snipplet is not much to go on. But apart from TaskWrapper, the rest of the code is very common place and straightforward.

Thanks!

     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
May 16, 2003, 12:20 PM
 
Why not embed the shell in the task? To start tomcat, do something like this:

Code:
/bin/sh -c "cd `dirname $0`/tomcat/bin/ && ./startup.sh"
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
DaGuy  (op)
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
May 16, 2003, 02:44 PM
 
Originally posted by Arkham_c:
Why not embed the shell in the task? To start tomcat, do something like this:

Code:
/bin/sh -c "cd `dirname $0`/tomcat/bin/ && ./startup.sh"
Thanks. However, I'm not sure if I understand the above clearly enough.

You are passing ./starup as the $0 argument to the cd command but it somehow doesn't need to be passed the directory name?



Also the -c option is not available, did you mean -C which is noclobber?

I messed various permutations on the terminal and didn't get to work. When I get it to work, I'll move it to the code.

Best,



     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:33 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2