title: Unable to provide CLASSPATH in docker?
body: <p><strong>Problem:</strong></p>
  
  <p>I am facing a <strong>classNotFoundException</strong> when i try to connect jsp container to mysql container by running an web application(.html, .jsp files) in browser.</p>
  
  <p><strong>Note:</strong> It is executing as expected in Eclipse</p>
  
  <p><strong>Description:</strong></p>
  
  <p>I have created an "mysqlrep" image using below dockerfile and i am using this image name in docker-compose.</p>
  
  <pre><code>from ubuntu:14.04
  run apt-get update
  run apt-get install mysql-server -y
  run apt-get install curl -y
  RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
  env set MYSQL_ROOT_PASSWORD= root
  add my.sql /var/lib/mysql
  run bash -c "/etc/init.d/mysql start &amp;&amp; mysql -u root &lt;/var/lib/mysql/my.sql"
  </code></pre>
  
  <p>In above dockerfile, i created database using my.sql file as shown below</p>
  
  <pre><code>CREATE SCHEMA softwareag;
  use softwareag;
  create table users(
    username varchar(10) primary key,
    pwd varchar(10),
    fname varchar(10),
    lname varchar(10), 
    email varchar(30)
  );
  insert into users values('shashank','shas','shashank','g','sg@gmail.com');
  
  CREATE USER "root"@"%" IDENTIFIED BY "root";
  GRANT ALL PRIVILEGES ON *.* TO "root"@"%";
  FLUSH PRIVILEGES;
  </code></pre>
  
  <p>Below is my docker-compose.yml where i am linking mysql container and jsp container</p>
  
  <pre><code>mysql:
     image: mysqlrep1
     container_name: mysqlcompose1
     environment:
         - MYSQL_ROOT_PASSWORD= root
     ports:
         - "0.0.0.0:3306:3306"
     command: bash -c "/etc/init.d/mysql start &amp;&amp; cd /var/lib/mysql &amp;&amp; mysql -u root &amp;&amp; sleep 50"
  
  jsp:
     build: .
     container_name: jspcompose1
     links:
       - mysql
     cap_add:
       - SYS_PTRACE
     ports:
       - "8080:8080"
     command: bash -c "/etc/init.d/tomcat7 start &amp;&amp;  ping 127.0.0.1 -c 100"
  </code></pre>
  
  <p>i am creating an jsp container in docker-compose using dockerfile. Inside dockerfile, using ubuntu as the base image and installing jdk, tomcat7 on top of it and mounted .html, .jsp files inside /var/lib/tomcat7/webapps/ROOT directory of jsp container.</p>
  
  <p><strong>Note:</strong> i also tried many syntax to set the classpath for mysql .jar file after adding mysql .jar to lib directories inside dockerfile but it doesnt solve my issue.</p>
  
  <p>After running docker-compose up, at the same time i am accessing it in browser through <a href="http://system-ip-address:8080/index.html" rel="nofollow">http://system-ip-address:8080/index.html</a>.</p>
  
  <p><strong>Note:</strong> In index .html, user click submit button after he enters his username &amp; password, it redirects to signIn.jsp page to verify username/password by connecting to mysql database.</p>
  
  <p>It works but when user click submit, it get redirected to signIn.jsp where it throws ClassNotFoundException.</p>
  
  <p>This is my signIn.jsp file</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
      &lt;title&gt;Sign In&lt;/title&gt;
    &lt;/head&gt;
  &lt;body&gt;
  &lt;%@ page import="java.sql.*"%&gt;
  &lt;%@ page import="javax.sql.*"%&gt;
  &lt;%@ page isErrorPage="true" %&gt;
  
  &lt;%
   try{
    String userid=request.getParameter("usr"); 
    session.setAttribute("username",userid); 
    String pwd=request.getParameter("pwd");
     Class.forName("com.mysql.jdbc.Driver"); 
     java.sql.Connection con =  DriverManager.getConnection("jdbc:mysql://mysql:3306/softwareag","root","root"); 
     Statement st= con.createStatement(); 
     ResultSet rs=st.executeQuery("select * from users where username='"+userid+"'");
     if(rs.next()) 
     { 
       if(rs.getString(2).equals(pwd)) 
       { 
       response.sendRedirect("http://www.softwareag.com/in/");
       }
     }else
     {
          response.sendRedirect("http://localhost:8080/index.html");
     }
  }
  catch(Exception e)
  {
        out.print("Exception:"+e);
  }
   %&gt;
   &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <p><strong>Can you suggest the solution to make it work ?</strong></p>
  
  <p><strong>How and where to provide classpath for mysql-connector-java-5.1.5-bin.jar file ?</strong></p>