war file deploying problem

i have created a war file in tomcat root/webapps/ch02/helloworldservlet directory. i ahve my class file in ch02/helloworldservlet/web-inf/classes

here is my web.xml file

<?xml version="1.0" encoding="ISO-8859-1"?>

<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>Hello World</display-name>

<description>A Hello World Web Application</description>

<servlet>

<servlet-name>HelloWorld</servlet-name>

<servlet-class>HelloWorldServlet.HelloWorldServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>HelloWorld</servlet-name>

<url-pattern>/hello</url-pattern>

</servlet-mapping>

</web-app>

and this is what i am typing in my url

http://localhost:8080/CH02/HelloWorldServlet/helloworld/hello

its displaying

type Status report

message /CH02/HelloWorldServlet/helloworld/hello

description The requested resource (/CH02/HelloWorldServlet/helloworld/hello) is not available.

any help?

[1524 byte] By [lrngjavaa] at [2007-11-27 1:08:32]
# 1
Required .jar file may be missing under WEB-INF/LIB oryour web.xml is not configured well.
skp71a at 2007-7-11 23:43:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

> Required .jar file may be missing under WEB-INF/LIB

> or

> your web.xml is not configured well.

no sir. i can see my servlet-apo executable jar file in /common/lib

how do you know my web.xml is not configured properly? i am following the book example and i dont see any difference between their example and my example.

lrngjavaa at 2007-7-11 23:43:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
As soon as I saw the error message, I thought that could be the issue. But it looks like some other problem. May be try with .do url-pattern. Again just a suggestion. It might not be the solution.
skp71a at 2007-7-11 23:43:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
this is like a worst nightmare
lrngjavaa at 2007-7-11 23:43:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Aliright here is how your war structure should look like

%CATLINA_HOME%/WEBAPPS/CH02<WEBAPP_NAME>

- helloworldservlet

(Place your JSPs,HTML & public resources into that folder)

- WEB-INF

(Place web.xml and nessary classes in classes folder & libraries in lib folder)

therefore if the following is you descripbed structure & you want your URL to be following http://localhost:8080/CH02/HelloWorldServlet/helloworld/hello

<?xml version="1.0" encoding="ISO-8859-1"?>

<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>Hello World</display-name>

<description>A Hello World Web Application</description>

<servlet>

<servlet-name>HelloWorld</servlet-name>

<servlet-class>HelloWorldServlet.HelloWorldServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>HelloWorld</servlet-name>

<url-pattern>/HelloWorldServlet/hello</url-pattern>

</servlet-mapping>

</web-app>

and don't forget to place the HelloWorld.class under %CATLINA_HOME%/WEBAPPS/CH02<WEBAPP_NAME>/WEB_INF/classes/HelloWorldServlet folder as you have metioned it to be under HelloWorldServlet pacakage(Going by an assumption that you have already mentioned package name on the servlet source).

Hope this might help :)

REGARDS,

RaHuL

RahulSharnaa at 2007-7-11 23:43:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

WOw what in the world is that

%CATLINA_HOME%/WEBAPPS/CH02<WEBAPP_NAME>

- helloworldservlet

do i type this in the dos? if i place my class file directly in tomcat common/classes/HelloWorldServlet/ then i type in my url

http://localhost:8080/servlet/HelloWorldServlet.HelloWorldServlet

it worked but this is not an efficient way to do it.

so now let me try your example. thanks for posting but can you explain what is %catline_home?

lrngjavaa at 2007-7-11 23:43:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

%CATILINA_HOME% is nothing but home directory of TOMCAT server...

say something like C:\program file\tomcat 5.0\ could be the path of it

and i beg your pardon the path

%CATLINA_HOME%/WEBAPPS/CH02<WEBAPP_NAME>

is

%CATLINA_HOME%/WEBAPPS/CH02 where ch02 can be replaced by another application name

%CATLINA_HOME%/WEBAPPS/CH02<WEBAPP_NAME>

- helloworldservlet

is nothing but

%CATLINA_HOME%/WEBAPPS/CH02/helloworldservlet/

place all your JSP's & other public resources in the following folder

%CATLINA_HOME%/WEBAPPS/CH02/WEB-INF

