954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

404 error

hi,
i'm trying to run a servlet code, but i get "HTTP Status 404 - Servlet Update2 is not available" error.
i checked code, its perfect, web.xml is correct.
but i did not find any .class files in my web-inf/classes directory.
how could i get servlet .class files in web-inf/classes dir?

waiting 4 answer,
BeanBoy :)

beanboy
Light Poster
44 posts since Aug 2009
Reputation Points: 10
Solved Threads: 1
 

What did you use for compiling Java files? IDE or command line?
And what did you do in order to compile them?

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

i used eclipse IDE. i just saved them and run the files. do i need to compile?. i'll try once,...and thanks 4 the reply

beanboy
Light Poster
44 posts since Aug 2009
Reputation Points: 10
Solved Threads: 1
 

I hope you created a proper web project through Eclipse. Using web project will take care of basic needs compile/run/deploy.

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

no peter, its not power web proj. everything worked fine for previous projs,.... but i donno whis this happed this time.

what do u think might be the prblem?
thanQ

beanboy
Light Poster
44 posts since Aug 2009
Reputation Points: 10
Solved Threads: 1
 

Without seeing project structure and relevant coding it is difficult to make a statement. If you want attach your project in zip/rar to next reply and someone will have look at it, of course if it is not confidential.

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

i'm sorry i couldn't attach the proj, but thanks for the help :)

beanboy
Light Poster
44 posts since Aug 2009
Reputation Points: 10
Solved Threads: 1
 

Otherwise u do one thing....compile ur servlets .java files and place the .class files manually in the WEB-INF/classes folder then it shld work...and one more thing...did u make ur servlet public?....

fardoonmuhafiz
Light Poster
27 posts since Jan 2010
Reputation Points: -1
Solved Threads: 1
 

okay,..i wil do what u said,...and yes my servlet is public ...thanQ

beanboy
Light Poster
44 posts since Aug 2009
Reputation Points: 10
Solved Threads: 1
 

do i need a Java Studio Creator to compile my servlets,.... i'll check it anyway

beanboy
Light Poster
44 posts since Aug 2009
Reputation Points: 10
Solved Threads: 1
 

okay, compiled using net beans, copied the .class file in to web-inf/classes dir, restarted server ,..and when i run, i got same 404 class not found error.
thanQ

beanboy
Light Poster
44 posts since Aug 2009
Reputation Points: 10
Solved Threads: 1
 

okay,... i hav compiled the servlet file in netbeans, copied it in to web-inf/classes folder in eclipse proj,...it still shows 404 class not found error :?:

thanQ:icon_cool:

beanboy
Light Poster
44 posts since Aug 2009
Reputation Points: 10
Solved Threads: 1
 

2 possible issues:
1)You didn't point compiler to the location of servlet.jar file (which should not be this case if you used appropriate project)
2)Your files can no longer find each other as you may not keep folder structure as on compile

If you want to compile from command line you can use following example . For better understanding how to with deployment have look here

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

okay :) i wil see

beanboy
Light Poster
44 posts since Aug 2009
Reputation Points: 10
Solved Threads: 1
 
do i need a Java Studio Creator to compile my servlets,.... i'll check it anyway


You don't need a java Studio creator to compile your servlet...just copy paste your servlet in a text document,or edit plus....go to the command prompt and set the path to your j2sdk/bin and compile the program using javac command....it shld work....and just copy the .class file into classes folder....thanks....

fardoonmuhafiz
Light Poster
27 posts since Jan 2010
Reputation Points: -1
Solved Threads: 1
 

2 possible issues: 1)You didn't point compiler to the location of servlet.jar file (which should not be this case if you used appropriate project) 2)Your files can no longer find each other as you may not keep folder structure as on compile

If you want to compile from command line you can use following example . For better understanding how to with deployment have look here


Mr.beanboy said he compiled his .java file(servlet) successfully....that means his compiler accessed the class files available in servlet.jar files necessary....

fardoonmuhafiz
Light Poster
27 posts since Jan 2010
Reputation Points: -1
Solved Threads: 1
 
okay :) i wil see


tin the tag u have tag and this should match exactly with the tag in tag e.g.
in the web.xml file...

<web-app>
<servlet>
<servlet-name>dummy</servlet-name>
<servlet-class>SomeServlet</servlet-class>
</servlet>
<servlet-mapping>
 <servlet-name>dummy</servlet-name>
<url-pattern>/heloserv</url-pattern>
</servlet-mapping>
</web-app>


Here the servlet-name can be any name...but make sure it is same in both the and tags and the should be the name of your servlet(the servlet you developed)...
and the url pattern can be anything...but if you have done hard deployment in the server...you should call the servlet in the following way.... http://localhost:portnumber/root/helosrv

if you did console deployment and your war file name is something like test.war then you shld call the servlet in the following way...
http://localhost:portnumber/test/helosrv ...

Hope ur servlet works fine now....

fardoonmuhafiz
Light Poster
27 posts since Jan 2010
Reputation Points: -1
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You