aspose file tools*
The moose likes Beginning Java and the fly likes Compiling servlet  [was: HTTP Status 404 - Servlet Login is not available] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compiling servlet  [was: HTTP Status 404 - Servlet Login is not available]" Watch "Compiling servlet  [was: HTTP Status 404 - Servlet Login is not available]" New topic
Author

Compiling servlet [was: HTTP Status 404 - Servlet Login is not available]

sravanthi yendluri
Greenhorn

Joined: May 25, 2008
Posts: 23
When I am trying to use,
http://localhost:8085/log?user_name="rajini"&password="dolly"

I am getting an error,

HTTP Status 404 - Servlet Login is not available

type: Status report

message: Servlet Login is not available

description: The requested resource (Servlet Login is not available) is not available.


I am using J2ME as my Frontend,Apache Tomcat 5.5 and Oracle 9i as my Backends.

Thanks,
Sravanthi.

[ May 25, 2008: Message edited by: sravanthi yendluri ]

[ May 25, 2008: Message edited by: sravanthi yendluri ]
[ May 28, 2008: Message edited by: Ben Souther ]
Rajat Bhatnagar
Greenhorn

Joined: Mar 11, 2008
Posts: 22
Your problem could be basically related to 3 things:
1. Wrong Entry in url-pattern/servlet-name/servlet-class tags in web.xml
2. Missing class files
3. Wrong Url in browser

The best way to find out is to check the tomcat logs .

Tomcat logs will clearly give an indication where you might be going wrong.
In case you are still not able to find the problem paste the Error log message here ..


Regards<br />Rajat Bhatnagar<br /><a href="http://guideofgreatness.googlepages.com" target="_blank" rel="nofollow">http://guideofgreatness.googlepages.com</a>
sravanthi yendluri
Greenhorn

Joined: May 25, 2008
Posts: 23
My servlets are in "C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\classes"

My web.xml is as follows,

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>


<servlet>
<servlet-name>Aboutus</servlet-name>
<servlet-class>AboutusServlet</servlet-class>
</servlet>

<servlet>
<servlet-name>Login</servlet-name>
<servlet-class>LoginServlet</servlet-class>
</servlet>


<servlet-mapping>
<servlet-name>Aboutus</servlet-name>
<url-pattern>/aboutus</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/log</url-pattern>
</servlet-mapping>


</web-app>


My servlet program is as follows,

This is the error that I found in localhost.2008-05-25 in the logs folder is.

May 25, 2008 9:27:18 PM org.apache.catalina.core.ApplicationContext log
INFO: org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRule: Target string: News / Redirect URL: ,]http://www.cnn.com], [org.apache.webapp.balancer.rules.RequestParameterRule: Target param name: paramName / Target param value: paramValue / Redirect URL: ,]http://www.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL: ]]http://jakarta.apache.org]]
May 25, 2008 9:27:18 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
May 25, 2008 9:27:18 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
May 25, 2008 9:27:18 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
May 25, 2008 9:27:18 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
May 25, 2008 9:27:54 PM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet Login as unavailable
May 25, 2008 9:27:54 PM org.apache.catalina.core.ApplicationContext log
SEVERE: Error loading WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@10a3b24
LoginServlet
java.lang.ClassNotFoundException: LoginServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1362)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1208)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1068)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:791)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:127)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
May 25, 2008 9:27:54 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet Login
java.lang.ClassNotFoundException: LoginServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1362)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1208)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1068)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:791)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:127)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)

[ May 25, 2008: Message edited by: sravanthi yendluri ]


[BSouther: Added UBB CODE tags]
[ May 26, 2008: Message edited by: Ben Souther ]
sridhar lakka
Ranch Hand

Joined: Jan 02, 2007
Posts: 109
still are you facing problem or is it solved?
sravanthi yendluri
Greenhorn

Joined: May 25, 2008
Posts: 23
I am still facing the problem.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410



Did you compile your servlet?
If so, where did you put your servlet class file?

A word of caution, this isn't related to your current problem but will cause a similar problem later when you start using JSP and beans.
All Java classes in a Java web application should be in packages.
There are cases where the JVM will not be able to find your Java classes if they are in the default package (no package).

I would fix that before continuing to debug this issue.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
sravanthi yendluri
Greenhorn

Joined: May 25, 2008
Posts: 23
I am trying to compile my LoginServlet.java but I am getting an error.


My User Variable is : (path)
C:\Program Files\Java\jdk1.5.0_15\bin;c:\j2sdk1.4.2_06\bin;C:\Program Files\Apache Software Foundation\Tomcat 5.5\bin

My System Variable is : (Classpath)
C:\Program Files\Java\jre1.6.0_05\lib\ext\QTJava.zip;
C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar;
C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\jsp-api.jar;
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\classes

Java_Home is,
C:\j2sdk1.4.2_06;C:\Program Files\Java\jdk1.5.0_15\bin

Before compiling I even followed the command,

set classpath=c:\program files\apache--\tomcat5.5\lib\common\servlet-api.jar

And I am using the following command to compile the servlet,

javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\classes\LoginServlet.java"

But I am getting an error,

javac:no source files
Usage:javac <options> <source files>
where possible options include:
**********************


Then I kept the LoginServlet.java program in C:\ and then compiled the program.I did not get any errors.

But,When I am running the servlet in the browser I am getting the same error 404.
I don't know what the problem is.

Sravanthi.

