File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes 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 ""Could not create task of type: echo"" Watch ""Could not create task of type: echo"" New topic
Author

"Could not create task of type: echo"

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30502
    
150

I'm trying to use the Timer task in my Ant script. If I comment out the timer task, it runs properly and displays Hello World. Is there something I need to do in the classpath to append it to my current one?

When I run it, I get:
Buildfile: <workspace>\Play\play.xml

test:
[timer] System reports java version 1.3.1
[timer] Using standard timer resolution
[timer] started
[timer] BUILD FAILED: <workspace>\Play\play.xml:16: Could not create task of type: echo
Total time: 265 milliseconds


My build file:


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30502
    
150

I went into the source code and added some logging. In the addTask(Task) method, I logged the type of the task:
org.apache.tools.ant.UnknownElement@9670967

and a stack trace to see where it was in the call hierarchy:
[timer] java.lang.Exception
[timer] at java.lang.Throwable.<init>(Throwable.java)
[timer] at de.jeckle.AntExtension.Timer.addTask(Timer.java:98)
[timer] at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:329)
[timer] at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:176)
[timer] at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:152)
[timer] at org.apache.tools.ant.Task.perform(Task.java:363)
[timer] at org.apache.tools.ant.Target.execute(Target.java:301)
[timer] at org.apache.tools.ant.Target.performTasks(Target.java:328)
[timer] at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
[timer] at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:571)
[timer] at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:367)
[timer] at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:199)
[timer] at java.lang.reflect.Method.invoke(Method.java)
[timer] at org.eclipse.ant.core.AntRunner.run(AntRunner.java:335)
[timer] at org.eclipse.ui.externaltools.internal.ant.launchConfigurations.AntLaunchDelegate$1.run(AntLaunchDelegate.java:172)
[timer] at java.lang.Thread.run(Thread.java:801)
[timer] adding task:
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30502
    
150

I've explored a bit more and it looks like a classpath issue. But how could Ant not be in the classpath of Ant? Where are you supposed to set it?
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
I've never set up my classpath the way you've done it. What I do is set the classpath outside build.xml (unless the task such as javac has a classpath attribute) and then run the target. If you place att.jar on the classpath this way and it still fails, then I'm baffled.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30502
    
150

Roger,
I was trying to run it from within Eclipse to facilitate testing and didn't want to mess with the classpath. I'll give your approach a try. The real build isn't running in Eclipse anyway.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
You can set up a configuration in eclipse and then place the JAR file on the classpath. I've often run Ant scripts like this.
Michael Duffy
Ranch Hand

Joined: Oct 15, 2005
Posts: 163
Originally posted by Jeanne Boyarsky:
I'm trying to use the Timer task in my Ant script. If I comment out the timer task, it runs properly and displays Hello World. Is there something I need to do in the classpath to append it to my current one?

When I run it, I get:



Look at the Ant task docs again. It's not <echo>Hello World</echo>; it should be <echo message="Hello World"/> if you're using the Ant echo task.


%
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30502
    
150

Michael,
When I run the same build script without the timer task, it works fine. So Ant is allowing <echo>Message</echo>
Michael Duffy
Ranch Hand

Joined: Oct 15, 2005
Posts: 163
Originally posted by Jeanne Boyarsky:
Michael,
When I run the same build script without the timer task, it works fine. So Ant is allowing <echo>Message</echo>


When I didn't see the <timer> task in my Ant 1.6.5 docs, I asked Google to look for it. It found this site:

http://www.jeckle.de/freeStuff/AntTimerTask/

Maybe the latest news they refer to apply.
Ryan Zezeski
Greenhorn

Joined: Mar 13, 2005
Posts: 29
[/qb]<hr></blockquote>

is "<workspace>" the actual name of your directory? That is confusing me.

Otherwise, does ant append or insert to the CLASSPATH? If it appens maybe your CLASSPATH is malformed?

EDIT: Just remembered you cannot even create a dir with the <,> characters in windows and i'm pretty sure you can't on UNIX/Linux either. This would tell me that you are using <workspace> to reference a property or something? If so it should be ${workspace}.
[ February 04, 2006: Message edited by: Ryan Zezeski ]

Java has 99 problems but a pointer ain't one
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30502
    
150

Michael,
I didn't see that before. It could well be the problem they are alluding to. I'll try downloading a different task to see if it is my environment or the Timer task.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30502
    
150

Originally posted by Ryan Zezeski:
[CODE]is "<workspace>" the actual name of your directory? That is confusing me.

No. Pretend I have the full path to the directory there. I edited it out before posting because I didn't want any non-public information on the web.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30502
    
150

Got it! You need to put the following at the beginnng of the addTask method. Luckily this task is open source. I made the change, re-jar'd it up and it worked. It seems this is a classloader problem.



Source of solution:
http://lists.canoo.com/pipermail/webtest/2004q1/001389.html
[ February 07, 2006: Message edited by: Jeanne Boyarsky ]
Unnsse Khan
Ranch Hand

Joined: Nov 12, 2001
Posts: 511
Jeanne & Michael,

How did you successfully place the "<" and ">" insider your posting's UBB [ CODE ]?

I have tried everything and it still gives me this:

"Sorry, your post appears to have an illegal HTML tag. Often this is because the post contains a "<" character instead of the equivalent HTML escape sequence "& lt;"

You can fix this by replacing every < in your post with "& lt;" (without the internal space). Sometimes the problem is that you're using a specific method name which our system thinks is part of an attempt to insert some evil JavaScript exploit into our pages. The most common is "get Cookie()" - just replace this phrase with something else like getKookie(). Sorry for the inconvenience; this is the best we can do for now. It's all Mapraputa's fault.

The specific error message is: ONERROR

� Please use your browser's back button to return. "


Many, many thanks!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30502
    
150

Unnsse,
I escaped it using HTML escape sequences. So &lt; = < and &gt; = > For just a few special characters, I do it by hand. For a lot, I use Eric's tool at the top of the HTML forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "Could not create task of type: echo"