title: Hibernate Validator @SafeHtml: org.jsoup.safety.Whitelist not found
body: <p>I have a problem with the @SafeHtml annotation used in bean validation.</p>
  
  <p>The annotations inside the entity:</p>
  
  <pre><code>@Basic
  @Column(length = 100000)
  @NotNull(groups = ValidationOrder1.class)
  @NotBlank(groups = ValidationOrder2.class)
  @Size(min = 5, max = 100000, groups = ValidationOrder3.class)
  @SafeHtml(groups = ValidationOrder4.class)
  private String text;
  </code></pre>
  
  <p>My dependencies inside <code>pom.xml</code>:</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.jsoup&lt;/groupId&gt;
          &lt;artifactId&gt;jsoup&lt;/artifactId&gt;
          &lt;version&gt;1.7.3&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
          &lt;version&gt;5.0.3.Final&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>The following exception is thrown during validation:</p>
  
  <pre><code>java.lang.ClassNotFoundException: org.jsoup.safety.Whitelist not found by org.glassfish.hk2.external.bean-validator
  </code></pre>
  
  <p>The full stacktrace:</p>
  
  <pre><code>[2014-02-07T16:27:01.786+0100] [glassfish 4.0] [WARNING] [] [javax.enterprise.resource.webcontainer.jsf.lifecycle] [[
    Error loading class org.hibernate.validator.internal.constraintvalidators.SafeHtmlValidator
  org.jboss.weld.resources.spi.ResourceLoadingException: Error loading class org.hibernate.validator.internal.constraintvalidators.SafeHtmlValidator
      at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:179)
      at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:188)
      at org.jboss.weld.manager.BeanManagerImpl.createAnnotatedType(BeanManagerImpl.java:1136)
      at org.jboss.weld.util.ForwardingBeanManager.createAnnotatedType(ForwardingBeanManager.java:196)
      at org.hibernate.validator.internal.cdi.DestructibleBeanInstance.createInjectionTarget(DestructibleBeanInstance.java:46)
      at org.hibernate.validator.internal.cdi.DestructibleBeanInstance.&lt;init&gt;(DestructibleBeanInstance.java:32)
      at org.hibernate.validator.internal.cdi.InjectingConstraintValidatorFactory.getInstance(InjectingConstraintValidatorFactory.java:51)
      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.validatePropertyForNonDefaultGroup(ValidatorImpl.java:792)
      at org.hibernate.validator.internal.engine.ValidatorImpl.validatePropertyForCurrentGroup(ValidatorImpl.java:764)
      at org.hibernate.validator.internal.engine.ValidatorImpl.validateValueInContext(ValidatorImpl.java:737)
      at org.hibernate.validator.internal.engine.ValidatorImpl.validateValue(ValidatorImpl.java:184)
      at javax.faces.validator.BeanValidator.validate(BeanValidator.java:315)
      at javax.faces.component.UIInput.validateValue(UIInput.java:1165)
      at javax.faces.component.UIInput.validate(UIInput.java:983)
      at javax.faces.component.UIInput.executeValidate(UIInput.java:1249)
      at javax.faces.component.UIInput.processValidators(UIInput.java:712)
      at javax.faces.component.UIForm.processValidators(UIForm.java:253)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1258)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1258)
      at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1195)
      at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
      at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
      at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
      at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
      at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
      at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
      at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
      at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
      at java.lang.Thread.run(Thread.java:744)
  Caused by: java.lang.NoClassDefFoundError: Lorg/jsoup/safety/Whitelist;
      at java.lang.Class.getDeclaredFields0(Native Method)
      at java.lang.Class.privateGetDeclaredFields(Class.java:2397)
      at java.lang.Class.getDeclaredFields(Class.java:1806)
      at org.jboss.weld.security.GetDeclaredFieldsAction.run(GetDeclaredFieldsAction.java:30)
      at org.jboss.weld.security.GetDeclaredFieldsAction.run(GetDeclaredFieldsAction.java:22)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.computeValue(BackedAnnotatedType.java:177)
      at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.computeValue(BackedAnnotatedType.java:171)
      at org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:35)
      at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$EagerlyInitializedLazyValueHolder.&lt;init&gt;(BackedAnnotatedType.java:154)
      at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.&lt;init&gt;(BackedAnnotatedType.java:171)
      at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.&lt;init&gt;(BackedAnnotatedType.java:171)
      at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.&lt;init&gt;(BackedAnnotatedType.java:65)
      at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.of(BackedAnnotatedType.java:47)
      at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.apply(ClassTransformer.java:85)
      at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.apply(ClassTransformer.java:82)
      at com.google.common.collect.ComputingConcurrentHashMap$ComputingValueReference.compute(ComputingConcurrentHashMap.java:358)
      at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.compute(ComputingConcurrentHashMap.java:184)
      at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.getOrCompute(ComputingConcurrentHashMap.java:153)
      at com.google.common.collect.ComputingConcurrentHashMap.getOrCompute(ComputingConcurrentHashMap.java:69)
      at com.google.common.collect.ComputingConcurrentHashMap$ComputingMapAdapter.get(ComputingConcurrentHashMap.java:396)
      at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:174)
      ... 55 more
  Caused by: java.lang.ClassNotFoundException: org.jsoup.safety.Whitelist not found by org.glassfish.hk2.external.bean-validator [21]
      at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
      at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
      at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
      ... 77 more
  ]]
  
  [2014-02-07T16:27:01.788+0100] [glassfish 4.0] [WARNING] [] [javax.enterprise.web] [[
    StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception
  java.lang.ClassNotFoundException: org.jsoup.safety.Whitelist not found by org.glassfish.hk2.external.bean-validator [21]
      at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
      at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
      at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
      at java.lang.Class.getDeclaredFields0(Native Method)
      at java.lang.Class.privateGetDeclaredFields(Class.java:2397)
      at java.lang.Class.getDeclaredFields(Class.java:1806)
      at org.jboss.weld.security.GetDeclaredFieldsAction.run(GetDeclaredFieldsAction.java:30)
      at org.jboss.weld.security.GetDeclaredFieldsAction.run(GetDeclaredFieldsAction.java:22)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.computeValue(BackedAnnotatedType.java:177)
      at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.computeValue(BackedAnnotatedType.java:171)
      at org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:35)
      at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$EagerlyInitializedLazyValueHolder.&lt;init&gt;(BackedAnnotatedType.java:154)
      at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.&lt;init&gt;(BackedAnnotatedType.java:171)
      at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedFields.&lt;init&gt;(BackedAnnotatedType.java:171)
      at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.&lt;init&gt;(BackedAnnotatedType.java:65)
      at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.of(BackedAnnotatedType.java:47)
      at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.apply(ClassTransformer.java:85)
      at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.apply(ClassTransformer.java:82)
      at com.google.common.collect.ComputingConcurrentHashMap$ComputingValueReference.compute(ComputingConcurrentHashMap.java:358)
      at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.compute(ComputingConcurrentHashMap.java:184)
      at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.getOrCompute(ComputingConcurrentHashMap.java:153)
      at com.google.common.collect.ComputingConcurrentHashMap.getOrCompute(ComputingConcurrentHashMap.java:69)
      at com.google.common.collect.ComputingConcurrentHashMap$ComputingMapAdapter.get(ComputingConcurrentHashMap.java:396)
      at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:174)
      at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:188)
      at org.jboss.weld.manager.BeanManagerImpl.createAnnotatedType(BeanManagerImpl.java:1136)
      at org.jboss.weld.util.ForwardingBeanManager.createAnnotatedType(ForwardingBeanManager.java:196)
      at org.hibernate.validator.internal.cdi.DestructibleBeanInstance.createInjectionTarget(DestructibleBeanInstance.java:46)
      at org.hibernate.validator.internal.cdi.DestructibleBeanInstance.&lt;init&gt;(DestructibleBeanInstance.java:32)
      at org.hibernate.validator.internal.cdi.InjectingConstraintValidatorFactory.getInstance(InjectingConstraintValidatorFactory.java:51)
      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.validatePropertyForNonDefaultGroup(ValidatorImpl.java:792)
      at org.hibernate.validator.internal.engine.ValidatorImpl.validatePropertyForCurrentGroup(ValidatorImpl.java:764)
      at org.hibernate.validator.internal.engine.ValidatorImpl.validateValueInContext(ValidatorImpl.java:737)
      at org.hibernate.validator.internal.engine.ValidatorImpl.validateValue(ValidatorImpl.java:184)
      at javax.faces.validator.BeanValidator.validate(BeanValidator.java:315)
      at javax.faces.component.UIInput.validateValue(UIInput.java:1165)
      at javax.faces.component.UIInput.validate(UIInput.java:983)
      at javax.faces.component.UIInput.executeValidate(UIInput.java:1249)
      at javax.faces.component.UIInput.processValidators(UIInput.java:712)
      at javax.faces.component.UIForm.processValidators(UIForm.java:253)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1258)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1258)
      at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1195)
      at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
      at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
      at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
      at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
      at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
      at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
      at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
      at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
      at java.lang.Thread.run(Thread.java:744)
  ]]
  </code></pre>