Bug 960924 - The jbossews-1.0/jbossews-2.0 cartridge should provide JDBC drivers for mysql and postgresql database
The jbossews-1.0/jbossews-2.0 cartridge should provide JDBC drivers for mysql...
Status: CLOSED CURRENTRELEASE
Product: OpenShift Online
Classification: Red Hat
Component: Containers (Show other bugs)
2.x
Unspecified Other
low Severity medium
: ---
: ---
Assigned To: Dan Mace
libra bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-05-08 06:17 EDT by jizhao
Modified: 2015-05-14 19:18 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-07-22 11:15:15 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description jizhao 2013-05-08 06:17:38 EDT
Description of problem:
Create a jbossews-1.0(jbossews-2.0) app, and add mysql(postgresql) to it. Write a program to connect to the mysql(postgresql) database, but it fails due to "Cannot load JDBC driver class 'com.mysql.jdbc.Driver(org.postgresql.Driver)'". The jbossews-1.0/jbossews-2.0 cartridge should provide JDBC drivers, just like the jbossas-7 and jbosseap-6.0 cartridges. Both v1 and v2 cartridge have this bug.

Version-Release number of selected component (if applicable):
devenv_3195

How reproducible:
Always

Steps to Reproduce:
1.Create a jbossews-1.0(jbossews-2.0) app, and add mysql(postgresql) to it.
2.Use the following programs to connect to databases:
For MySQL: mysql.jsp
<%@ page contentType="text/plain" language="java" import="java.sql.*" %>
<%@ page import="javax.naming.*" %>
<%@ page import="java.io.*"  %>
<%@ page import="java.util.*"  %>
<%@ page import="java.text.*"  %>
<%@ page import="javax.naming.*" %>
<%@ page import="javax.sql.*" %>
<%
String version = request.getParameter("version");
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/MysqlDS");
Connection connection=ds.getConnection();
# Do some SQL queries
connection.close();
%>



For PostgreSQL: postgresql.jsp
<%@ page contentType="text/plain" language="java" import="java.sql.*" %>
<%@ page import="javax.naming.*" %>
<%@ page import="java.io.*"  %>
<%@ page import="java.util.*"  %>
<%@ page import="java.text.*"  %>
<%@ page import="javax.naming.*" %>
<%@ page import="javax.sql.*" %>
<%
String version = request.getParameter("version");
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/PostgreSQLDS");
Connection connection=ds.getConnection();
# Do some SQL queries
connection.close();
%>


3.Git push all the changes. Visit <app_url>/mysql.jsp or <app_url>/postgresql.jsp.
  
Actual results:
For MySQL:
javax.servlet.ServletException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'

For PostgreSQL:
javax.servlet.ServletException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.postgresql.Driver'

The user has to add mysql/postgresql connector to src/main/webapp/WEB-INF/lib/ manually in order to get the app working.

Expected results:
The jbossews-1.0/jbossews-2.0 cartridge should provide JDBC drivers for mysql and postgresql database, so that the user don't need to add the connectors manually.

Additional info:
Comment 1 jizhao 2013-06-25 01:57:07 EDT
Still not pulled in in devenv_3409. Will test again when new ami comes.
Comment 2 jizhao 2013-06-25 05:39:58 EDT
Move this bug back to ASSIGNED since no pull request about it is found.
Comment 3 Dan Mace 2013-07-08 15:53:02 EDT
https://github.com/openshift/origin-server/pull/3005

The fact that the drivers aren't present in the Tomcat library space is not a bug; Tomcat itself shouldn't provide specific JDBC drivers in the shared classloader. Application developers are responsible for specifying their own application dependencies (e.g. via a Maven POM) scoped to their application's classloader.

That said, the jbossews default template configurations include example/prefab JNDI datasource definitions for out-of-the-box integration with the MySQL and PostgreSQL cartridges which aren't usable until the user adds the driver of their choice to their application's dependency set.

What I've done is add both the MySQL and PostgreSQL JDBC drivers to the default/template pom.xml file to make it easier for new users to experiment (for example, if a user were to create a new jbossews application and then add the mysql-5.1 cartridge, they should be able to use the default MySQL JNDI datasource without requiring pon.xml modifications).

If/when the user replaces the example pom.xml (or switches to another build method entirely), it's the the user's responsibility to add a driver to their application's classpath one way or another.
Comment 4 openshift-github-bot 2013-07-08 23:11:28 EDT
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/1531de3d540e0af2095bcb8c2e82042c7fa268b0
Bug 960924: Add mysql and pg drivers to template pom.xml
Comment 5 Meng Bo 2013-07-09 06:20:49 EDT
According to devel's comment#3, the JDBC driver for mysql and postgresql has been added to pom.xml by default.

Move bug to verified.

Note You need to log in before you can comment on or make changes to this bug.