我有以下错误
ValidationException:HV000041:调用TraversableResolver.IsReachable()引发异常。在org.hibernate.validator.internal.engine.validatorimpl.isreachable(validatorimpl.java:1405)上
org.hibernate.validator.internal.engine.validatorimpl.isvalidationrequired(validatorimpl.java:1381)
在org.hibernate.validator.internal.engine.validatorimpl.validateconstraint(validatorimpl.java:542)在org.hibernate.validator.internal.engine.validatorimpl.validateconstraintsfordefaultgroup(validatorimpl.java:487)在org.hibernate.validator.internal.engine.validatorconstraintsforcurrentgroup(validatorimpl.java:451)在unit.runners.model.frameworkmethod$1.RunReflectiveCall(FrameworkMethod.Java:50)在org.junit.internal.runners.model.reflectiveCallable.Run(ReflectiveCallable.12)在org.junit.runners.model.frameworkmethod.InvokeExplory(FrameworkMethod.47)在org.junit.internal.runners.statements.InvokeMethod.Evalue(InvokeMethod.17)在Junit4.SpringJunit4ClassRunner.Runchild(SpringJunit4ClassRunner.:88)在org.junit.runners.ParentRunner$3。Run(ParentRunner.Java:290)在org.junit.runners.ParentRunner.Runchilds(ParentRunner.Java:290)在org.junit.runners.ParentRunner.Runchilds(ParentRunner.Java:71)在org.junit.runners.ParentRunner.Access(ParentRunner.Access)在38)在org.eclipse.jdt.internal.junit.runner.remoteStrunner.runtests(remoteStrunner.java:459)在org.eclipse.jdt.internal.junit.runner.remoteStrunner.runtests(remoteStrunner.java:675)在org.eclipse.jdt.internal.junit.runner.remoteStrunner.junner.run(remoteStrunner.java:382)在versableResolverforSingleValidation.java:96)位于org.hibernate.validator.internal.engine.resolver.cachingTraversableResolverforSingleValidation.IsReachable(CachingTraversableResolverforSingleValidation.java:41)位于org.hibernate.validator.internal.engine.validatorimpl.IsReachable(validatorimpl.java:1396
这是我的代码---------------------JUnit-------------//DeploymentConfigurationMappingPK初始化在construtor中完成
@Test
public void test1ConnectionIdIsRequired()
{
connectionMappingPK.setConnectionId(null);
List<String> errorMessages=null;
errorMessages=adminValidator.constraintViolationsForDeploymentConfigMapping(connectionMappingPK);
Assert.assertTrue(errorMessages.contains("ConnectionId must be specified."));
}
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.JoinColumn;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import com.demo.DBConstants;
@Embeddable
public class DeploymentConfigurationMappingPK implements Serializable {
private static final long serialVersionUID = 1L;
@JoinColumn(name = DBConstants.CONNECTION_ID, nullable = false)
@Column(name = DBConstants.CONNECTION_ID, nullable = false, length = 255)
@NotNull(message="ConnectionId must be specified.")
@Size(min=1, max=255)
private String connectionId;
@Basic
@Column(name = DBConstants.APPLICATION_ID, length = 255)
@NotNull(message="ApplicationId must be specified.")
@Size(min=1, max=255)
private String applicationId;
@Basic
@Column(name = DBConstants.APPLICATION_VERSION, length = 10)
@NotNull(message="ApplicationVersion must be specified.")
@Size(min=1, max=10)
private String applicationVersion;
public String getConnectionId() {
return connectionId;
}
public void setConnectionId(String connectionId) {
this.connectionId = connectionId;
}
public String getApplicationId() {
return applicationId;
}
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
public String getApplicationVersion() {
return applicationVersion;
}
public void setApplicationVersion(String applicationVersion) {
this.applicationVersion = applicationVersion;
}
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ConnectionMappingPK)) {
return false;
}
ConnectionMappingPK castOther = (ConnectionMappingPK) other;
return this.connectionId.equals(castOther.getConnectionId())
&& this.applicationId.equals(castOther.getApplicationId())
&& this.applicationVersion.equals(castOther
.getApplicationVersion());
}
public int hashCode() {
final int prime = 31;
int hash = 17;
hash = hash * prime + this.connectionId.hashCode();
hash = hash * prime + this.applicationVersion.hashCode();
hash = hash * prime + this.applicationId.hashCode();
return hash;
}
}
----------------AdminValidator------------------------------------------------------------------------------------------------------------
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.Demo.persistence.model.DeploymentConfigurationMappingPK ;
public class AdminValidator {
private static final Logger LOG = LoggerFactory
.getLogger(AdminValidator.class);
private ValidatorFactory factory = null;
private Validator validator = null;
public AdminValidator() {
if (factory == null) {
factory = Validation.buildDefaultValidatorFactory();
validator = factory.getValidator();
}
}
public List<String> constraintViolationsForDeploymentConfigMapping(DeploymentConfigurationMappingPK connMapPK) {
if (LOG.isDebugEnabled()) {
LOG.debug("In handler #constraintViolationsDetectedForConnMapping of AdminValidator");
}
List<String> errorMessages = new ArrayList<String>();
**Set<ConstraintViolation<DeploymentConfigurationMappingPK>> constraintViolations = validator**
.validate(connMapPK);
if (constraintViolations.size() > 0)
{
Iterator<ConstraintViolation<DeploymentConfigurationMappingPK>> iterator = constraintViolations
.iterator();
while (iterator.hasNext())
{
ConstraintViolation<DeploymentConfigurationMappingPK> cv = iterator
.next();
errorMessages.add(cv.getMessage());
}
}
return errorMessages;
}
}
-----------持久性.xml------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="com.Demo.persistence"
transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.Demo.persistence.model.DeploymentConfigurationMappingPK</class>
<shared-cache-mode>ALL</shared-cache-mode>
<properties>
<property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
</properties>
</persistence-unit>
</persistence>
我们在演示项目中使用的是eclipselink、springframework,而不是spring的MVC。
似乎与HV-1013漏洞有关,在hibernate 5.3.0.cr1中修复。
这是一个windows表单应用程序,我在其中有一个特定的表单。在这个表单上,我显示了一些应该在后台异步发生的处理的进度。所有这些都很好,除了当我尝试处理后台处理中捕获的异常时…… 这是表单代码中调用Async函数的子函数,该函数位于包含所有后台处理代码的模块中: 这是它调用的异步函数,它位于一个单独的模块中: 这是由异步函数调用的常规sub: 当我使用我知道最终会在子B中生成错误的数据运行此代码时
问题内容: 我有一个简单的方法,可将命令打印到屏幕上,扫描用户的输入,然后将其作为字符串返回。如果用户输入无效,它将通知用户并再次询问。该方法运行完美,但是我的讲师提到我们应该始终关闭资源,因此我回过头来添加了close方法,现在无论用户输入什么,每次调用该方法时都会收到NoSuchElementException。这是代码… 例外总是指向用户输入以scan.nextLine()。trim()开头
问题内容: 假设我希望能够在程序中任何地方每次引发异常时都能够记录到文件。我不想修改任何现有代码。 当然,可以将其概括为每次引发异常时都可以插入钩子。 以下代码是否被认为可以安全地执行此操作? 问题答案: 如果要记录 未捕获的 异常,只需使用sys.excepthook即可。 我不确定是否会记录 所有 引发的异常的价值,因为很多库会在内部为可能不关心的事情引发/捕获异常。
你可以使用raise语句 引发 异常。你还得指明错误/异常的名称和伴随异常 触发的 异常对象。你可以引发的错误或异常应该分别是一个Error或Exception类的直接或间接导出类。 如何引发异常 例13.2 如何引发异常 #!/usr/bin/python # Filename: raising.py classShortInputException(Exception): '''A u
问题内容: 以上是我的脚本。 这是我的错误: 有谁知道这是为什么发生以及如何解决? 问题答案: 字符编码存在问题。您是否尝试过在报告开头更改编码行? 例如,对于中欧字母,请更改: 通过 您在这里有不同字符编码标准的列表:http : //en.wikipedia.org/wiki/Character_encoding#Common_character_encodings 希望能奏效