When I try to build a project that uses Flex and where the Flex SDK is on one drive and the project files on another I get the following error in ant:
[mxmlc] java.lang.NoClassDefFoundError: flex2/tools/Compiler
[mxmlc] Exception in thread "main"
It seems to be a problem with the Flex mxmlc ant task. Anyone know the root cause of this? It works if I move the Flex SDK over to the project folder but I don't like being hackish like that...
Ant in verbose mode gives:
compile.main:
dropping E:\c from path as it doesn't exist
dropping E:\programs\flex-sdk\lib\mxmlc.jar from path as it doesn't exist
[mxmlc] java.lang.NoClassDefFoundError: flex2/tools/Compiler
[mxmlc] Exception in thread "main"
[antcall] Exiting E:\svn\trunk\dev\modules\web\webapps\lpjserver\lpjserver-build.xml.
BUILD FAILED
E:\svn\trunk\dev\modules\web\webapps\lpjserver\lpjserver-build.xml:379: The following error occurred while executing this line:
E:\svn\trunk\dev\modules\web\webapps\lpjserver\lpjserver-build.xml:199: mxmlc task failed.
at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:508)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:418)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.inv开发者_如何学Gooke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.Main.runBuild(Main.java:758)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: E:\svn\trunk\dev\modules\web\webapps\lpjserver\lpjserver-build.xml:199: mxmlc task failed.
at flex.ant.FlexTask.executeOutOfProcess(FlexTask.java:253)
at flex.ant.FlexTask.execute(FlexTask.java:223)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
... 17 more
--- Nested Exception ---
E:\svn\trunk\dev\modules\web\webapps\lpjserver\lpjserver-build.xml:199: mxmlc task failed.
at flex.ant.FlexTask.executeOutOfProcess(FlexTask.java:253)
at flex.ant.FlexTask.execute(FlexTask.java:223)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.Main.runBuild(Main.java:758)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Did you put flexTasks.jar
into lib
folder of your ant installation?
In my case I've copied D:\Flex_sdk_3.3.0\ant\lib\flexTasks.jar
into D:\apache-ant-1.7.1\lib\
I determined that this is actually a bug in the flex ant task. FlexTask.java is not doing proper pathing to work across multiple drives on a windows machine.
Somewhere there is a path that doesn't have the drive letter on the front of it. So it works when you're on the 'correct' drive, but not otherwise.
I found this blog posting - search for MXMLC=
in the text - someone found a solution for a Mac install that threw the same exception. You may be able to adapt this to you situation. (It looks like maybe when the flex mxmlc compiler is installed and configured it doesn't necessarily include the drive letter everywhere its needed.)
Rather than moving or copying the jar, perhaps you can add the full path to it with drive letter as a property in your build, then append that to the classpath.
Copy Flex sdk/x.x folder to the same drive as your sources, adjust flex.sdk.home ant variable and rebuild.
精彩评论