TeamCity build failing on custom ant task executed by a maven build

I am trying to setup a new project in TeamCity (v4.5.4), but am running into an issue. The project is Java webapp with a Flex client. It is built via Maven, which in turn uses the flexmojos plugin to build the flex SWF. As part of the flex building process, the Flex SDK creates the HTML wrapper for the Flex component. It apparently uses an ant task to do such. Within the Flex SDK is a "flexTasks.jar" file that contains the custom ant task. The build runs fine via the command line. However, when I run it inside TeamCity, I get the following error:

[09:07:59]: [INFO] [antrun:run {execution: default}]
[09:07:59]: [INFO] Executing tasks
[09:08:00]: [INFO] ------------------------------------------------------------------------
[09:08:00]: [ERROR] BUILD ERROR
[09:08:00]: [INFO] ------------------------------------------------------------------------
[09:08:00]: [INFO] An Ant BuildException has occured: taskdef class flex.ant.HtmlWrapperTask cannot be found
[09:08:00]: [INFO] ------------------------------------------------------------------------
[09:08:00]: [INFO] For more information, run Maven with the -e switch
[09:08:00]: [INFO] ------------------------------------------------------------------------


I have been unsuccessful in finding any discussion of this problem here in the forums or in the TeamCity issue tracker. I have tried to work around the problem by placing the necessary lib in the {user.home}/.ant/lib directory even though this should be unnecessary since the build works fine via command line. Regardless, that attempted workaround did not solve the issue.

At this point I am at a lost as to what to do next and am looking for assistance before opening a bug report. Below is a stack trace obtained via adding the -e switch to the maven runner definition in TeamCity.


[09:35:35]: [INFO] An Ant BuildException has occured: taskdef class flex.ant.HtmlWrapperTask cannot be found
[09:35:35]: [INFO] Trace
[09:35:35]: org.apache.maven.lifecycle.LifecycleExecutionException: An Ant BuildException has occured: taskdef class flex.ant.HtmlWrapperTask cannot be found
[09:35:35]: at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:703)
[09:35:35]: at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:540)
[09:35:35]: at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:519)
[09:35:35]: at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
[09:35:35]: at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
[09:35:35]: at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
[09:35:35]: at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
[09:35:35]: at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
[09:35:35]: at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
[09:35:35]: at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:41)
[09:35:35]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[09:35:35]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[09:35:35]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[09:35:35]: at java.lang.reflect.Method.invoke(Method.java:597)
[09:35:35]: at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
[09:35:35]: at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
[09:35:35]: at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
[09:35:35]: at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[09:35:35]: Caused by: org.apache.maven.plugin.MojoExecutionException: An Ant BuildException has occured: taskdef class flex.ant.HtmlWrapperTask cannot be found
[09:35:35]: at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:131)
[09:35:35]: at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:98)
[09:35:35]: at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
[09:35:35]: at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
[09:35:35]: ... 17 more
[09:35:35]: Caused by: taskdef class flex.ant.HtmlWrapperTask cannot be found
[09:35:35]: at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:609)
[09:35:35]: at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:228)
[09:35:35]: at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[09:35:35]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[09:35:35]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[09:35:35]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[09:35:35]: at java.lang.reflect.Method.invoke(Method.java:597)
[09:35:35]: at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[09:35:35]: at org.apache.tools.ant.Task.perform(Task.java:348)
[09:35:35]: at org.apache.tools.ant.Target.execute(Target.java:357)
[09:35:35]: at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:118)
[09:35:35]: ... 20 more
[09:35:35]: Caused by: java.lang.ClassNotFoundException: flex.ant.HtmlWrapperTask
[09:35:35]: at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1400)
[09:35:35]: at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1341)
[09:35:35]: at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1088)
[09:35:35]: at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
[09:35:35]: at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
[09:35:35]: at java.lang.Class.forName0(Native Method)
[09:35:35]: at java.lang.Class.forName(Class.java:247)
[09:35:35]: at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:583)
[09:35:35]: ... 30 more
4 comments
Comment actions Permalink

Hello, Mark

There were a couple of threads with similar symptoms:
http://www.jetbrains.net/devnet/message/5241875
http://www.jetbrains.net/devnet/message/5232279

Could these be related to your problem?

0
Comment actions Permalink

Thanks Sergey. The first one looks similar to the issue I was having. I actually got it working. The unfortunate part, is I am not sure how. While I am of course happy to have it working, I hate not knowing what the issue was. I went to try another possible workaround. But I got to thinking that I had not been bouncing the TeamCity server or agent when making my changes. Oops. So I did that with this workaround attempt. And the build started working. However, when I undid that workaround to verify that it was the fix, I did not reproduce the issue.  I undid my two other changes, to try and find the one that fixed it, bouncing the agent and server between changes. But I was still unable to reproduce the problem.So I'm up and running. I simply don't know what was causing the problem.

0
Comment actions Permalink

Don't you think this could be a user account related issue?
Are you sure when your build failed you were running the agent under the same user as you run the build manually?

0
Comment actions Permalink

I have exactly the same problem here. My agents run as user "teamcity" and are not able to execute my external ant tasks, but "su - teamcity" is. I used the commandline found in the agent's log.

0

Please sign in to leave a comment.