2012-09-12 43 views
4

我正在嘗試使用hibernate驗證器來工作gwt驗證。我照着在http://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/validation/gwt編譯期間的GWT驗證錯誤 - 沒有可用的源代碼

我.gwt.xml文件樣本驗證項目,隨後從http://code.google.com/p/google-web-toolkit/wiki/BeanValidation步驟和配置我的項目包含:

<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照顧超級源,所以我不需要提供源代碼?任何人都可以看到我失蹤的東西嗎?

回答

7

GWT是針對Hibernate Validator 4.1.0-Final構建的,它依賴於它的一些內部組件(PathImpl,NodeImpl),顯然這些在Hibernate Validator 4.2.0中已經有所改變。

使用4.1.0-Final(或可能在示例中爲4.0.2.GA)而不是4.2.0。


問題可以在GWT Tracker被跟蹤,我們或許應該至少文檔的不兼容性明確。

+0

我使用Hibernate 3.6.9實際,但切換hibernate驗證器的版本爲4.1.0.Final解決了它。謝謝!我爲它創建了一個問題:http://code.google.com/p/google-web-toolkit/issues/detail?id=7661 – Jonas

+0

謝謝;編輯的答案以清楚地說明我提到了Hibernate Validator(而不是Hibernate ORM)並且包含了問題的鏈接。 –

0

我不知道Hibernate驗證的GWT實現。但爲什麼GWT試圖理解你的Hibernate源碼jar中的代碼?如果它是GWT自己的代碼,它應該來自它的gwt-user.jar或類似的東西。

如果您同意我的觀點,那麼請不要在GWT編譯類路徑中包含任何真正的Hibernate jar。無論如何,它不需要它/知道它。

0

4.1.0也適用於我,經過一段時間後,我發現高版本有幾個問題。因此,可以使用相同的版本從GWT教程(http://www.gwtproject.org/doc/latest/DevGuideValidation.html)內recommaned還我有一個編譯警告:

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> 
相關問題