Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: ClassCastException HibernateValidator to ValidationProvider
PostPosted: Wed Nov 18, 2009 5:56 am 
Newbie

Joined: Wed Nov 18, 2009 5:30 am
Posts: 10
Hi,

While using HibernateValidator (4.0.0.GA) and statically initializing ValidatorFactory, i get following error at deployment time in Weblogic11g:
java.lang.ClassCastException: org.hibernate.validator.HibernateValidator cannot be cast to javax.validation.spi.ValidationProvider

Code excerpt:

public class BaseBusinessObject implements BusinessObject {
protected static ValidatorFactory factory = Validation.byDefaultProvider().configure().buildValidatorFactory();
protected Validator validator = null;

....
}

This BaseBusinessObject is being used in a stateless EJB 3.0 which is in turn used by Struts2 actions.

When i move factory initialization to an instance method everything goes fine and works as desired. Any clues why its happening?

Full Stacktrace:

java.lang.ClassCastException: org.hibernate.validator.HibernateValidator cannot be cast to javax.validation.spi.ValidationProvider
at javax.validation.Validation$DefaultValidationProviderResolver.getValidationProviders(Validation.java:332)
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:256)
at com.warid.campaign.businessobject.BaseBusinessObject.initValidator(BaseBusinessObject.java:94)
at com.warid.campaign.businessobject.BaseBusinessObject.<clinit>(BaseBusinessObject.java:26)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getClassForName(PrivilegedAccessHelper.java:86)
at org.eclipse.persistence.internal.weaving.TransformerFactory.storeAttributeMappings(TransformerFactory.java:475)
at org.eclipse.persistence.internal.weaving.TransformerFactory.buildClassDetailsAndModifyProject(TransformerFactory.java:161)
at org.eclipse.persistence.internal.weaving.TransformerFactory.createTransformerAndModifyProject(TransformerFactory.java:80)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:849)
at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:216)
at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:343)
at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:323)
at weblogic.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:125)
at weblogic.deployment.AbstractPersistenceUnitRegistry.storeDescriptors(AbstractPersistenceUnitRegistry.java:336)
at weblogic.deployment.AbstractPersistenceUnitRegistry.loadPersistenceDescriptor(AbstractPersistenceUnitRegistry.java:250)
at weblogic.deployment.ModulePersistenceUnitRegistry.<init>(ModulePersistenceUnitRegistry.java:63)
at weblogic.ejb.container.deployer.EJBModule.setupPersistenceUnitRegistry(EJBModule.java:210)
at weblogic.ejb.container.deployer.EJBModule$1.execute(EJBModule.java:311)
at weblogic.deployment.PersistenceUnitRegistryInitializer.setupPersistenceUnitRegistries(PersistenceUnitRegistryInitializer.java:62)
at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:362)
at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:176)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:42)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:609)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:185)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:53)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
at weblogic.deploy.internal.targetserver.operations.RedeployOperation.createAndPrepareContainer(RedeployOperation.java:98)
at weblogic.deploy.internal.targetserver.operations.RedeployOperation.doPrepare(RedeployOperation.java:122)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:157)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:12)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:45)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)


Top
 Profile  
 
 Post subject: Re: ClassCastException HibernateValidator to ValidationProvider
PostPosted: Tue Dec 22, 2009 1:07 am 
Newbie

Joined: Wed Nov 18, 2009 5:30 am
Posts: 10
I was using weblogic 10.3.0 i did following change in weblogic-application.xml in application ear

<prefer-application-packages>
<package-name>javax.validation.*</package-name>
<package-name>org.hibernate.validator.*</package-name>
</prefer-application-packages>

And now i can instantiate validator factory in static class. It was a class loading issue. And above lines enable weblogic filter class loader.
Do not forget to add validation.jar and hibernate-validator.jar in manifest of ejb.jar.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.