Harshal,

"Error=2" from Windows means "file not found". You can find the full set of all of the Windows error codes at http://msdn.microsoft.com/library/?url=/library/en-us/debug/base/system_error_codes.asp?frame=true.

You have either misspelled the name of the file or, more likely, you have failed to specify the correct path to the file. Double-check the spelling of both the "dir" and "executable" parameters to see if they are exactly correct.

I see that your "dir" parameter is missing the drive letter, colon, backslash and maybe a directory level or two before 'tomcat4.1'; if you put the rest of the path there, you may find that your exec task works fine.

Then again, maybe not. I just tried starting Tomcat on my computer via an Ant task that was written the same way as yours, only I put the full path in the 'dir' parameter; it didn't work and I got "error=2", just like you. So, if fixing the parameters along the lines I suggested don't work, choose one of the following two approaches:


[Approach 1]


<property name="tomcat.path" value="D:\jakarta-tomcat-4.1.24\bin" description="The path to the startup script."/>

<property name="start" value="startup.bat" description="The name of the startup script."/>

<target name="start_tomcat" description="Start Tomcat.">

<exec executable="${tomcat.path}\${start}" os="Windows XP" failonerror="true" description="Starting Tomcat."/>

</target>



[Approach 2]

<property name="tomcat" value="D:\jakarta-tomcat-4.1.24\bin\startup.bat" description="The path to the startup script."/>

<target name="start_tomcat" description="Start Tomcat.">

<echo message="Starting Tomcat...."/>

<exec executable="${tomcat}" os="Windows XP" failonerror="true" description="Starting Tomcat."/>

</target>



One of those two approaches should work for you. There may be other approaches that will work too.

--
Rhino

----- Original Message ----- From: "Harshal Chavda" <[EMAIL PROTECTED]>
To: <user@ant.apache.org>
Sent: Sunday, February 05, 2006 2:10 PM
Subject: problem with exec task



HI to all fellow users,
My configuration is jdk(1.3.1),Ant(1.6.3),tomcat(4.1)
on a windows XP.I want to start the tomcat server(startup.bat).So I
used the "exec" task.BUt I get an error which is follows :

====================================================================
prac.xml:82: Execute failed: java.io.IOException: CreateProcess:
startup.bat error=2 at
at
====================================================================
org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:620)
at
org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:452)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at
org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExec
utor.java:40)
at
org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
--- Nested Exception ---
java.io.IOException: CreateProcess: startup.bat error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:61)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:546)
at java.lang.reflect.Method.invoke(Native Method)
at
org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execu
te.java:834)
at
org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:435)
at
org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:449)
at
org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:576)
at
org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:617)
at
org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:452)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at
org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExec
utor.java:40)
at
org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)

=====================================================================
The line 82 is-->
<exec dir="tomcat 4.1\bin" executable="startup.bat"/>.

Can anyone please tell me how to find a solution for this Exception as

I can only write very simple java programs and as such my knowledge of

JAVA is limited.

Thanks Harshal


--------------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.2/251 - Release Date: 04/02/2006



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.2/251 - Release Date: 04/02/2006


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to