place web.xml under this folder

%CATLINA_HOME%/WEBAPPS/CH02/WEB-INF/lib

place all your jars in the following folder

%CATLINA_HOME%/WEBAPPS/CH02/WEB-INF/classes/HelloWorldServlet

Place your HelloWorldServlet.class in the following folder.

and change your web.xml as the thing i've metioned earlier.

<?xml version="1.0" encoding="ISO-8859-1"?>

<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>Hello World</display-name>

<description>A Hello World Web Application</description>

<servlet>

<servlet-name>HelloWorld</servlet-name>

<servlet-class>HelloWorldServlet.HelloWorldServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>HelloWorld</servlet-name>

<url-pattern>/HelloWorldServlet/hello</url-pattern>

</servlet-mapping>

</web-app>

Hope this doesn't confuse you further.

REGARDS,

RaHuL

RahulSharnaa at 2007-7-11 23:43:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

ah i hate this thing. i tried but still not working.

my jar file is in this folder(helloworld.war)

C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\CH02\HelloWorldServlet\WEB-INF\lib

and here is my web.xml file

C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\CH02\HelloWorldServlet\WEB-INF

and here is my java file(HelloWorldServlet.java)

C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\CH02\HelloWorldServlet

and here is my class file

C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\CH02\HelloWorldServlet\WEB-INF\classes\HelloWorldServlet

and this is what i am typing in my browser

http://localhost:8080/CH02/HelloWorldServlet/helloworld/hello

displays me an error

type Status report

message /CH02/HelloWorldServlet/helloworld/hello

description The requested resource (/CH02/HelloWorldServlet/helloworld/hello) is not available.

--

Please help

lrngjavaa at 2007-7-11 23:43:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
I guess U r not listening to what i've said....%CATLINA_HOME%\webapps\ch02\WEB-INFthis is where your folder had to be...If u r not instersted in reading posts properly...better don't post any queries as such....
RahulSharnaa at 2007-7-11 23:43:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10

i have that classes folder and lib folder under ch02/web-inf

i am listening to you rahul. i have done exatcly what you told me.

create a folder ch02

/webapps/root/ch02

create a folder for web-inf

/webapps/root/ch02/HelloWorldServlet/web-inf

put all your classes file in the classes folder in web-inf(HelloWorldServlet.class)

/webapps/root/ch02/HelloWorldServlet/web-inf/classes/HelloWorldServlet

put all your jsp files in ch02 folder

/webapps/root/ch02

put all your web.xml file under web-inf folder

/webapps/root/ch02/HelloWorldServlet/web-inf

everything i did like you said mr rahul.

lrngjavaa at 2007-7-11 23:43:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 11

ok mr rahul so i now understand what you were trying to say. you want me to make the web-inf folder in ch02. which i did. and still not working

type Status report

message /CH02/HelloWorldServlet/helloworld/hello

description The requested resource (/CH02/HelloWorldServlet/helloworld/hello) is not available.

lrngjavaa at 2007-7-11 23:43:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 12

its not

/webapps/root/ch02/HelloWorldServlet/web-inf

C:\program file\tomcat 5.0\webapps\ch02\WEB-INF

make sure you place WEB-INF folder under the application context which you are working on.

have you changed web.xml mappings to

<?xml version="1.0" encoding="ISO-8859-1"?>

<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>Hello World</display-name>

<description>A Hello World Web Application</description>

<servlet>

<servlet-name>HelloWorld</servlet-name>

<servlet-class>HelloWorldServlet.HelloWorldServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>HelloWorld</servlet-name>

<url-pattern>/HelloWorldServlet/helloworld/hello</url-pattern>

</servlet-mapping>

</web-app>

as you are requesting for a pattern

http:/ /hostname:ApplicationPort /CH02/HelloWorldServlet/helloworld/hello

always make sure if you are requesting for a pattern of

http://localhost:8080/webapplicationname/XXYX..../...

your servlet mapping should be

<servlet-mapping>

<servlet-name>ServletName</servlet-name>

<url-pattern>/XXYX..../...</url-pattern>

</servlet-mapping>

RahulSharnaa at 2007-7-11 23:43:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...