permaculture playing cards*
The moose likes Ant, Maven and Other Build Tools and the fly likes ANT - and was unexpected at this time. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "ANT - and was unexpected at this time." Watch "ANT - and was unexpected at this time." New topic
Author

ANT - and was unexpected at this time.

saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
hello everyone,

i am not an experienced person using ant, but have done a few projects using ant to build.
Upto my knowledge ant must be either provided the specific target in our build.xml or run the ant directly in build.xml without any argument.

But now I am facing a peculiar error which i get when i run ant
and was unexpected at this time

i am stuck why would such a message come around?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Have you run ANT with the -x flag? Should give you further info.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
what ever the option i pass it gives me the same error
and was unexpected at this time

and more over it is the same even in the location where buil.xml is not present.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

What command are you using? Have you checked in an XML editor that your build.xml is valid?
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
my build files are valid because the ant integrated into IDE is working fine for this build files.
I am facing the error when i am running from a command prompt.

Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Interesting, can you post the command you are using to run the build?
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
@Martijn Verburg
so did you go through the changes i have made to my previous post, i have added a snapshot of the error screen.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hmm, haven't seen that before, is your ANT_HOME and JAVA_HOME set correctly? Also does your build.xml file have a default target?
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
yes ofcourse earlier i have sucessfully build my application in the same way & now i am facing this error without changing anything to my path variables.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

Please post you build script. As far as I can tell from the error the term 'and' is appearing in an unusual location. Also, post the full command line you entered and all of the output that was generated (copy and past the whole thing from the command line to the forum).


JBoss In Action
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
this is what i get, what else you want me to give.

in case if the above image does not work.

C:\Documents and Settings\Stubati>dir build.xml
Volume in drive C has no label.
Volume Serial Number is E410-81E4

Directory of C:\Documents and Settings\Stubati

03/08/2010 05:36 PM 4,336 build.xml
1 File(s) 4,336 bytes
0 Dir(s) 16,883,073,024 bytes free

C:\Documents and Settings\Stubati>ant
and was unexpected at this time.

C:\Documents and Settings\Stubati>
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3833

Can you post your default task in the build.xml here?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
what ever the build file i use or which ever the target i give to the command ant, it is just throwing the message
and was unexpected at this time.


actually i am able to run the file properly through my IDE, but when i do it directly in a command prompt i am facing the error.
I tried even to remove the existing ant binaries and downloaded the new ones but still i am getting the same.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3833

What you get when you type "ant -version" from your shell?
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
same message.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3833

You better first check your Ant installation, looks like an issue with the shell interpreter. Check the PATH, ANT_HOME, JAVA_HOME environment variables again. Post the content of those here.
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159


If there is any problem with them then the ant should state some error like windows stating that ant is not recognized as internal or external command.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3833

What about PATH? And have you try running "ant -version" from the bin directory of ANT_HOME (assuming your installation is correct)?
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
Vijitha Kumara wrote:And have you try running "ant -version" from the bin directory of ANT_HOME (assuming your installation is correct)?

yes i have done that as well but no luck.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3833

yes i have done that as well but no luck.

What's the error you got, same as before ? Just to make sure, What you get when you type "java -version" in the shell? And what's the directory structure inside the ANT_HOME?

If this doesn't work either, best thing would be to start fresh, get the latest Ant installed (follow the instruction accordingly, to make sure you haven't missed any) and try from there...
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
here are the different versions i get for java , ant, maven

C:\Documents and Settings\Stubati>java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)

C:\Documents and Settings\Stubati>ant -version
and was unexpected at this time.

C:\Documents and Settings\Stubati>mvn -version
Apache Maven 3.0 (r1004208; 2010-10-04 17:20:56+0530)
Java version: 1.6.0_17
Java home: C:\Program Files\Java\jdk1.6.0_17\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
Vijitha Kumara wrote: If this doesn't work either, best thing would be to start fresh, get the latest Ant installed

I posted here about the issue only after i make sure that i made a new installation by downloading the latest binaries.
this is my ant folder structure.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7


Ant is run via a batch file named ant.bat. Apparently someone edited that file and screwed it up. Either fix it, or reinstall ant. Another possibility is env var settings - if any JAVA_HOME has quotes then that could cause issues. The best way to find out the exact issue is edit ant.bat and comment out the "@echo off" at the start of the file, then when you run ant it will echo all of the command in ant.bat until it hits the place where it was messed up.
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
@ Peter Johnson
What a great point
Peter Johnson wrote: The best way to find out the exact issue is edit ant.bat and comment out the "@echo off"

It did helped me where i made the mistake, it was the variable CLASSPATH which contains "" and that's where it messed up the whole thing.
ThankQ
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

Never set the CLASSPATH env var, it will only lead to problems!
 
GeeCON Prague 2014
 
subject: ANT - and was unexpected at this time.