java.lang.ClassNotFoundException

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajay13785
    New Member
    • Oct 2013
    • 10

    java.lang.ClassNotFoundException

    I have added ojdbc14.jar, classes12.jar in my WEB-INF lib folder but its showing the java.lang.Class NotFoundExcepti on:.

    I have also added the jar files by right click on the project folthder and from build path add external jars. I have addedd all the jars but dont know why this error is showing up

    ERROR:

    Code:
    	at java.lang.Thread.run(Unknown Source)
    java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
    	at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:128)
    	at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
    	at java.lang.Class.forName0(Native Method)
    	at java.lang.Class.forName(Unknown Source)
    	at org.apache.jsp.insert1_jsp._jspService(insert1_jsp.java:74)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
    	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
    	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
    	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
    	at redirectServlet.doPost(redirectServlet.java:67)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    	at java.lang.Thread.run(Unknown Source)

    My Java Code:

    Code:
    <%@ page  language="java"  import="java.sql.*" %>
    <%@ page import = "java.io.*"%>
    
    <% 
    
          
           String appl=request.getParameter("app");
           String sel=request.getParameter("second");
           String url= request.getParameter("link");
                
          
    
    %>
    
    <% 
    
    try{
    	 String sql ="INSERT into TEST_LINKS (ID,APPLICATION,ENTITY,URL) VALUES(TEST_LI.nextval,'"+appl+"','"+sel+"','"+url+"')";
    	 Class.forName("oracle.jdbc.OracleDriver");
    
    	 Connection con = DriverManager.getConnection("jdbc:oracle:thin:SCOTT/tiger@myhost:1521:orcl");
    	 int action = con.createStatement().executeUpdate(sql);
    	 con.setAutoCommit(true);
    	
    
    	    if(action>=1  ){
          	 out.println("Data inserted"); 
          	 
           } else{
          	 out.println("Data not inserted"); 
           }
       }
    
    catch(Exception e){
    		e.printStackTrace();
    	}
            %>
  • ajay13785
    New Member
    • Oct 2013
    • 10

    #2
    I resolved the problem, I putted jar file in web content dir and thought it is in wen-inf lib folder, and also my host name was incorrect.
    Thanks anyways

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Don't write database connection logic in a JSP. Write it in a normal Java class where you can test it without starting a server and call it from a servlet. Use JSPs for presentation logic only.

      Comment

      Working...