Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package apache.commons not exists

 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove it from both places and deploy it with your application.
 
Amol Nayak
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"It" what? Did you change your compilation classpath?
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4681
331
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 671
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check in tomcats lib directory, whether servlet-api.jar is there or not..
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is there
 
Prasad Krishnegowda
Ranch Hand
Posts: 671
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
remove servlet-api.jar from your applications web-inf lib folder
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no effect
same error occur
 
Prasad Krishnegowda
Ranch Hand
Posts: 671
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic