2012-02-25 58 views
1

我用ant建立了以下任務來編譯我的gwt項目。Ant gwtcompile ClassNotFoundException

<taskdef resource="dk/contix/ant/gwt/ant-gwt.xml" classpathref="gwt.classpath" /> 
    <gwtcompile destdir="${www.dir}" optimize="true" version="1.6"> 
     <fileset dir="${src.dir}"> 
     <include name="**/*.gwt.xml"/> 
     </fileset> 
    </gwtcompile> 

我得到這個錯誤:

[gwtcompile] [ERROR] Unexpected internal compiler error 
[gwtcompile] java.lang.NoClassDefFoundError: com/google/gwt/dev/shell/PlatformSpecific 
[gwtcompile] at dk.contix.ant.gwt.GWT16Compile$1.run(GWT16Compile.java:40) 
[gwtcompile] at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88) 
[gwtcompile] at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82) 
[gwtcompile] at dk.contix.ant.gwt.GWT16Compile.execute(GWT16Compile.java:50) 
[gwtcompile] at dk.contix.ant.gwt.GWTCompileTask.execute(GWTCompileTask.java:136) 
[gwtcompile] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) 
[gwtcompile] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) 
[gwtcompile] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
[gwtcompile] at java.lang.reflect.Method.invoke(Method.java:601) 
[gwtcompile] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) 
[gwtcompile] at org.apache.tools.ant.Task.perform(Task.java:348) 
[gwtcompile] at org.apache.tools.ant.Target.execute(Target.java:390) 
[gwtcompile] at org.apache.tools.ant.Target.performTasks(Target.java:411) 
[gwtcompile] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399) 
[gwtcompile] at org.apache.tools.ant.Project.executeTarget(Project.java:1368) 
[gwtcompile] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) 
[gwtcompile] at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) 
[gwtcompile] at org.apache.tools.ant.Project.executeTargets(Project.java:1251) 
[gwtcompile] at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424) 
[gwtcompile] at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138) 
[gwtcompile] Caused by: java.lang.ClassNotFoundException: com.google.gwt.dev.shell.PlatformSpecific 
[gwtcompile] at java.net.URLClassLoader$1.run(URLClassLoader.java:366) 
[gwtcompile] at java.net.URLClassLoader$1.run(URLClassLoader.java:355) 
[gwtcompile] at java.security.AccessController.doPrivileged(Native Method) 
[gwtcompile] at java.net.URLClassLoader.findClass(URLClassLoader.java:354) 
[gwtcompile] at java.lang.ClassLoader.loadClass(ClassLoader.java:423) 
[gwtcompile] at java.lang.ClassLoader.loadClass(ClassLoader.java:356) 
[gwtcompile] ... 20 more 

所以,用了大量的研究,我終於找到了一個老GWT-DEV-linux.jar文件。當我加入這個到類路徑中,我得到:

[gwtcompile] Comiling modules [com.heavyweightsoftware.leal.ui.ImageViewer] 
[gwtcompile] Comiling modules [com.heavyweightsoftware.leal.ui.ImageViewer] 
[gwtcompile] Loading module 'com.heavyweightsoftware.leal.ui.ImageViewer' 
[gwtcompile] Loading inherited module 'com.google.gwt.user.User' 
[gwtcompile]  Loading inherited module 'com.google.gwt.animation.Animation' 
[gwtcompile]   Loading inherited module 'com.google.gwt.core.Core' 
[gwtcompile]    Loading inherited module 'com.google.gwt.core.CompilerParameters' 
[gwtcompile]    [ERROR] Line 23: Unexpected element 'define-configuration-property' 
[gwtcompile]    [ERROR] Failure while parsing XML 
[gwtcompile] com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries) 

哪個論壇說的是,因爲在類路徑中的舊版本開發的。

現在我卡住了,不知道該去哪裏。請指教。

謝謝。

回答

1

IMO沒有任何理由使用這個(過時的)ant任務(它只適用於GWT 1.4,1.5和1.6)。只需使用java任務即可致電com.google.gwt.dev.Compiler類。

以下是由GWT的WebAppCreator產生的螞蟻build.xml文件啓發:

<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler" 
    classpathref="gwt.classpath"> 
    <!-- add jvmarg -Xss16M or similar if you see a StackOverflowError --> 
    <jvmarg value="-Xmx256M"/> 
    <arg line="-war"/> 
    <arg value="${www.dir}"/> 
    <!-- Additional arguments like -style PRETTY or -logLevel DEBUG --> 
    <arg value="com.heavyweightsoftware.leal.ui.ImageViewer"/> 
</java> 

WebAppCreator使用的模板見http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/user/tools/templates/ant/build.xmlsrc

0

關於Java很酷的事情是,如果您遇到問題,你可以總是試圖尋找源代碼

在這裏,您可以檢查代碼GWT16Compile:http://code.google.com/p/ant-gwt/source/browse/trunk/src/dk/contix/ant/gwt/GWT16Compile.java?r=12

各地的40行,它說:

if (config.isOptimize()) { 
    updater = PlatformSpecific.checkForUpdatesInBackgroundThread(logger, CheckForUpdates.ONE_DAY); 
} 

也許你可以嘗試在你的ant build config中設置optimize爲false,看看它是否可以工作。

相關問題