Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Getting ClassNotFoundException error.

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    7
    My Mood
    Cheeky
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Getting ClassNotFoundException error.

    I am working in eclipse and using Jboss-server4.2. Even after adding external mysql-connector jar in build path I am getting the error classnotfoundexception. Even I have tried to place mysql-connector jar inside /web-inf/lib folder.
    My-Code looks like
    public class Auth extends HttpServlet {
    	private static final long serialVersionUID = 1L;
     
    	/**
    	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    	 */
     
    	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    		// TODO Auto-generated method stub
    		response.setContentType("text/HTML");
    		PrintWriter out = response.getWriter();
    		String uname = request.getParameter("uname");
    		String pass = request.getParameter("pass") ;
    		try{
    			Class.forName("com.mysql.jdbc.Driver");
    			   out.println("Driver Loaded");
     
    			Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/j2ee","root","root");
    				out.println("Connction Established");
     
    			PreparedStatement pr = con.prepareStatement("insert into user values(?,?)");
    			 pr.setString(1, uname);
    			 pr.setString(2, pass);
    			 int x = pr.executeUpdate();
    			 if(x>0)
    			 {
    				 out.println("Success");
    				 out.println(uname + " thanks!!");
    				 out.println("Your password: "+ pass);
    			 }
    			 else
    				 out.println("Failed");
     
     
    		}
    		catch(SQLException e){
    			out.println(e);
    		}
    		catch(ClassNotFoundException f){
    			out.println(f);
    		}
     
     
    	}
     
    }


  2. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    939
    Thanks
    6
    Thanked 202 Times in 178 Posts

    Default Re: Getting ClassNotFoundException error.

    Also at java-forums.org

  3. The Following User Says Thank You to pbrockway2 For This Useful Post:

    copeg (January 2nd, 2013)

  4. #3
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,103
    Thanks
    169
    Thanked 779 Times in 725 Posts
    Blog Entries
    5

    Default Re: Getting ClassNotFoundException error.

    Read the docs for the JBoss server you are using - you need to place external libraries in the appropriate location for them to be on the classpath (not sure about this version, but in other versions its the server/default/lib/ directory)

Similar Threads

  1. Getting ClassNotFoundException error.
    By kunalgaurav18 in forum JDBC & Databases
    Replies: 1
    Last Post: January 2nd, 2013, 07:46 AM
  2. glassfish ClassNotFoundException java.lang.ClassNotFoundException: ...
    By enginco in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: June 18th, 2012, 12:18 PM
  3. ClassNotFoundException (bit weird)
    By chronoz13 in forum Exceptions
    Replies: 1
    Last Post: April 26th, 2011, 02:15 AM
  4. [SOLVED] ClassNotFoundException - Please Help
    By igniteflow in forum Exceptions
    Replies: 11
    Last Post: October 3rd, 2010, 10:50 PM
  5. ClassNotFoundException ???
    By wolfgar in forum JDBC & Databases
    Replies: 2
    Last Post: November 20th, 2009, 12:35 PM

Tags for this Thread