• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

requested resource() not found for simple HTML?

 
Ranch Hand
Posts: 61
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello everyone,
I'm starting servlets and jsp and following the Head First: Servlets and JSP book for it.

As per the book I was trying the example from chapter-3 as described in steps and got the problem in the first step itself.

I've created (and rechecked for compliance) the development and deployment environments as per the ch3 of book. Also I'm at first step of the Beer-v1 app. in which I've created the form.html and web.xml files and put them in the directories specified.

Now, when trying to run the form.html I got this error from Tomcat : 404 requested resource() is not available.

I've already checked that the tomcat server is running as I can access the http://localhost:8080/ page. I've also tried by restarting the server but for no use.

also in Tomcat manager it's showing the running status for the application Beer-v1 as false, while for that from chapter-1 i.e. ch1 it's showing true.

What could be the possible solution? (Sorry for such a long description... )
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There most likely cause is that you don't have that directory configured properly as a "web application". If, on startup, the server does not see the correct WEB-INF, web.xml, etc. structure, you will get that not found message.

Bill
 
Anupam Jain
Ranch Hand
Posts: 61
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Brogden wrote:There most likely cause is that you don't have that directory configured properly as a "web application". If, on startup, the server does not see the correct WEB-INF, web.xml, etc. structure, you will get that not found message.

Bill



Thanks for the quick reply Bill,

but as I said earlier... I've created and rechecked the directory structure for compliance with the book. And also I'm able to run the sample application from chapter-1.

according to the book I should've been able to run the two file(s) I've created so far.
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps you could share that directory structure with us? UseCodeTags, like this:

Also, could you share the contents of your web.xml file (again, UseCodeTags)?
 
Anupam Jain
Ranch Hand
Posts: 61
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark E Hansen wrote:Perhaps you could share that directory structure with us?


Also, could you share the contents of your web.xml file (again, UseCodeTags)?



The directory structure is as described below... (This is in accordance to the book...)



I hope the above structure is clear to everyone... The code is also same as the book for the two files form.html and web.xml.
I dont think that the code for the web.xml is important as of this point 'cause the entry point to the application is form.html for which the server is saying resource() not found.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I dont think that the code for the web.xml is important as of this point '



Alas, you have made an incorrect assumption. When the server starts up it tries to find web applications by looking for the required directory structure and reading the web.xml deployment descriptor.

IF there is any error in web.xml such that this step fails, then the server does not consider that directory to contain a valid web application. Even if there is nothing but plain HTML, it still would not be a valid web application.

One would expect to find error messages in the logs.

Tomcat manager it's showing the running status for the application Beer-v1 as false, while for that from chapter-1 i.e. ch1 it's showing true.



Suggests that something went wrong during startup - thats why you have been asked to show your web.xml

Bill
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At this point, I would be looking at the Tomcat logs.
Tomcat very rarely fails quietly.

 
Greenhorn
Posts: 27
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure if this will solve your issue, but try putting the html file inside the WEB-INF folder.

And in web.xml change the welcome file list tag and add the name of the html file into it at the top. Sample code is:



When you open the http://localhost:8080, by default it will open your html page.

You can revert back once it works .
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

parampreet sethi wrote:I am not sure if this will solve your issue, but try putting the html file inside the WEB-INF folder.

And in web.xml change the welcome file list tag and add the name of the html file into it at the top. Sample code is:




If you want to place the file under WEB-INF, you're going to need to include that in the welcome file list, as in:

Also, why list an htm version if you don't have that file?


parampreet sethi wrote:When you open the http://localhost:8080, by default it will open your html page.


Only if your web application is configured as the root web application on the application server. Otherwise, you'll need to include the application context name, as in http://localhost:8080/myapp.

 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

parampreet sethi wrote:I am not sure if this will solve your issue, but try putting the html file inside the WEB-INF folder.


No. That will cause the HTML file to not be accessible via URL.

And in web.xml change the welcome file list tag and add the name of the html file into it at the top. Sample code is:


