此代码在开发模式下运行良好,但在gwt编译时失败并出现异常。我不知道为什么。 MechanicCategory类在路径上,与eclipse编译得很好,并且所有在dev模式下运行良好但是gwt编译失败......: - /任何想法?
public interface Entity<K> {
public K getId();
public void setId(K value);
}
public interface Mechanic extends Entity<Integer> {
List<UsualBase> getUsualBases();
boolean performCalculation(Date date);
}
@Category(MechanicCategory.class)
public interface BeanFactory extends AutoBeanFactory {
BeanFactory INSTANCE = GWT.create(BeanFactory.class);
AutoBean<Mechanic> mechanic();
}
public class MechanicCategory {
public static boolean performCalculation(AutoBean<Mechanic> instance, Date date) {
return false;
}
}
[java] Compiling module es.company.product.loader.Loader
[java] Resolving es.company.product.commons.client.beans.BeanFactory
[java] Found type 'es.company.product.commons.client.beans.BeanFactory'
[java] [ERROR] Annotation error: cannot resolve es.company.product.commons.client.beans.categories.MechanicCategory
[java] java.lang.ClassNotFoundException: es.company.product.commons.client.beans.categories.MechanicCategory
[java] at java.net.URLClassLoader$1.run(Unknown Source)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(Unknown Source)
[java] at java.lang.ClassLoader.loadClass(Unknown Source)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
[java] at java.lang.ClassLoader.loadClass(Unknown Source)
[java] at java.lang.Class.forName0(Native Method)
[java] at java.lang.Class.forName(Unknown Source)
[java] at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotationValue(TypeOracleMediator.java:750)
[java] at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotationValue(TypeOracleMediator.java:689)
[java] at com.google.gwt.dev.javac.TypeOracleMediator.createAnnotation(TypeOracleMediator.java:498)
[java] at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotation(TypeOracleMediator.java:648)
[java] at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotations(TypeOracleMediator.java:663)
[java] at com.google.gwt.dev.javac.TypeOracleMediator.resolveClass(TypeOracleMediator.java:809)
[java] at com.google.gwt.dev.javac.TypeOracleMediator.addNewTypes(TypeOracleMediator.java:439)
[java] at com.google.gwt.dev.javac.TypeOracleMediatorFromSource.addNewUnits(TypeOracleMediatorFromSource.java:52)
[java] at com.google.gwt.dev.javac.CompilationState.assimilateUnits(CompilationState.java:164)
[java] at com.google.gwt.dev.javac.CompilationState.<init>(CompilationState.java:82)
[java] at com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:450)
[java] at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:370)
[java] at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:360)
[java] at com.google.gwt.dev.Precompile.precompile(Precompile.java:252)
[java] at com.google.gwt.dev.Precompile.precompile(Precompile.java:233)
[java] at com.google.gwt.dev.Precompile.precompile(Precompile.java:145)
[java] at com.google.gwt.dev.Compiler.run(Compiler.java:232)
[java] at com.google.gwt.dev.Compiler.run(Compiler.java:198)
[java] at com.google.gwt.dev.Compiler$1.run(Compiler.java:170)
[java] at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)
[java] at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)
[java] at com.google.gwt.dev.Compiler.main(Compiler.java:177)
[java] [ERROR] Annotation error: expected class java.lang.Class, got null
答案 0 :(得分:2)
解决!当gwt编译时,war/WEB-INF/classes
必须在类路径上。
编辑:我的意思是你需要在你的类路径中使用.class字节码文件,所以你需要在用gwt编译它之前对它进行javac