Fórumok
java.lang.ClassCastException: org.hibernate.dialect.MySQLDialect cannot be
Sanjeev Kumar, módosítva 11 év-val korábban
java.lang.ClassCastException: org.hibernate.dialect.MySQLDialect cannot be
New Member Bejegyzések: 6 Csatlakozás dátuma: 2013.02.27. Legújabb bejegyzések
Hi everyone,
I am using Liferay CE 6.1, tomcat 7.
I am developing custom portlets in my liferay project.
I am connecting to external database MySQL.
I need to add hibernate3.jar to implement my custom API's in my portlet.
I tried adding the hibernate3.jar explicitly in my WEB-INF/lib folder and also tried adding through liferay-plugin-package.properties to include the dependency jar which liferay uses.
But I get the same error, saying org.hibernate.HibernateException: Could not instantiate dialect class
BeanLocator not set for servlet context,
java.lang.ClassCastException: org.hibernate.dialect.MySQLDialect cannot be cast to org.hibernate.dialect.Dialect.
org.hibernate.HibernateException: Could not instantiate dialect class.
Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liferayHibernateSessionFactory' defined in ServletContext resource [/WEB-INF/classes/META-INF/hibernate-spring.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Could not instantiate dialect class.
I am not able to go forward until I get rid of this problem, please I need help, thanks in advance...
I am using Liferay CE 6.1, tomcat 7.
I am developing custom portlets in my liferay project.
I am connecting to external database MySQL.
I need to add hibernate3.jar to implement my custom API's in my portlet.
I tried adding the hibernate3.jar explicitly in my WEB-INF/lib folder and also tried adding through liferay-plugin-package.properties to include the dependency jar which liferay uses.
But I get the same error, saying org.hibernate.HibernateException: Could not instantiate dialect class
BeanLocator not set for servlet context,
java.lang.ClassCastException: org.hibernate.dialect.MySQLDialect cannot be cast to org.hibernate.dialect.Dialect.
org.hibernate.HibernateException: Could not instantiate dialect class.
Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liferayHibernateSessionFactory' defined in ServletContext resource [/WEB-INF/classes/META-INF/hibernate-spring.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Could not instantiate dialect class.
I am not able to go forward until I get rid of this problem, please I need help, thanks in advance...
MICHAIL MOUDATSOS, módosítva 11 év-val korábban
RE: java.lang.ClassCastException: org.hibernate.dialect.MySQLDialect cannot
Regular Member Bejegyzések: 110 Csatlakozás dátuma: 2011.10.04. Legújabb bejegyzések
I think ou should first mention what kind of frameworks you use, i.e. "Do you use plain Hibernate?", "Are you using Spring?". This will help people understand your situation better. E.g., for the plain hibernate case, I have tried that in the past and there was no problem. I just had to add hibernate and all of its dependencies to my lib folder (and of course initialize it properly ).
Sanjeev Kumar, módosítva 11 év-val korábban
RE: java.lang.ClassCastException: org.hibernate.dialect.MySQLDialect cannot
New Member Bejegyzések: 6 Csatlakozás dátuma: 2013.02.27. Legújabb bejegyzések
But the error occurs when the hibernate jar is added in lib folder, not while implementing the API's which are built on hibernate.
MICHAIL MOUDATSOS, módosítva 11 év-val korábban
RE: java.lang.ClassCastException: org.hibernate.dialect.MySQLDialect cannot
Regular Member Bejegyzések: 110 Csatlakozás dátuma: 2011.10.04. Legújabb bejegyzésekSanjeev Kumar:
But the error occurs when the hibernate jar is added in lib folder, not while implementing the API's which are built on hibernate.So, you mean you haven't written a single line of code, not even a configuration file, anything?
Sanjeev Kumar, módosítva 11 év-val korábban
RE: java.lang.ClassCastException: org.hibernate.dialect.MySQLDialect cannot
New Member Bejegyzések: 6 Csatlakozás dátuma: 2013.02.27. Legújabb bejegyzések
we are connecting to different (application) Database using hibernate.
We created API to connect to the other application database. The API is using hibernate to connect the other application.
We created API to connect to the other application database. The API is using hibernate to connect the other application.
Sahil Shaikh, módosítva 9 év-val korábban
RE: java.lang.ClassCastException: org.hibernate.dialect.MySQLDialect cannot
New Member Bejegyzés: 1 Csatlakozás dátuma: 2014.05.21. Legújabb bejegyzések
Does anyone one have any success with hibernate?
Di He, módosítva 9 év-val korábban
RE: java.lang.ClassCastException: org.hibernate.dialect.MySQLDialect cannot
New Member Bejegyzések: 13 Csatlakozás dátuma: 2008.01.28. Legújabb bejegyzések
I started a liferay6.2.2 service builder portlet by using the eclipselink 2.5.1 and JPA 2.1 to get data from external database, my service builder portlet also have tables created by service.xml. I tested the service builder portlet in my LR6.2.2 tomcat server and it works well.
I then deployed my service builder portlet on LR6.2.2 Glassfish 3 server, I got an error says it can't created the EntityManagerFactory from the persistence unit defined in persistence.xml. So I tried using hibernate JPA to replace the eclipselink, then I ran into the same issue you guys are talking about.
I think glassfish 3 server has older version of eclipselink installed. I am going to try to upgrade it to 2.5.1 and see my portlet will work or not.
If you are running liferay on tomcat, you could try what I did. Good luck.
I then deployed my service builder portlet on LR6.2.2 Glassfish 3 server, I got an error says it can't created the EntityManagerFactory from the persistence unit defined in persistence.xml. So I tried using hibernate JPA to replace the eclipselink, then I ran into the same issue you guys are talking about.
I think glassfish 3 server has older version of eclipselink installed. I am going to try to upgrade it to 2.5.1 and see my portlet will work or not.
If you are running liferay on tomcat, you could try what I did. Good luck.
David H Nebinger, módosítva 11 év-val korábban
RE: java.lang.ClassCastException: org.hibernate.dialect.MySQLDialect cannot
Liferay Legend Bejegyzések: 14916 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
You're encountering class loader issues...
Basically you've got your own hibernate jar loaded in your class loader, but the liferayHibernateSessionFactory instance is defined in Liferay's class loader. In Liferay's class loader, it has already created the connection and established the dialect to use, in this case a MySQLDialect.
So you're trying to reuse the connection from their class loader in your own class loader and, of course, although both have a Dialect interface defined, they are completely different class and cannot be cast around.
Basically you've got your own hibernate jar loaded in your class loader, but the liferayHibernateSessionFactory instance is defined in Liferay's class loader. In Liferay's class loader, it has already created the connection and established the dialect to use, in this case a MySQLDialect.
So you're trying to reuse the connection from their class loader in your own class loader and, of course, although both have a Dialect interface defined, they are completely different class and cannot be cast around.
Suresh Yadagiri, módosítva 8 év-val korábban
RE: java.lang.ClassCastException: org.hibernate.dialect.MySQLDialect cannot
Junior Member Bejegyzések: 29 Csatlakozás dátuma: 2014.03.24. Legújabb bejegyzések
I saw the hiberante dialect class cast exception when i deploy audit plugin in Liferay 6.1 + Jboss 5.1; The exception was
ERROR [HDScanner][ContextLoader:227] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liferayHibernateSessionFactory' defined in ServletContext resource [/WEB-INF/classes/META-INF/hibernate-spring.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Could not instantiate dialect class
Caused by: org.hibernate.HibernateException: Could not instantiate dialect class
at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:162)
at org.hibernate.dialect.resolver.DialectFactory.buildDialect(DialectFactory.java:99)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:117)
Caused by: java.lang.ClassCastException: org.hibernate.dialect.Oracle10gDialect cannot be cast to org.hibernate.dialect.Dialect
at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:156)
I am able to resolve this by copying jboss-classloading.xml in audit-portlet.war/WEB-INF
jboss-classloading.xml:
<classloading xmlns="urn:jboss:classloading:1.0"
parent-first="false"
domain="LiferayDomain"
export-all="NON_EMPTY"
import-all="true">
</classloading>
ERROR [HDScanner][ContextLoader:227] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liferayHibernateSessionFactory' defined in ServletContext resource [/WEB-INF/classes/META-INF/hibernate-spring.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Could not instantiate dialect class
Caused by: org.hibernate.HibernateException: Could not instantiate dialect class
at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:162)
at org.hibernate.dialect.resolver.DialectFactory.buildDialect(DialectFactory.java:99)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:117)
Caused by: java.lang.ClassCastException: org.hibernate.dialect.Oracle10gDialect cannot be cast to org.hibernate.dialect.Dialect
at org.hibernate.dialect.resolver.DialectFactory.constructDialect(DialectFactory.java:156)
I am able to resolve this by copying jboss-classloading.xml in audit-portlet.war/WEB-INF
jboss-classloading.xml:
<classloading xmlns="urn:jboss:classloading:1.0"
parent-first="false"
domain="LiferayDomain"
export-all="NON_EMPTY"
import-all="true">
</classloading>