• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Opening .bat files from ant

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Did anyone manage to open .bat files from ant? I'm trying to open the tomcat console through ant tasks.
I'm doing this:


I also tried this with no success:



The error is:

start-tomcat:
[exec] The CATALINA_HOME environment variable is not defined correctly
[exec] This environment variable is needed to run this program

This is a little strange though since TOMCAT_HOME is defined correctly (i also set another env var CATALINA_HOME, no luck).
I have no problem opening tomcat6.exe though, even if it doesn't show the window, but the process is there when i open windows task manager.

Can anyone help? Thanks.

Edit: i'm using jdk 1.6, tomcat 6 and ant 1.7 from eclipse ganymede, but it doesn't work when i run the task outside of eclipse either.
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where are you defining CATALINA_HOME?
 
Nick Potter
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in environment variables.
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK,

That's one theory down, next thing: Can you echo the values of the various environment variables before the start.bat is called?
 
Nick Potter
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, also deploying the application works just fine... no problems till i want to start the tomcat console. I read somewhere that there's a problem opening the .bat files with latest versions of ant. On another machine i have tomcat 4 and ant 1.0 (i think) and i have no problem.
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm, not sure in that case, I did find an alternative for you here
 
Saloon Keeper
Posts: 27817
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just for a slightly different angle of attack: Tomcat is a Java program. That means that Ant can bypass the whole script-thingy stuff and launch it directly.

In fact, since Tomcat is embeddable, you could even create an Ant task to do the whole thing - probably someone's already done so.
 
Nick Potter
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With <exec executable="{tomcat.home}/bin/startup.bat" spawn="true"> it doesn't open it.
With <exec executable="{tomcat.home}/bin/tomcat6.exe" spawn="true"> it works.

I want it to open the tomcat console, but it doesn't. With tomcat 4, jdk 1.4, ant 1.0 this works : <exec executable="{tomcat.home}/bin/startup.bat" spawn="true">
With tomcat6, jdk1.6, 1.7 it doesn't.
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nick,

I know this is a bit of a hassle, but are you able to drop the Ant version to 1.6 and try that? I'm curious to see if it's the exec task of 1.7 that's mucking things up (I've googled and couldn't find anything however).
 
Tim Holloway
Saloon Keeper
Posts: 27817
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what "Tomcat console" means here. The tomcat admin webapps aren't part of the base tomcat download anymore - they have to be downloaded separately. But they wouldn't open automatically, since they're webapps and therefore only respond to web requests.

If you mean a DOS-style command window, you'd have to open a new command window and have IT run tomcat. I forget the details.

One possible reason why this happened automatically before and doesn't now might be that the older version was dumping output to stdout and that forced a console window to open to display it. Not all Tomcat configurations write to stdout. Tomcat itself doesn't, and well-written webapps don't either, since there's no universal rule on where System.out/err.print's will go (if anywhere). That's why logging is preferable. In Tomcat, system.out prints generally go to logs/catalina.out, though I forget if a localhost or app-specific log might get them instead.
 
Nick Potter
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By tomcat console i mean the dos-style command window. I also tried to open the command window (cmd.exe) and have it run tomcat . I'm using stdout in log4j configuration to have it print my sysout's in tomcat console. I'll have to trt using ant 1.6 just to see if this is an ant version problem.
 
Nick Potter
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, i managed to get it done.
Strange enough (to me at least) this piece of code doesn't work although i set the tomcat.home variable correctly in the build.properties file:


But this one does work:


Maybe someone's got an explanation?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic