• Post Reply Bookmark Topic Watch Topic
  • New Topic

cannot access javax.servlet.http.HttpServlet error

 
Neeraj jain
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am deploying a servlet in Weblogic and when i am setting the classpath of jdk1.4 i am getting an error in compilation

MyServlet1.java:5: cannot access javax.servlet.http.HttpServlet
bad class file: C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar(javax/servlet/http/HttpServlet.class)
class file has wrong version 49.0, should be 48.0
Please remove or make sure it appears in the correct subdirectory of the classpath.

and when i am doing the compilation with the command

javac -source 1.4 -d WEB-INF\classes MyServlet1.java

its working absulutely fine

 
william blake
Greenhorn
Posts: 9
Chrome Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is a lot differentce between jdk 1.4 to jdk 1.5
It is recommended to use jdk 1.5
 
Wayan Saryada
Ranch Hand
Posts: 105
IntelliJ IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that because you are using the different version of JDK for compiling and for running your application server. Make sure that is you are using JDK 1.4 for your application server you also compile your servlet classes using JDK 1.4, or the other way around update your application server to use the later JDK.
 
Neeraj jain
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but the servlet-api.jar is already compiled with jdk1.5 so how can i recompile it with jdk 1.4 and use it in my program
 
Neeraj jain
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ I Wayan Saryada i hav compiled my program through jdk 1.4 and i am using the weblogic 8.1 which supports only the classfiles compiled with jdk 1.4 so i use -source 1.4 but the servlet api is provided by the Apache foundation which is not compiled from jdk 1.5 not from jdk 1.4 so i am getting this error but now please tell me how to resolve this problem
 
Wayan Saryada
Ranch Hand
Posts: 105
IntelliJ IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess weblogic should have their own version of servlet API. So If you create a war file just don't include the servlet-api.jar with it so it can use the same version used by weblogic app server.
 
Neeraj jain
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ I Wayan Saryada thanks this is what i actually needed
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!