Error: org.apache.jasper.JasperException: Unable to compile class for JSP:

Hello;

One of my Apache Tomcat accounts is receiving this error.  

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 6 in the generated java file
Only a type can be imported. com.microsoft.jdbc.sqlserver.SQLServerDriver resolves to a package

The customer has been stable for over a year then on Sunday 4/11 they started receiving this error message.

I would appreciate if you can help me solve this problem quickly.

If 500 points is not enough, please let me know what the resolution is worth and I will adjust the points.

Thank-you
kwwellsAsked:
Who is Participating?
 
VenabiliConnect With a Mentor Commented:
What changed on the 11th? Looks like the Microsoft driver had disappeared somewhere from the classpath

That's essentially a ClassNotFoundExcpetion - except that it gets thrown a bit strangely.
0
 
kwwellsAuthor Commented:
Hi;  thanks for getting back top me.

I cannot find anything in their WEB_INF that has changes in more than a year.

The website admin just  noticed this on 4/11, it is quite possible that this has been around for a while and they just discovered it.

There was a tomcat upgrade on 3/22/2010, is it possible that because of the upgrade, the com.microsoft.jdbc.sqlserver.SQLServerDriver needs to be recompiled or the classpath reset?
0
 
VenabiliConnect With a Mentor Commented:
Yeah, depending on how they upgraded - can you just verify that the driver jar(s) is/are where it is supposed to be.

It probably does not need a new jar  but it is possible that either a file is no more there or depending on how they did the classpath, it might not get included anymore.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
kwwellsAuthor Commented:

Yes there is a JAR in the WEB-INF/lib folder. the jar is mssqlserver.jar

Whe I do a echo %classpath is seems that there is no classpath for the user, there is only a system classpath. I know that there used to be a user classpath but it seems to have gone away

The CLASSPATH is pointing at the system level
root@server101 [/home/ucom/www/WEB-INF]# echo $CLASSPATH
.:/usr/local/jdk/lib/classes.zip

Question how do I set the clase path for the user?

Also the following is a dump of the error.

Here is a dump of the error

SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP:


An error occurred at line: 6 in the generated java file
Only a type can be imported. com.microsoft.jdbc.sqlserver.SQLServerDriver resolves to a package

Stacktrace:
      at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93)
      at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
      at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:451)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:319)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
      at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
      at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
      at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:775)
      at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:704)
      at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:897)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
      at java.lang.Thread.run(Thread.java:619)
[Loaded org.apache.coyote.Constants from file:/usr/local/jakarta/apache-tomcat-5.5.28/server/lib/tomcat-coyote.jar]
[Loaded org.apache.catalina.connector.Constants from file:/usr/local/jakarta/apache-tomcat-5.5.28/server/lib/catalina.jar]
0
 
VenabiliConnect With a Mentor Commented:
The classpath is built from the server basically so echo won't help.
yeah - it is a ClassNotFoundException - the stacktrace just confirms it but it was clear from the message.

What version of MSSQL are you running? In some you need 2 more jars (http://support.microsoft.com/kb/313100 for example)

Can you check what CATALINA_OPTS and JAVA_OPTS are set to?
0
 
kwwellsAuthor Commented:
Hi

I have MySQL Server installed no MSSQL.

The MySQL Version is shown below;

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 79716
Server version: 5.0.89-community MySQL Community Edition (GPL)

I am having difficulty finding the values of CATALINA_OPTS and JAVA_OPTS? any ideas

0
 
VenabiliCommented:
Hold on a second: If you are going against Mysql why are you loading  the MSSQL driver?
0
 
kwwellsAuthor Commented:
I am confused, i'll tell you why;

The entire application is coded to use <%@ page import="com.microsoft.jdbc.sqlserver.SQLServerDriver"%>

Which was working fine until the TOMCAT upgrade from 5.5.25 to 5.5.28.

How is it possible that this driver would work wit MySQL



0
 
VenabiliCommented:
It's not... so I am even more confused than you are at this point :)

Can you find the code where you actually open a connection? Maybe this import is simply not needed and not used?
0
 
kwwellsAuthor Commented:
Here is the connect part

<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="com.microsoft.jdbc.sqlserver.SQLServerDriver"%>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*" %>
<%@ include file="conn.jsp"%>
<jsp:include page="top.htm" />
<jsp:include page="menu.htm"/>

<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
0
 
VenabiliCommented:
That's just the imports... can you show the actual code that does the connections.
maybe conn.jsp?
and this code definitely looks like a connection ot MSSQL, not to MySQL
0
 
kwwellsAuthor Commented:
Now I understabd why this is happening.

They are using a remote server?


<%@ page contentType="text/html;charset=GBK" language="java"%>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.io.*" %>
<%
                  Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
                  String  url="jdbc:oracle:thin:@10.10.10.10:db1";
                  String  user="user";    
                  String  password="pass";
                  Connection  conn=  DriverManager.getConnection(url,user,password);
%>
0
 
VenabiliConnect With a Mentor Commented:
Yes, that is a remote server (unless if that IP is yours?) But that is a connection to an Oracle server

So back to the question - why do you need the MSSQL driver if you are using Oracle?

Let's try something - open the JSP, remove the import of the MSSQL driver and let's see what happens. Unless if you have a conneciton to MSSQL somewhere as well.
0
 
kwwellsAuthor Commented:
I removed that import and ran the JSP again anf now it appears to be showing the real error; But I do not know why they set it up this way.

Here is the error
Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Exception in JSP: /conn.jsp:6

3: <%@ page import="javax.sql.*" %>
4: <%@ page import="java.io.*" %>
5: <%
6:                   Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
7:                   String  url="jdbc:oracle:thin:@10.10.10.10:1521:db1";
8:                   String  user="user";    
9:                   String  password="pass";


Stacktrace:
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


root cause

javax.servlet.ServletException: oracle.jdbc.driver.OracleDriver
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
      org.apache.jsp.restaurants_jsp._jspService(restaurants_jsp.java:523)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


root cause

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232)
      org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:125)
      org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)
      java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
      java.lang.Class.forName0(Native Method)
      java.lang.Class.forName(Class.java:169)
      org.apache.jsp.restaurants_jsp._jspService(restaurants_jsp.java:62)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.28 logs.

0
 
VenabiliConnect With a Mentor Commented:
Same problem but now for the correct DB - now you just need to get the jar  with the proper drivers :)
Download it from http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html, restart Tomcat (to make sure it picks it up) and let's see how it goes.
0
 
VenabiliCommented:
OK - who did the code? Because the things here really get stranger and stranger :) And if this had worked before the upgrade then I suspect the upgrade lost and/or moved some jars about.
0
 
kwwellsAuthor Commented:
Ok thanks for all the help;

I will install the new driver and give it a try and I will let you know the results, hopefully this evening.
0
 
VenabiliConnect With a Mentor Commented:
:) Make sure you download the correct one (you need to find out what the Oracle version is). What a mess - good luck with it - I should be around (or if not, I will see the notifs later on) if you need more help.
0
 
kwwellsAuthor Commented:
This is a china travel website and that is where it was coded.

I do not have  a clue how I can determine the ODBC version I need to download,  I will need to get that information from them.

Is it ok if we keep this open until it is resolved?

Ken
0
 
VenabiliCommented:
Absolutely - no rush to close it before it is solved. I am a bit skeptical that this worked before the upgrade but who knows - if all jars are in place, it will work with all unneeded imports...
0
 
kwwellsAuthor Commented:
Hi;

Just a heads up.

I asked the techs for that site to install the correct Oracle JDBC driver and correct the JSP that contain the MSSQL ODBC.

Once they complete that if everything works I will close the question and will indicate how please I am with the solution you provided, if there are still problems, I will ask you to help me resolve this.

by the way it appears that the classpath is empty.

What is the proper procedure to set the class path for both the server and the user (who needs a class path of their own). If you could answer that for me that will help me fix the proble I am going to run into when they install the new JDBC.  Thanks for the help.

Ken
0
 
VenabiliCommented:
Which is the tomcat version?
Basically you do not need to setup the system classpath (for the user or anyone else) as Tomcat won't use it anyway.

As long as you keep the jars in the designated folders, tomcat will set them in the classpath when it starts. if you need something additional, just open the script that starts tomcat and add it there.
0
 
kwwellsAuthor Commented:
Thank-you very much for all your help.
Since it may be a while before the customer gets back to me, I will close this question.

If there are more issues, I will create a new question.

Again thank-you for being there when I needed help, you guy are great.

Regards

Ken
0
 
VenabiliCommented:
:) If you want to connect a new and an old question, you can use "ask related question" option after you close it. That will notify me that you created a new one. Although I keep an eye on the zone and will see it anyway

Not that we do not have a lot of other experts here but I will be happy to keep helping if you have more issues.

Good luck with this application :)
0
 
kwwellsAuthor Commented:
Hi Again;

The customer installed the correct JDBC driver and we are now receiving this error.

/home/ucom/www/WEB-INF/lib
   mysql-connector-java-5.1.10-bin.jar    
   ojdbc14.jar



type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: oracle.jdbc.driver.OracleDriver
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


root cause

javax.servlet.ServletException: oracle.jdbc.driver.OracleDriver
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
      org.apache.jsp.restaurants_jsp._jspService(restaurants_jsp.java:523)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


root cause

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232)
      org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:125)
      org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)
      java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
      java.lang.Class.forName0(Native Method)
      java.lang.Class.forName(Class.java:169)
      org.apache.jsp.restaurants_jsp._jspService(restaurants_jsp.java:62)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.28 logs.

Can you help

Thanks

Ken
0
 
kwwellsAuthor Commented:
Venabili was very professional and helpful
0
 
VenabiliCommented:
It cannot find the Oracle driver in the class path.
0
 
kwwellsAuthor Commented:
Hi;

Yes I figured that out and added the driver to the shared library yesterday after I sent this question.

As soon as I did that it worked.

Thanks so much for all the help.

I now realize that I should have offered more points than I offered for this problem, next time I will offer more points.

Rgeards

Ken
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.