gpt4 book ai didi

java - Ant gwtcompile ClassNotFoundException

转载 作者:太空宇宙 更新时间:2023-11-04 08:21:34 25 4
gpt4 key购买 nike

我已经使用 ant 设置了以下任务来编译我的 gwt 项目。

    <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)

论坛说这是因为类路径中的 dev 版本较旧。

现在我被困住了,不知道该去哪里。请指教。

谢谢。

最佳答案

IMO 没有任何理由使用这个(过时的)ant 任务(它仅适用于 GWT 1.4、1.5 和 1.6)。只需使用 java 任务来调用 com.google.gwt.dev.Compiler 类即可。

以下内容的灵感来自 GWT 的 WebAppCreator 生成的 Ant 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>

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

关于java - Ant gwtcompile ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9440483/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com