Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DataSource class not found

 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting a class not found exception when compiling a servlet, on a DataSource object. Specifically on this line:

Ihave imported the following packages:
import java.io.*;
import java.util.*;
import java.util.regex.*;
import java.sql.*;
import java.text.*;
import javax.mail.*;
import javax.activation.*;
import javax.mail.internet.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.*;
import javax.naming.Context;
import javax.naming.InitialContext;
What package do I need?
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahh it is the little errors that cause some much trouble.

DataSource is defined in the
javax.activation and javax.sql packages.
Craig.
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest you re-define your class to:

or
 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have imported the javax.sql.* and javax.activation.* packages.
Just in case I tried importing javax.sql and javax.activation, but got the javax/sql and javax/activation cannot find type errors.
My class path contains following .jars
rt.jar, tools.jar, servlet.jar
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, okay. I guess I misunderstood your error message.
The packages below are found in a jar file called j2ee.jar which can be accessed through Java's Enterprise Edition(J2EE) which you can download from Sun's website. I can't remember the exact path but it is something like %j2ee_home%\lib\j2ee.jar. The serlvet.jar file contains packages relating to jsp/servlet.


I hope this helps.
 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I noticed activation.jar was not in my class path and also made the suggested changes and it works now thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic