0

我正面临这个奇怪的问题,其中 api 由于 javax.validation 问题而引发并发修改异常。

    java.util.ConcurrentModificationException: null
    at java.util.HashMap$HashIterator.nextNode(HashMap.java:1445) ~[na:1.8.0_265]
    at java.util.HashMap$ValueIterator.next(HashMap.java:1474) ~[na:1.8.0_265]
    at org.eclipse.persistence.jpa.PersistenceProvider.isLoadedWithReference(PersistenceProvider.java:464) ~[eclipselink-2.6.1.jar:2.6.1.v20150916-55dc7c3]
    at javax.persistence.Persistence$PersistenceUtilImpl.isLoaded(Persistence.java:154) ~[javax.persistence-2.1.0.jar:2.1.0]
    at org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:56) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:130) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:46) ~[bean-validator-2.2.0.jar:5.0.0.Final] [1 skipped]
    at org.hibernate.validator.internal.engine.ValidatorImpl.isReachable(ValidatorImpl.java:1307) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:1292) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    ... 49 common frames omitted
Wrapped by: javax.validation.ValidationException: HV000041: Call to TraversableResolver.isReachable() threw an exception.
    at org.hibernate.validator.internal.engine.ValidatorImpl.isReachable(ValidatorImpl.java:1316) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:1292) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:475) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:424) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:388) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:340) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraint(ValidatorImpl.java:635) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraints(ValidatorImpl.java:524) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:349) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraint(ValidatorImpl.java:635) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraints(ValidatorImpl.java:524) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateParametersInContext(ValidatorImpl.java:916) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateParameters(ValidatorImpl.java:240) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateParameters(ValidatorImpl.java:198) ~[bean-validator-2.2.0.jar:5.0.0.Final]
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095) [webapp-runner.jar:na] [28 skipped]
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) [webapp-runner.jar:na]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502) [webapp-runner.jar:na]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458) [webapp-runner.jar:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_265]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_265]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [webapp-runner.jar:na]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_265]

堆栈跟踪没有说明 bean 中的哪个验证导致了问题。

4

2 回答 2

1

看起来堆栈跟踪正在以一种特殊的方式被...格式化。

显示它的正常方式是首先显示主要异常,然后是cause(或包装的)异常链。但是您向我们展示的内容是包装的异常,然后是包装它的异常。

所以这意味着ConcurrentModificationException导致ValidationException......而不是相反。

不幸的是,这并不能解释实际发生了什么。

于 2021-04-20T07:19:37.843 回答
0

显然异常堆栈跟踪是说哈希图中发生了并发修改异常。如果在遍历映射值或 API 时使用迭代器,可能会发生并发修改异常,这些映射值或 API 不是线程安全的,如通用 Hashmap 对象。尝试使用并发哈希图,您的问题应该得到解决。

于 2021-04-20T06:53:05.923 回答