0
votes

I have created a Tomcat 7 scaling app on openshift (using 2 small gears) which includes a Mysql cartridge and I have a WAR file that I deployed to it using git.

In order to handle Database transactions, I always implemented a ServletContextListener which annotates a datasource object like this:

@Resource(name="jdbc/MySQLDS")

private Datasource datasource;

then on the contextInitialized method:

public void contextInitialized(ServletContextEvent e)

ServletContext context=e.getServletContext();

context.setAttribute("ds",datasource);

which is then used by an Object I call DBHandler than manages all database transactions. This has worked fine with a single gear so far(without scaling) and I did not even need to change anything on the annotation because by default if you include a mysql cartridge, there will always be a resource called "jdbc/MySQLDS" in the .openshift/context.xml file in the git repo.

On the logs of the scaling app I detected this:

org.apache.catalina.core.StandardContext startInternal

SEVERE:Error listenerStart

SEVERE:Context [/MyApp] startup failed due to previous errors

How can I make this work on a scaling app and not have the Servlet Context failing?

1

1 Answers

0
votes

It seems like the Datasource was not the issue...The App could connect to Mysql Datasource fine after all and the problem was caused by the HaProxy Cartridge..Apparently if you do not serve any content at the root of the app the haproxy cartridge closes down causing a 503 error.

This answer helped me pinpoint the problem:

Openshift Layer4 connection, App Won't Start