Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot cast org.hibernate.validator.util.LazyValidatorFactory to javax.validation.ValidatorFactory

 
ezani abd halim
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I am trying to deploy a test application using Prime Faces, Hibernate, Spring DAO, EJB3, Facelets and JSF2.0 which I created in my Net Beans 6.9.1 IDE which works fine in GlassFish Server 3.0 but does not seem to run on JBoss-6.0.0.Final. Since the app connects to a MySQL database, uses JPA2 and JTA (EclipseLink), I have added the mysql-connector.x.x.x-bin.jar and the mysql-ds.xml files needed. Many of the jar files in our app's lib folder had to be removed because they were already included in JBoss AS 6 and were causing ClassCastExceptions. After refining the jars to be included in our app's lib folder, I am still obtaining a few errors.

Main error seems to be :-

05:27:18,931 ERROR [STDERR] log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
05:27:18,931 ERROR [STDERR] log4j:WARN Please initialize the log4j system properly.
05:27:18,975 ERROR [[/H2Care]] Exception sending context initialized event to listener instance of class
org.jboss.web.jsf.integration.config.JBossMojarra20ConfigureListener: java.lang.ClassCastException: Cannot cast org.hibernate.validator.util.LazyValidatorFactory to javax.validation.ValidatorFactory

Here is my persistence.xml file:



Please help. I attach the full JBoss 6 server log below :-




Thank you very much in advance.
Ezani

 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you packaging any jar file(s) containing javax.validation.* within your application. If yes, remove such jar(s) from your application packaging.
 
ezani abd halim
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jaikiran

Long time no see....I've been taking a 10-months sabbatical..great to be back to JEE and JavaRanch with my new employer! Yep..java-validation.jar was one of the files that I had removed from our app's lib folder as well as hibernate-validation.jar since I found they're both already available in JBoss. The set of pre-available jars that is already included with JBoss seems to be a fallacy of JBoss. You see, we have no problems with Glassfish as they don't include jars so our app was able to run. We would expect it also to be able to run straight off with JBoss by copying the war to server/deploy but no, the moment we moved to JBoss, we had to include the -ds.xml and also look at duplicate jar files causing the ClassCastExceptions which to me is really a time waster. Anyway the 'Deployment in Error' problem still exists between these pair of jars : hibernate-validator and javax-validation. At the time I posted, I'd removed both. Let me try putting one not the other and see how the problem works out. Will keep everyone informed!

Thanks again!

Ezani
 
ezani abd halim
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there

Just to make things cystal clear, I list down all the jars that I have in my lib folder of my app (leaving out the versions). They are :-

aristo.jar
barbecue.jar
bcmail.jar
bcprov-jdk.jar
bctsp-jdk.jar
black-tie.jar
blitzer.jar
bluesky.jar
casablanca.jar
commons-fileupload.jar
commons-io.jar
commons-logging.jar
cupertino.jar
dark-hive.jar
dot-luv.jar
eggplant.jar
excite-bike.jar
facestrace.jar
flick.jar
glass-x.jar
hot-sneaks.jar
humanity.jar
itext.jar
jcommon.jar
jdom.jar
jfreechart.jar
jsf-api-2.x.x.jar
jsf-impl-2.x.x.jar
jstl.jar
junit.jar
le-frog.jar
midnight.jar
mint-choc.jar
overcast.jar
pepper-grinder.jar
poi.jar
primefaces-3.x.x.jar
primefaces-3.x.x-SNAPSHOT.jar
redmond.jar
rocket.jar
rome.jar
smoothness.jar
south-street.jar
start.jar
sunny.jar
swanky-purse.jar
trontastic.jar
ui-darkness.jar
ui-lightness.jar
vader.jar
 
ezani abd halim
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

Ok...I included hibernate-validator.jar in the lib folder and left out validation-api.jar and also vice versa but I still keep getting this error:

java.lang.ClassCastException: Cannot cast org.hibernate.validator.util.LazyValidatorFactory to javax.validation.ValidatorFactory

 
ezani abd halim
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there.

Has anyone faced the same problem and found a fix? Not making any headway on this. I've ensured eclipselink.jar and jaxax.persistence.jar is in JBoss and I know that the whole range of Hibernate jars (core, annotations, validation, etc) are already included in JBoss AS (server/all/common/lib) and after scouting that folder, I also found validation-api.jar. I believe it may be a conflict between hibernate-validator.jar and validation-api.jar in the JBoss AS libraries or a version mismatch so I will head in that direction for now. Will keep you informed if I can fix, God willing.

Ezani
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic