Bean 検証 (JSR-303) カスタム制約を使用しようとしているときに、ここで説明されているように注釈と XML 構成を使用すると、ログに次のエラーが表示され、制約が無視されます。
<Error> <org.hibernate.validator.xml.ValidationXmlParser> <BEA-000000> <Error parsing validation.xml: null>
アプリケーション サーバーとして Weblogic 12.1.1 を使用しており、アプリケーションは war ファイルとしてデプロイされています。
validation.xmlファイルとconstraint-mapping.xmlファイルの両方が、WEB-INF/classes/META-INF の下に配置されます。
誰かがこれを引き起こす可能性のある手がかりを持っていますか? これは依存関係または競合するライブラリの問題ですか?
ここに私のvalidation.xmlがあります:
<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration">
<default-provider>org.hibernate.validator.HibernateValidator</default-provider>
<constraint-mapping>META-INF/constraint-mapping.xml</constraint-mapping>
</validation-config>
そして私のconstraint-mapping.xml:
<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd"
xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
<constraint-definition annotation="foo.CustomConstraint">
<validated-by include-existing-validators="true">
<value>foo.CustomConstraintValidator</value>
</validated-by>
</constraint-definition>
</constraint-mappings>
前もって感謝します、
ディミトリス
アップデート
Gunnar の提案に従った後、次のことを行いました。
- Weblogic のデフォルトの休止状態バリデーター (4.1.0) をバージョン 4.3.1 でオーバーライドします。
- ValidationXmlParser クラスをデバッグしました。
これにより、次の例外が発生しました。
javax.xml.bind.UnmarshalException
- with linked exception:
[Exception [EclipseLink-25004] (Eclipse Persistence Services - 2.3.2.v20111125-r10461):
org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred unmarshalling the document
Internal Exception: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 96;
SchemaLocation: schemaLocation value =
'http://jboss.org/xml/ns/javax/validation/configuration' must have even number of URI's.]
これを克服するために、validation.xml の xsi:schemaLocation を次のように更新しました。
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration
http://jboss.org/xml/ns/javax/validation/configuration/validation-configuration-1.0.xsd"
この変更により、以前のエラーは修正されますが、注釈は引き続き無視されます。ここで何が恋しいですか?