[ May 26, 2008: Message edited by: sravanthi yendluri ]

[ May 26, 2008: Message edited by: sravanthi yendluri ]

[ May 26, 2008: Message edited by: sravanthi yendluri ]

[ May 26, 2008: Message edited by: sravanthi yendluri ]
[ May 26, 2008: Message edited by: sravanthi yendluri ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Originally posted by sravanthi yendluri:
I am trying to compile my LoginServlet.java but I am getting an error.

If your servlet is not compiling, then of course its not going to work at run time. How can the serveklt be called is it doesn't exist?

Do you not think that you should fix the compile error before worrying about getting it to run?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sravanthi yendluri
Greenhorn

Joined: May 25, 2008
Posts: 23
My servlet was compiled when I kept it directly in C:\ drive.
H Gokulam
Ranch Hand

Joined: Nov 04, 2003
Posts: 46
Originally posted by sravanthi yendluri:
My servlet was compiled when I kept it directly in C:\ drive.


You need to put your class file into the corresponding directory in tomcat. WEB-INF/classes directory


Harikumar G<br />SCJP 1.4
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

One more thing that isn't relative to your issue:
Don't use directories with spaces in its names...
cortin flaneir
Greenhorn

Joined: May 26, 2008
Posts: 13
check out your web.xml file . i am sure that url pattern is does not match. or your classfile missing.check out
sravanthi yendluri
Greenhorn

Joined: May 25, 2008
Posts: 23
Where can I find my class file for the Java file so that I can put it in web-inf\classes folder.

I found it in the C:\ drive because I complied it from there and I kept it in the web-inf\classes folder and I compiled it again but I got the same error that there is no source file.

Am I compiling in the right way.

I compiled the program as follows:

javac -classpath="C:\ProgramFiles\ApacheSoftwareFoundation\Tomcat5.5\ROOT\WEB-INF\classes\LoginServlet.java"

I am doing it in the right way?

Sravanthi.
[ May 27, 2008: Message edited by: sravanthi yendluri ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The class file is created by the compiler.
sravanthi yendluri
Greenhorn

Joined: May 25, 2008
Posts: 23
Is the way that I compiled the file right?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Originally posted by sravanthi yendluri:
put it in web-inf\classes folder.


It's WEB-INF/ not web-inf. Case counts.
sravanthi yendluri
Greenhorn

Joined: May 25, 2008
Posts: 23
I typed it right and was caeful with the case.
I don't know what the problem is?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Originally posted by sravanthi yendluri:
I typed it right and was caeful with the case.

Please read this.
sravanthi yendluri
Greenhorn

Joined: May 25, 2008
Posts: 23
I tried again typing in the correct cases but I am getting the same error.
I am not knowing what to do.
[ May 27, 2008: Message edited by: sravanthi yendluri ]
Baseet Ahmed
Ranch Hand

Joined: Dec 18, 2006
Posts: 224

Originally posted by sravanthi:
I compiled the program as follows:

javac -classpath="C:\ProgramFiles\ApacheSoftwareFoundation\Tomcat5.5\ROOT\WEB-INF\classes\LoginServlet.java"
I am doing it in the right way?


sravanthi,
If it is giving error then,try with this:
Put your Java file(LoginServlet.java) in C drive
1- Go to C:\ProgramFiles\ApacheSoftwareFoundation\Tomcat5.5\ROOT\WEB-INF\classes directory using cd command(on Windows)
2- cd C:\ProgramFiles\ApacheSoftwareFoundation\Tomcat5.5\ROOT\WEB-INF\classes
3- Then compile it using C:\ProgramFiles\ApacheSoftwareFoundation\Tomcat5.5\ROOT\WEB-INF\classes>javac C:\LoginServlet.java
4- Give the restart to your application server(tomcat etc).
5- Test the application.


Regards
Baseet Ahmed
****************
Say Salaam before starting communication(verbal+nonverbal),even before Hi/Hello.
Salaam : Assalam Alekum (Peace may upon you.)
****************
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39537
    
  27
Originally posted by sravanthi yendluri:
javac -classpath="C:\ProgramFiles\ApacheSoftwareFoundation\Tomcat5.5\ROOT\WEB-INF\classes\LoginServlet.java"

I am doing it in the right way?

No. The classpath -as the name implies- is for class files, not source files. The command should be something like


[ May 28, 2008: Message edited by: Ulf Dittmer ]

Ping & DNS - updated with new look and Ping home screen widget
sravanthi yendluri
Greenhorn

Joined: May 25, 2008
Posts: 23


sravanthi,
If it is giving error then,try with this:
Put your Java file(LoginServlet.java) in C drive



I kept the file in the C Drive directly and compiled it directly and it worked fine. But when I tried to follow the steps given I am getting the error "System cannot find the path specified".

When I tried compiling the way "Ulf Dittmer" told me I am getting the error "no source code".
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Using javac and setting up classpaths are not servlet issues.
I'm moving this thread to Java In General (beginner).

It's a common mistake to jump right into servlets without spending a little time learning core Java. Now might be a good time to step back from this project and follow a couple tutorials on the basics of Java. You'll save yourself a lot of time and trouble if you do.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compiling servlet [was: HTTP Status 404 - Servlet Login is not available]
 
Similar Threads
problem running the HelloWorld ! servlet
Tomcat success page not displaying..
Unable to Access the Database
Need Help for Correct Url Mapping for Servlet in web.xml
HTTP Status 405 - Restful webservice