0

hi I am having a project that runs perfectly over Netbeans without any problem in the syntax or connectivity bUt wHen i try to run the same jsp pages in tomcat it generates error. It is possible that the error is in the directory structure .

I had placed the jsp pages,html pages, css, images folder,web-inf folder and the .js files all in one folder in the webapps\login. When I run the index.html page it runs bUt when I click on the login page link it shows the following exception.

Can someone help me out?

HTTP Status 500 - message description The server encountered an internal error () that prevented it from fulfilling this request.

exception:

javax.servlet.ServletException: com.mysql.jdbc.Driver
        org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
        org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
        org.apache.jsp.login_jsp._jspService(org.apache.jsp.login_jsp:907)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause 

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
        org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1332)
        org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1181)
        org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:150)
        org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:71)
        java.lang.Class.forName0(Native Method)
        java.lang.Class.forName(Unknown Source)
        org.apache.jsp.login_jsp._jspService(org.apache.jsp.login_jsp:445)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
MaVRoSCy
  • 17,747
  • 15
  • 82
  • 125
  • Try moving the WEB-INF folder to webapps/. I do not know if it is possible to have it in a webapps subfolder, but this is where it is usally located. – f_puras Aug 30 '12 at 07:45
  • @f_puras: a `WEB-INF` folders inside `webapps` will create a new context with the name `WEB-INF`. This is definitely not what he wants. Usually, the `WEB-INF` is located within the context directory (e.g. `webapps//WEB-INF`) – tbl Aug 30 '12 at 07:52
  • @tbk: Oh, right! I was thinking of the directory structure in an Eclipse project. When deployed, the OP's settings sound sensible. – f_puras Aug 30 '12 at 08:02

2 Answers2

0

It seems that com.mysql.jdbc.Driver is not int your in your classpath. You have to add all the needed jars (in this case this should be mysql-connector-java.jar, but there should be more) to:

webapps/app-name/WEB-INF/lib/

where app-name in your case is login.

Hardik Mishra
  • 14,779
  • 9
  • 61
  • 96
melopsitaco
  • 176
  • 4
  • i have placed teh mysql-connector-java.jar file in C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib – user1635172 Aug 30 '12 at 07:39
0

Usually you would generate a WAR (web archive) file that contains your code base as well as all dependendent libraries and deploy that into tomcat (e.g. by copying into the webapp folder). From what I remember, NB generates the WAR file already (stackoverflow: How can I create a war file of my project in NetBeans?) and stores it in the dist/ folder of your project. Check if you can find a file that is called <projectname>.war inside that folder and copy it to your webapp directory.

Community
  • 1
  • 1
tbl
  • 771
  • 3
  • 11
  • ys m having that war file where to place that ?directly in the webapps directory or inside the login folder webapps\login\login.war – user1635172 Aug 30 '12 at 07:41
  • Put it directly into `webapps` folder, but move your existing `login` folder out of the way first, tomcat will most likely create a new one. – tbl Aug 30 '12 at 07:49
  • ys its working bt nw the format for the jsp pages is completely scattered – user1635172 Aug 30 '12 at 08:23
  • Scattered? That sounds like a different problem to me. Feel free to ask another question. – tbl Aug 30 '12 at 08:25
  • actually the formatting of the jsp page is nt the way it has to bee seriously vry depressed plz help me – user1635172 Aug 30 '12 at 08:32