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 package apache.commons not exists Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "package apache.commons not exists" Watch "package apache.commons not exists" New topic
Author

package apache.commons not exists

deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.*;

but when i compile this file it says
package org.apache.commons.fileupload does not exist

classpath=C:\Program Files\Java\jdk1.6.0\lib\tools.jar;C:\Program Files\Java\jre1.6.0\lib\j2ee.jar;F:\SOFT\Tomcat 5.0\common\lib\servlet-api.jar;F:\SOFT\Tomcat 5.0\common\lib\commons-fileupload-1.0.jar;


commons-fileupload-1.0.jar file is in two folders
1. F:\SOFT\Tomcat 5.0\common\lib
2. C:\Program Files\Java\jre1.6.0\lib\ext
arriesh chellu
Greenhorn

Joined: Jan 18, 2010
Posts: 7
I think since the package exists in both the folders the folder that is first accessed by the compiler is that of the Windows program files or in your given list the second one
so what the compiler does is that it first finds in this package it fails to get the required pacakage
For the solution just remove the package from the program files and see what happens.....
deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
means remove commons- fileupload-1.0.jar file from C:\Program Files\Java\jre1.6.0\lib\ext folder
are you telling this ?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Remove it from both places and deploy it with your application.
Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
You need to have this jar in WEB-INF/lib of your webapp once your servlet gets complied.

However for compiling your servlet you just need to have this jar in your classpath.

Try explicitly putting this jar in your classpath while compliling

e.g java -cp %CLASSPATH%;F:\SOFT\Tomcat 5.0\common\lib\commons-fileupload-1.0.jar;. <your servlet class name>
deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
okay i did it what you said
now it shows
org.apache.commons.fileupload.servlet
org.apache.commons.fileupload.disk
packages not exists
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

"It" what? Did you change your compilation classpath?
deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
yes
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3164
    
  47

Where did you get that commons-fileupload-1.0.jar file from? Version 1.0 was released in 2003.
My sense is you should try downloading the latest version of Commons Upload from the Apache site.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
now it compile
but at run in tomcat it shows
java.lang.NoClassDefFoundError: javax/servlet/ServletInputStream
insertimage.doPost(insertimage.java:17)
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What libraries are you deploying? What libraries did you remove from the Tomcat lib directories? If you're getting that message in Tomcat you've done something very wrong. Right now it just seems like you're trying things at random.
deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
in my app. web-inf/lib folder
servlet-api.jar and commons-filrupload-1.2.1.jar both files are saved
and i saw servlet-api.jar it contains servletinputstream class
yet the error will show?
i don't understand why?
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 537

check in tomcats lib directory, whether servlet-api.jar is there or not..
deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
it is there
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 537

remove servlet-api.jar from your applications web-inf lib folder
deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
no effect
same error occur
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 537

Then, I am not able to figure out the cause, can you redeploy your whole application, by removing servlet-api.jar from your applications web-inf lib folder and see.. Also, restart the tomcat server before redeploying it..
Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
I would suggest you unpack the zip downloaded again from tomcat site and deploy your application in it. While during all this trial and error some jar file must have got deleted.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

David Newton wrote:What libraries are you deploying? What libraries did you remove from the Tomcat lib directories?

You're only deploying two libraries with your application?

In any case, you *must* not deploy any JEE API jars with your application. It'd be quicker to just answer the question(s), but okay. At this point it probably *would* be quicker for you to reinstall Tomcat.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: package apache.commons not exists