No. That will do nothing at all except add a useless entry.
 
parampreet sethi
Greenhorn
Posts: 27
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry my mistake, yes welcome file will not be directly accessible if the application is not set as ROOT.

As Mark corrected that the URL will be http://localhost:8080/myApp for accessing welcome file.

Regarding Anupam's query, Are you deploying the application as a WAR file in tomcat or its a folder which is copied inside tomcat/webapps folder?

Tomcat manager it's showing the running status for the application Beer-v1 as false, while for that from chapter-1 i.e. ch1 it's showing true.



If tomcat logs do not say anything. You can try by setting the context of application in server.xml file. Below mentioned is the way to set it:

  • Open file $TOMCAT_HOME/conf/server.xml in an editor.
  • Navigate to the bottom of the file (after the last existing <Context> element.
  • Add a new <Context> element for your application, using the existing examples as a guide. The following attributes are supported:

  • a. path. The context path for your application, which is the prefix of a request URI that tells Tomcat which application should be used to process this request. For example, if you set your path to "/catalog", any request URI beginning with "/catalog" will be processed by this application. This attribute is requrired, and must start with a slash ('/') character.
    b. docBase. The document root directory for this web application. This can be a relative path (relative to the directory in which Tomcat is started), or an absolute path, to the directory containing your app. On a Windows platform, you MUST use the drive prefix and a colon when specifying an absolute path. This attribute is required.
    c. debug. Debugging detail level (from "0" to "9") that defines how verbose Tomcat's logging messages will be when your application is initialized, started, and shut down. The default value is "0" (minimal logging) if you do not specify a different value.
    d. reloadable. Set to "true" if you want Tomcat to watch for changes to Java class files in the WEB-INF/classes directory, or JAR files in the WEB-INF/lib directory. If such a change is noted, Tomcat will shut down and reload your application automatically, picking up these changes. The default value ("false") means that such changes will be ignored. NOTE: While this feature is very useful during development, it requires overhead to do the checking. This capability should generally not be used in deployed production applications.
    e. trusted. Set to "true" if this application requires access to Tomcat 3.2 internal classes. Normally, this will only be required for the administration application that ships with Tomcat.

    Rest I will leave it to experts of the community .
     
    Anupam Jain
    Ranch Hand
    Posts: 61
    Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    parampreet sethi wrote:Regarding Anupam's query, Are you deploying the application as a WAR file in tomcat or its a folder which is copied inside tomcat/webapps folder?


    No I'm not deploying the application as a WAR file... I'm just following the book word by word so far... which didn't say anything regarding a WAR file (as of yet).

    Another thing is.... (as I noted)... In the book... they have developed the Beer-v1 application in steps... and what is explained so far is making a welcome html file "form.html" and the "web.xml" (with servlet and servlet-mappinng code) as mentioned above. After this they've asked to test the so far developed application... Can there be a problem about not preparing the servlet class at this point? (Though I think they are not required for form.html to display)

    I am using tomcat on Windows-xp platform. And I don't see the server icon in my system tray even when it is running. Is there a problem with my Tomcat installation?

    parampreet sethi wrote:
    If tomcat logs do not say anything. You can try by setting the context of application in server.xml file.



    what are these tomcat logs?? and where to find them?? are they available at http://localhost:8080/ ??
     
    parampreet sethi
    Greenhorn
    Posts: 27
    Tomcat Server Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You can see the tomcat logs on console itself.

    When you start the tomcat I believe from startup.bat file in case of windows from tomcat/bin folder, It will run the tomcat in a new command prompt window. You can check the tomcat logs there and see in case some exception is coming due to which your application is not getting deployed.

    Also paste the content of your web.xml file, it will help debugging the issue.
     
    Anupam Jain
    Ranch Hand
    Posts: 61
    Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Here's the code of my web.xml ...

     
    The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
    We need your help - Coderanch server fundraiser
    https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
    reply
      Bookmark Topic Watch Topic
    • New Topic