sumit badaya sumit badaya - 1 year ago 89
MySQL Question

How to set Hibernate MySQL Connection in Openshift Tomcat 7 (JBOSS EWS 2.0)?

I'm developing Java based web application using spring hibernate and am trying out OpenShift to deploy my application. But I am facing troubles in configuring my application for the MySQL connector. I have included mysql-connector in my Maven dependency.

Below is my maven's

file's mysql dependency code:


And here is my servlet-xml code:

<beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<beans:property name="driverClassName" value="com.mysql.jdbc.Driver" />
<beans:property name="url" value="jdbc:mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/jbossews" />
<beans:property name="username" value="${OPENSHIFT_MYSQL_DB_USERNAME}" />
<beans:property name="password" value="${OPENSHIFT_MYSQL_DB_PASSWORD}" />

But when I deploy this to my openshift account and hit the address of my controller, it shows the below error:

HTTP Status 500 - Request processing failed; nested exception is
Could not open Hibernate Session for transaction; nested exception is
org.hibernate.exception.GenericJDBCException: Could not open

I must be misconfiguring my MySQL stuff in xml file.

Answer Source

I got an answer:


these are the OpesnShift variables. you cant use them for configuration. They should be replaced by their real values which you have done for the first one.