title: javax.validation.ValidationException: HV000063: Unable to instantiate class
body: <p>I am running junit written in Custom JSR 303 Validation using ConstraintValidator. Something like this <a href="http://goldenpackagebyanuj.blogspot.in/2013/05/custom-jsr-303-validation-using-constraintValidator.html" rel="nofollow">example</a></p>
  
  <p>My Validation test class:</p>
  
  <pre><code>public class ProductV2ValidationTest {
      private static Validator validator;
      @Before
      public void setUp() throws ExternalApiException {
           ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();  
           validator = validatorFactory.getValidator();  
     }
  
     @Test
     public void ValidatorTest() {
         try {
             ProductV2 productV2 = getObjectMapper().readValue(this.getClass().getResourceAsStream("/json/productV2Valid.json"),  ProductV2.class);
  
             Set&lt;ConstraintViolation&lt;ProductV2&gt;&gt; constraintViolations = validator.validate(productV2);  
            for(ConstraintViolation&lt;ProductV2&gt; constraintViolation : constraintViolations){  
              String message = constraintViolation.getMessage();  
              System.out.println(message);  
          }  
  
          assertEquals(0,constraintViolations.size());  
  
      }  catch (IOException e) {
          e.printStackTrace();
          assertTrue(false);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>FYI, My validators are in some another maven project(jar),and test are written in another maven project(war).</p>
  
  <p>I am getting this error:</p>
  
  <pre><code>javax.validation.ValidationException: HV000063: Unable to instantiate class com.xyz.gep.itemwrapper.external.entities.validator.NumberOfObjectsValidater.
  at org.hibernate.validator.internal.util.privilegedactions.NewInstance.run(NewInstance.java:54)
  at org.hibernate.validator.internal.util.ReflectionHelper.run(ReflectionHelper.java:658)
  at org.hibernate.validator.internal.util.ReflectionHelper.newInstance(ReflectionHelper.java:206)
  at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorFactoryImpl.getInstance(ConstraintValidatorFactoryImpl.java:34)
  at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.createAndInitializeValidator(ConstraintValidatorManager.java:141)
  at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.getInitializedValidator(ConstraintValidatorManager.java:101)
  at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:125)
  at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:91)
  at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:85)
  at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:478)
  at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:424)
  at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:388)
  at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:340)
  at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:158)
  at com.rakuten.gep.itemwrapper.external.entities.validator.ProductV2ValidationTest.ValidatorTest(ProductV2ValidationTest.java:36)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
  at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  Caused by: java.lang.IllegalAccessException: Class org.hibernate.validator.internal.util.privilegedactions.NewInstance can not access a member of class com.rakuten.gep.itemwrapper.external.entities.validator.NumberOfObjectsValidater with modifiers ""
  at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:109)
  at java.lang.Class.newInstance(Class.java:368)
  at org.hibernate.validator.internal.util.privilegedactions.NewInstance.run(NewInstance.java:48)
  at org.hibernate.validator.internal.util.ReflectionHelper.run(ReflectionHelper.java:658)
  at org.hibernate.validator.internal.util.ReflectionHelper.newInstance(ReflectionHelper.java:206)
  at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorFactoryImpl.getInstance(ConstraintValidatorFactoryImpl.java:34)
  at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.createAndInitializeValidator(ConstraintValidatorManager.java:141)
  at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.getInitializedValidator(ConstraintValidatorManager.java:101)
  at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:125)
  at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:91)
  at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:85)
  at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:478)
  at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:424)
  at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:388)
  at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:340)
  at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:158)
  at com.rakuten.gep.itemwrapper.external.entities.validator.ProductV2ValidationTest.ValidatorTest(ProductV2ValidationTest.java:36)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
  at mockit.integration.junit4.internal.BlockJUnit4ClassRunnerDecorator.executeTest(BlockJUnit4ClassRunnerDecorator.java:126)
  at mockit.integration.junit4.internal.BlockJUnit4ClassRunnerDecorator.invokeExplosively(BlockJUnit4ClassRunnerDecorator.java:104)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java)
  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
  ... 6 more
  </code></pre>
  
  <p>I tried adding</p>
  
  <pre><code>&lt;dependency&gt;
     &lt;groupId&gt;javax.el&lt;/groupId&gt;
     &lt;artifactId&gt;javax.el-api&lt;/artifactId&gt;
     &lt;version&gt;2.2.4&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
     &lt;groupId&gt;org.glassfish.web&lt;/groupId&gt;
     &lt;artifactId&gt;javax.el&lt;/artifactId&gt;
     &lt;version&gt;2.2.4&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>But no help .</p>
  
  <p>I am using this dependancy:</p>
  
  <pre><code>&lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
          &lt;version&gt;5.0.2.Final&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
                  &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
  </code></pre>