File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes DataSource class not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "DataSource class not found" Watch "DataSource class not found" New topic
Author

DataSource class not found

Kerry Wilson
Ranch Hand

Joined: Oct 29, 2003
Posts: 254
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?


http://www.goodercode.com
SCJP 1.4
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
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

Joined: Mar 19, 2002
Posts: 405
I would suggest you re-define your class to:

or
Kerry Wilson
Ranch Hand

Joined: Oct 29, 2003
Posts: 254
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

Joined: Mar 19, 2002
Posts: 405
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

Joined: Oct 29, 2003
Posts: 254
I noticed activation.jar was not in my class path and also made the suggested changes and it works now thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DataSource class not found
 
Similar Threads
Deploying Commons DBCP
InitialContext WebSphere 3.5.4
Disambiguating a class defined in multiple libs
Initial Context Problems, please help
Auditing for Oracle with EclipseLink JPA