1
OVAL検証フレームワークを使用してXMLファイルを処理中に例外が発生します。私は検証のためにOVAL検証フレームワークを使用しています。私はこのユーザーガイドをサイトに記載しています。 http://oval.sourceforge.net/userguide.htmlXMLfileを処理中のConversionException XStream API
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception : java.lang.RuntimeException
cause-message : null
class : java.util.regex.Pattern
required-type : java.util.regex.Pattern
converter-type : com.thoughtworks.xstream.converters.extended.RegexPatternConverter
path : /oval/class/field/matchPattern/pattern
line number : 13
class[1] : net.sf.oval.constraint.MatchPatternCheck
converter-type[1] : net.sf.oval.configuration.xml.XMLConfigurer$1
class[2] : net.sf.oval.configuration.pojo.elements.FieldConfiguration
class[3] : net.sf.oval.configuration.pojo.elements.ClassConfiguration
class[4] : net.sf.oval.configuration.pojo.POJOConfigurer
version : 1.4.9
-------------------------------
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root Cause
com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception : java.lang.RuntimeException
cause-message : null
class : java.util.regex.Pattern
required-type : java.util.regex.Pattern
converter-type : com.thoughtworks.xstream.converters.extended.RegexPatternConverter
path : /oval/class/field/matchPattern/pattern
line number : 13
class[1] : net.sf.oval.constraint.MatchPatternCheck
converter-type[1] : net.sf.oval.configuration.xml.XMLConfigurer$1
class[2] : net.sf.oval.configuration.pojo.elements.FieldConfiguration
class[3] : net.sf.oval.configuration.pojo.elements.ClassConfiguration
class[4] : net.sf.oval.configuration.pojo.POJOConfigurer
version : 1.4.9
-------------------------------
com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
私のXMLは
<?xml version="1.0" ?>
<oval xmlns="http://oval.sf.net/oval-configuration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://oval.sf.net/oval-configuration http://oval.sourceforge.net/oval-configuration.xsd">
<!-- define checks for the acme.model.User class -->
<!-- overwrite=false means already defined checks for this class will not
be removed -->
<class type="org.rbac.form.ConfigurationLoginForm" overwrite="false">
<field name="password">
<notNull message="password.can.not.be null"></notNull>
<notEmpty message="password.can.not.be.empty"></notEmpty>
<length min="4" max="20" message="password.length.must.be.between.min.max"></length>
<matchPattern matchAll="true">
<pattern pattern="^[a-z0-9]{8}$" flags="0" />
</matchPattern>
</field>
</class>
</oval>
であり、これは、私はそれが正常に動作し、パターンを削除した場合、XML
XMLConfigurer xmlConfigurer = new XMLConfigurer(FormValidator.class.getResourceAsStream("/validation/login_configuration.xml"));
Guard guard = new Guard(xmlConfigurer);
Validator validator = new Validator(guard.getConfigurers());
ResourceBundleMessageResolver messageResolver = new ResourceBundleMessageResolver();
messageResolver.addMessageBundle(resourceBundle);
Validator.setMessageResolver(messageResolver);
Validator.setContextRenderer(new ResourceBundleValidationContextRenderer());
List<ConstraintViolation> LS = validator.validate(formObject);
return LS;
に対してオブジェクトを検証する方法です。なにか提案を。
また、いくつかのJavaコードを追加してください。 –
結局これを解決できましたか? – javabeats