-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: Error when buildSessionFactory() for AnnotationConfiguration
PostPosted: Thu Jun 07, 2007 10:32 am 
Regular
Regular

Joined: Wed Apr 12, 2006 12:49 am
Posts: 105
Location: Malaysia
Hi,

I'm using Hibernate Core 3.2.2.GA & Hibernate Annotations 3.3.0.GA.

I have the following code in my HibernateUtil.java but it gives error at annotationConfiguration.buildSessionFactory() part when I try to run my application. Any possible reason why it fails?

Code:
-------
annotationConfiguration = new AnnotationConfiguration();
annotationConfiguration.configure();
annotationConfiguration.buildSessionFactory();


Error:
------
java.lang.ClassCastException: org.hibernate.validator.event.ValidateEventListener
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:783)
at my.com.snt.util.HibernateUtil.<clinit>(HibernateUtil.java:41)
at my.com.snt.cis.filter.HibernateFilter.doFilter(HibernateFilter.java:21)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)


Please advise.
Thanks.

_________________
Thank you.

Regards,
Jap.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 07, 2007 1:14 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
An old jar somewhere in your classpath probably

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 07, 2007 9:00 pm 
Regular
Regular

Joined: Wed Apr 12, 2006 12:49 am
Posts: 105
Location: Malaysia
Dear Emmanuel,

Thanks, I will try.
Probably not due to old jar in classpath, but you gave me a hint.
It could be the hibernate core jar file in my JBoss is the old one as I'm using Hibernate Core 3.2.2GA.

Between, do we usually need to put hibernate core, annotations jar in the JBoss lib directory when we deploy our application? or include these jars as part of our application lib.

Please advise.

_________________
Thank you.

Regards,
Jap.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 08, 2007 9:42 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I usually update the server, I never tried deploying them in the app only.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 08, 2007 10:32 am 
Regular
Regular

Joined: Wed Apr 12, 2006 12:49 am
Posts: 105
Location: Malaysia
Dear Emmanuel,

I found out the cause for my error already.
It is because I didn't include hibernate-validator.jar in my project and jboss lib folder also doesn't have the jar file.

1. The strange thing is I don't really use Hibernate Validator in my coding, but why must I include this jar file? Any idea?

2. Like this case, Jboss does not have hibernate-validator.jar, so you mean you usually copy this file to the Jboss folder instead of attached with project correct? and if the jboss jar file is older than the one you use in development eg hibernate3.jar, you will replace this correct? will this affect the Jboss itself?

3. If i include jar file in project and Jboss lib directory also has the same jar but different version, do you know which jar will it use?

4. By the way, if you update the jar files in server instead of "bundle" with each application, when you update the hibernate3.jar in the server, existing applications that are running fine will be affected right? Would like to listen to your experience.

Please advise.

_________________
Thank you.

Regards,
Jap.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 08, 2007 5:40 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
JBoss AS as of today does include Hibernate Validator through hibernate-annotations.jar (HAN 3.2 series)
As of Hibernate Annotations 3.3.0, validator has been split.
That's why you have the issue I guess

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 09, 2007 10:34 am 
Regular
Regular

Joined: Wed Apr 12, 2006 12:49 am
Posts: 105
Location: Malaysia
So, do you mean although my application does not use hibernate annotations but it's actually hibernate annotations itself that needs to use Validator to do something (which I don't know) and therefore gives error when validator jar is not included?

Please advise.

_________________
Thank you.

Regards,
Jap.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 11, 2007 7:17 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
yes, because your new annotation version (included in your app) finds an old validator in the classpath (from JBoss).
If JBoss AS was not including validator, then you would be fine

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 12, 2007 8:50 am 
Regular
Regular

Joined: Wed Apr 12, 2006 12:49 am
Posts: 105
Location: Malaysia
Yes, you are right.

The original Jboss AS 4.0.3SP1 does comes with hibernate-annotations.jar which include Validator inside.

However, when I hit the error I try to replace the hibernate-annotations.jar in the JBoss AS directory. Unfortunately, like you mention, Validator is not included in the latest version of hibernate-annotations.jar. As a result, the error occur.

Now I understand.

Is the fact validator is not "bundled" as part of hibernate-annotations.jar documented somewhere? so that next time I would know where to look for if I hit strange error and save the troubleshooting time.

_________________
Thank you.

Regards,
Jap.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 3:05 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It's mentionned in the reference documentation and the migration guide wiki page I think.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 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.