title: HTTP Status 500 - Error instantiating servlet class jav.com.controller.conrollerServletLogin
body: <p>I am developing a simple login form but got error while running one Tomcat server. </p>
  
  <p>Below is the stack trace :</p>
  
  <pre><code>java.lang.NullPointerException
  at java.util.Properties$LineReader.readLine(Unknown Source)
  at java.util.Properties.load0(Unknown Source)
  at java.util.Properties.load(Unknown Source)
  at jav.com.utility.Utility.getConnection(Utility.java:23)
  at jav.com.dao.daoLogin.&lt;init&gt;(daoLogin.java:12)
  at jav.com.controller.conrollerServletLogin.&lt;init&gt;(conrollerServletLogin.java:23)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  at java.lang.reflect.Constructor.newInstance(Unknown Source)
  at java.lang.Class.newInstance(Unknown Source)
  </code></pre>
  
  <p>db.properties file</p>
  
  <pre><code>driver=com.mysql.jdbc.Driver
  url=jdbc:mysql://localhost:3306/pra
  user=root
  password=root
  </code></pre>
  
  <p>Utility.java</p>
  
  <pre><code>package jav.com.utility;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.io.InputStream;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.SQLException;
  import java.util.Properties;
  
  
  public class Utility {
   private static Connection connection;
   public static Connection getConnection() {
    if (connection != null) {
     return connection;
    } else {
     try {
      Properties prop = new Properties();
      // file input output this code read db.properties file from     location src
      InputStream inputStream = Utility.class.getClassLoader().getResourceAsStream("/db.properties");
      prop.load(inputStream);
      // String driver="com.mysql.jdbc.Driver";
      String driver = prop.getProperty("driver");
      String url = prop.getProperty("url");
      String user = prop.getProperty("user");
      String password = prop.getProperty("password");
      Class.forName(driver);
      connection = DriverManager.getConnection(url, user, password);
     } catch (ClassNotFoundException e) {
  
  
      e.printStackTrace();
     } catch (SQLException e) {
  
      e.printStackTrace();
     } catch (FileNotFoundException e) {
  
      e.printStackTrace();
     }
    }
   }
  }
  </code></pre>
  
  <p>I tried to solve but I am getting error like 404 and 500 .</p>