gwt编译期间的GWT验证错误 - 没有可用的源代码

时间:2012-09-12 10:07:22

标签: validation gwt hibernate-validator

我正在尝试使用hibernate验证器进行gwt验证。我已按照http://code.google.com/p/google-web-toolkit/wiki/BeanValidation中的步骤操作,并根据http://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/validation/

上的示例验证项目配置了我的项目

我的.gwt.xml文件包含:

<inherits name="org.hibernate.validator.HibernateValidator" />

和我的自定义验证工厂:

<replace-with class="my.package.here.client.validation.ValidatorFactory">
<when-type-is class="javax.validation.ValidatorFactory" />
</replace-with>     

验证在开发模式下在客户端和服务器端都很完美,但在尝试gwt编译时,我得到:

gwtc-production:
     [java] Compiling module my.package.MyModule
     [java]    Validating newly compiled units
     [java]       [ERROR] Errors in 'jar:file:/hibernate-validator-4.2.0.Final-sources.jar!/org/hibernate/validator/constraints/impl/FutureValidatorForReadableInstant.java'
     [java]          [ERROR] Line 32: No source code is available for type org.joda.time.ReadableInstant; did you forget to inherit a required module?
     [java]       [ERROR] Errors in 'jar:file:/hibernate-validator-4.2.0.Final-sources.jar!/org/hibernate/validator/constraints/impl/FutureValidatorForReadablePartial.java'
     [java]          [ERROR] Line 32: No source code is available for type org.joda.time.ReadablePartial; did you forget to inherit a required module?
     [java]       [ERROR] Errors in 'jar:file:/hibernate-validator-4.2.0.Final-sources.jar!/org/hibernate/validator/constraints/impl/PastValidatorForReadableInstant.java'
     [java]       [ERROR] Errors in 'jar:file:/hibernate-validator-4.2.0.Final-sources.jar!/org/hibernate/validator/constraints/impl/SafeHtmlValidator.java'
     [java]          [ERROR] Line 22: The import org.jsoup cannot be resolved
     [java]          [ERROR] Line 23: The import org.jsoup cannot be resolved
     [java]          [ERROR] Line 35: Whitelist cannot be resolved to a type
     [java]          [ERROR] Line 40: Whitelist cannot be resolved to a type
     [java]          [ERROR] Line 40: Whitelist cannot be resolved
     [java]          [ERROR] Line 43: Whitelist cannot be resolved to a type
     [java]          [ERROR] Line 43: Whitelist cannot be resolved
     [java]          [ERROR] Line 46: Whitelist cannot be resolved to a type
     [java]          [ERROR] Line 46: Whitelist cannot be resolved
     [java]          [ERROR] Line 49: Whitelist cannot be resolved to a type
     [java]          [ERROR] Line 49: Whitelist cannot be resolved
     [java]          [ERROR] Line 52: Whitelist cannot be resolved to a type
     [java]          [ERROR] Line 52: Whitelist cannot be resolved
     [java]          [ERROR] Line 55: Whitelist cannot be resolved to a type
     [java]          [ERROR] Line 62: Jsoup cannot be resolved
     [java]          [ERROR] Line 62: Whitelist cannot be resolved to a type
     [java]       [ERROR] Errors in 'jar:file:gwt-user.jar!/org/hibernate/validator/super/org/hibernate/validator/engine/PathImpl.java'
     [java]          [ERROR] Line 72: The constructor NodeImpl(String) is undefined
     [java]          [ERROR] Line 84: The constructor NodeImpl(Path.Node) is undefined
     [java]          [ERROR] Line 95: The constructor NodeImpl(Path.Node) is undefined
     [java]          [ERROR] Line 202: The constructor NodeImpl(String) is undefined
     [java]          [ERROR] Line 204: The method setInIterable(boolean) is undefined for the type NodeImpl
     [java]          [ERROR] Line 209: The method setIndex(Integer) is undefined for the type NodeImpl
     [java]          [ERROR] Line 212: The method setKey(String) is undefined for the type NodeImpl
     [java]    [ERROR] Aborting compile due to errors in some input files

显然有一些我不见的源jar。我(和其他人)在我的类路径上:

hibernate-validator-4.2.0.Final.jar
hibernate-validator-4.2.0.Final-sources.jar

我还尝试添加joda-time-2.1.jarjoda-time-2.1-sources.jarjsoup-1.6.3.jarjsoup-1.6.3-sources.jar

不应该继承org.hibernate.validator.HibernateValidator来处理超级源代码所以我不需要提供源代码吗?谁能看到我错过的东西?

3 个答案:

答案 0 :(得分:7)

GWT是针对Hibernate Validator 4.1.0-Final而构建的,它依赖于它的一些内部结构(PathImplNodeImpl),显然那些在Hibernate Validator 4.2.0中已经发生了变化。

使用4.1.0-Final(或样本中可能为4.0.2.GA)而不是4.2.0。


可以在GWT Tracker中跟踪问题,我们应该至少明确记录不兼容性。

答案 1 :(得分:0)

我不知道Hibernate验证的GWT实现。但是为什么GWT试图从你的Hibernate源jar中理解代码呢?如果它是GWT自己的代码,它应该来自它的gwt-user.jar或类似的东西。

如果您同意我的意见,那么请不要在GWT编译类路径中包含任何真正的Hibernate jar。无论如何,它不需要它/知道它。

答案 2 :(得分:0)

4.1.0也为我工作,经过一段时间后我发现更高版本存在一些问题。因此,使用与gwt(http://www.gwtproject.org/doc/latest/DevGuideValidation.html)教程中推荐的版本相同的版本,我也有编译警告:

detected warnings related to 'javax.validation.constraint'. is validation- version .jar on the classpath

我修正了:

<dependency>
    <groupId>javax.validation</groupId>
    <artifactId>validation-api</artifactId>
    <scope>compile</scope>
</dependency>