Thursday, August 25, 2011

Error creating bean with name 'liferayTransactionManager' defined in class path resource [META-INF/hibernate-spring.xml]

Every once in a while when I install Liferay in different servers I get something like the below:
15:39:20,176 ERROR [ContextLoader:215] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'liferayTransactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liferayTransactionManager' defined in class path resource [META-INF/hibernate-spring.xml]: Cannot resolve reference to bean 'liferayHibernateSessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liferayHibernateSessionFactory' defined in class path resource [META-INF/hibernate-spring.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Hibernate Dialect must be explicitly set

This is an error that relates to a connectivity problem with your database. Be sure you see the *whole* stacktrace and look for a clue about connection/permission problems. Commonly you should be able to get it right if you follow these directions (Using MySQL here):

  1. Check what IP MySQL is listening to. Below it shows as listening in 192.168.0.6
    $ netstat -an|grep 3306
    tcp        0      0 192.168.0.6:3306        0.0.0.0:*               LISTEN     
    
  2. Try connecting with the same host and credentials Liferay is using from command line mysql client:
    $ mysql -u liferay -p -h 192.168.0.6
    Enter password: 
    ERROR 1130 (HY000): Host '192.168.0.6' is not allowed to connect to this MySQL server
    
  3. As the example above shows there is a permision problem so go ahead and correct it. In MySQL password must be specified per each granted user@host combination:
    $ mysql -u root -p
    ...
    mysql>  GRANT ALL ON lportal.* TO 'liferay'@'192.168.0.6';
    Query OK, 0 rows affected (0.00 sec)
    
  4. Review your /etc/hosts in the client to make sure if you are using a host it maps to the specified IP:
    $ vi /etc/hosts
    192.168.0.6  sqlHost
    

No comments:

Followers