• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

404 error tomcat/servlet  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get an error message: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. This happens when I click on the submit button of the form. My poject is composed of three files: Appweb.java, hello.html and web.xml. I have already tried to reinstall tomcat or check tomcat manager, or check the code for some mistake, but I have found nothing.
Schermata-del-2019-02-05-16-58-56.png
[Thumbnail for Schermata-del-2019-02-05-16-58-56.png]
Schermata-del-2019-02-05-17-03-46.png
[Thumbnail for Schermata-del-2019-02-05-17-03-46.png]
Schermata-del-2019-02-05-17-06-47.png
[Thumbnail for Schermata-del-2019-02-05-17-06-47.png]
 
Saloon Keeper
Posts: 5327
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

In the future, please do not post screenshots, which make it impossible to quote or copy - post the actual text, preferably in CODE tags.

Which URL is displayed in the browser?
 
Daniel Russell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Moores wrote:Welcome to the Ranch.

In the future, please do not post screenshots, which make it impossible to quote or copy - post the actual text, preferably in CODE tags.

Which URL is displayed in the browser?




The url in the browser is this one: http://localhost:8081/Appweb/.

 
Marshal
Posts: 67255
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are running tomcat on port 8081?  

What we also need to see is your web.xml. Posted as text and using code tags (see UseCodeTags).
 
Daniel Russell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:You are running tomcat on port 8081?  

What we also need to see is your web.xml. Posted as text and using code tags (see UseCodeTags).



Yes, I'm using port 8081, because 8080 gives me problem. If I use 8080 the Bowser show me the message: "The requested resource is not available." and I have also problem with tomcat,
because tomcat say that 8080 is already in use, or something like that.

My web.xml is:



I have already tried to change /Appweb to /Appweb/*, but nothing change.
 
Bear Bibeault
Marshal
Posts: 67255
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Russell wrote:Yes, I'm using port 8081, because 8080 gives me problem. If I use 8080 the Bowser show me the message: "The requested resource is not available." and I have also problem with tomcat,
because tomcat say that 8080 is already in use, or something like that.


Then this is the first thing to fix rather than side-step around.

The resource not available error likely means a configuration issue. There's a checklist in the ServletsFaq to help find out what the issue is.

If something else is running on 8080, likely a runaway instance of tomcat, you need to know about it.
 
Daniel Russell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Daniel Russell wrote:Yes, I'm using port 8081, because 8080 gives me problem. If I use 8080 the Bowser show me the message: "The requested resource is not available." and I have also problem with tomcat,
because tomcat say that 8080 is already in use, or something like that.


Then this is the first thing to fix rather than side-step around.

The resource not available error likely means a configuration issue. There's a checklist in the ServletsFaq to help find out what the issue is.

If something else is running on 8080, likely a runaway instance of tomcat, you need to know about it.



When I try to use port 8080, when I start tomcat it apperas this message:

"Port 8080 required by Tomcat v8.5 Server at localhost (2) is already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s)."

In the past I have chosen the second option, that was to pass to port 8081.
 
Bear Bibeault
Marshal
Posts: 67255
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What else could your system be running that could be sitting on 8080 already? If you're not running something explicitly, it's likely a runaway Tomcat instance that you should kill.

If some other server is legitimately using 8080 (unlikely? other servers usually have their own conventional port other than Tomcat's 8080) then using another port is ok, but not optimum.

What happens when you hit localhost:8080?
 
Daniel Russell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Russell wrote:

Bear Bibeault wrote:

Daniel Russell wrote:Yes, I'm using port 8081, because 8080 gives me problem. If I use 8080 the Bowser show me the message: "The requested resource is not available." and I have also problem with tomcat,
because tomcat say that 8080 is already in use, or something like that.


Then this is the first thing to fix rather than side-step around.

The resource not available error likely means a configuration issue. There's a checklist in the ServletsFaq to help find out what the issue is.

If something else is running on 8080, likely a runaway instance of tomcat, you need to know about it.



When I try to use port 8080, when I start tomcat it apperas this message:

"Port 8080 required by Tomcat v8.5 Server at localhost (2) is already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s)."

In the past I have chosen the second option, that was to pass to port 8081.



I have found a process running and I have killed him from terminal. Now I'am able to use port 8080, but when I try to submit my form the error is the same as before, it's the 404: "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.".
 
Bear Bibeault
Marshal
Posts: 67255
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Had you worked through the troubleshooting list in the ServletsFaq for resource 404 errors?

[Edit: link ]
 
Daniel Russell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Had you worked through the troubleshooting list in the ServletsFaq for resource 404 errors?

[Edit: link ]



I have to understand this one:

"Make sure that the servlet class is properly placed under the WEB-INF/classes hierarchy, or properly packaged in a jar file in WEB-INF/lib."

If I go to WEB-INF/lib, in the lib folder there's nothing. If the servlet class is "helloservelets" in my case, then it has this directory: eclipse-workspace/Appweb/src/helloservlets. That is the directory in which I find the file Appweb.java. In web-inf there is only my web.xml. Does it means that I have to change the directory of helloservlets?
 
Sheriff
Posts: 21689
101
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Russell wrote:The url in the browser is this one: http://localhost:8081/Appweb/.


That's missing the context path, which is the name of the WAR file (minus .war). Unless you deploy a WAR as the root application, you need to use its content path.
 
Daniel Russell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:

Daniel Russell wrote:The url in the browser is this one: http://localhost:8081/Appweb/.


That's missing the context path, which is the name of the WAR file (minus .war). Unless you deploy a WAR as the root application, you need to use its content path.



I'm not using a war file in my project, instead I'm using a web.xml and a hello.html. At the moment  I open the html file in the web browser, I complete the form and then, when I press the submit button, it appears the message: "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists", in the error 404 page.

The Hello.html is this one:

 
Rancher
Posts: 3983
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Russell wrote:
If I go to WEB-INF/lib, in the lib folder there's nothing. If the servlet class is "helloservelets" in my case, then it has this directory: eclipse-workspace/Appweb/src/helloservlets. That is the directory in which I find the file Appweb.java. In web-inf there is only my web.xml. Does it means that I have to change the directory of helloservlets?



That sounds like it hasn't been deployed correctly.

Can you post the directory structure under your tomcat/webapps (not as a screenshot).

It should be something like:
webapp -
   Appweb -
       <html files>
       WEB-INF -
           classes -
               <your class directory structure helloservlet/Appweb.class>
           lib -  (probably empty)
 
Daniel Russell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:

Daniel Russell wrote:
If I go to WEB-INF/lib, in the lib folder there's nothing. If the servlet class is "helloservelets" in my case, then it has this directory: eclipse-workspace/Appweb/src/helloservlets. That is the directory in which I find the file Appweb.java. In web-inf there is only my web.xml. Does it means that I have to change the directory of helloservlets?



That sounds like it hasn't been deployed correctly.

Can you post the directory structure under your tomcat/webapps (not as a screenshot).

It should be something like:
webapp -
   Appweb -
       <html files>
       WEB-INF -
           classes -
               <your class directory structure helloservlet/Appweb.class>
           lib -  (probably empty)



My project has this structure:

Appweb- (folder of the project in workspace)

     build -
       classes-
          helloservlets-
                Appweb.class

     src-
         helloservlets-
           Appweb.java

     WebContent-
        hello.html

          META-INF-
             MANIFEST.MF
     
          WEB-INF-
             web.xml
             lib (empty)



So the class is in the build folder, not in the WEB-INF.
 
Dave Tolls
Rancher
Posts: 3983
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, not your project.
What is deployed to tomcat?
What does the webapp folder under tomcat look like?

What you show there is your project, this is not the same thing that is deployed to the server.

If you don't know where to look, then how do you deploy your webapp?
 
Daniel Russell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:No, not your project.
What is deployed to tomcat?
What does the webapp folder under tomcat look like?

What you show there is your project, this is not the same thing that is deployed to the server.

If you don't know where to look, then how do you deploy your webapp?



You mean the folder in tomcat?

If so, it's this one:

wtpwebapps-

      Appweb-

        hello.html
       
        META-INF-
         
           MANIFEST.MF

        WEB-INF-
         
           web.xml

          classes-
         
                 helloservlets-
   
                     Appweb.class


          lib (empty)


 
Daniel Russell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Russell wrote:

Dave Tolls wrote:No, not your project.
What is deployed to tomcat?
What does the webapp folder under tomcat look like?

What you show there is your project, this is not the same thing that is deployed to the server.

If you don't know where to look, then how do you deploy your webapp?



You mean the folder in tomcat?

If so, it's this one:

wtpwebapps-

      Appweb-

        hello.html
       
        META-INF-
         
           MANIFEST.MF

        WEB-INF-
         
           web.xml

          classes-
         
                 helloservlets-
   
                     Appweb.class


          lib (empty)




I found another problem that likely is related to the 404 problem.

when I hover with the mouse those package:



I see this message: Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.

What's the meaning of this message?

My problem is related to get and post method, because the 404 appears when I click to submit button.
So there must be something to fix in HttpServletRequest.
 
Dave Tolls
Rancher
Posts: 3983
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, based on the mappings in your web.xml, I would say your servlet resides at:
https://<servername>/Appweb/Appweb

The first Appweb is the application name (based on the folder name in webapps).
The second is what you have mapped the servlet to.

As for the message, it means the IDE cannot find either the source code or the Javadoc for those classes, and so cannot do it's usual trick of popping up the Javadoc description of the class.
 
Daniel Russell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:Right, based on the mappings in your web.xml, I would say your servlet resides at:
https://<servername>/Appweb/Appweb

The first Appweb is the application name (based on the folder name in webapps).
The second is what you have mapped the servlet to.

As for the message, it means the IDE cannot find either the source code or the Javadoc for those classes, and so cannot do it's usual trick of popping up the Javadoc description of the class.




Two Appweb? the folder and the name of the class?

When I open my hello.html, then I complete the form and I press 'submit', in the 404 error page the url written up the page is "http://localhost:8080/Appweb/". You mean the right url would be something like "http://localhost:8080/Appweb/Appweb/"? But even if I change to this, the error is the same.

the strange thing is that if I write http://localhost:8080/Appweb/hello.html, then it goes to the page with he form. When I press the button "submit" then it goes to the url http://localhost:8080/Appweb/  and then it show up the error message: "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists."

 
Rob Spoor
Sheriff
Posts: 21689
101
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Russell wrote:Two Appweb? the folder and the name of the class?


Technically speaking the context path and the servlet path. (Note that I said the same except I used the term "war". That's how web applications are usually deployed.) But your servlet is mapped to /Appweb, not /Appweb/ or /Appweb/*. Try using http://localhost:8080/Appweb/Appweb (no trailing slash).

As for your error when you submit the form, that's because it's still trying to open http://localhost:8080/Appweb/. Unless you have an index.html, index.jsp or a welcome file in the root of your application, that URL simply does not exist.
 
Daniel Russell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:

Daniel Russell wrote:Two Appweb? the folder and the name of the class?


Technically speaking the context path and the servlet path. (Note that I said the same except I used the term "war". That's how web applications are usually deployed.) But your servlet is mapped to /Appweb, not /Appweb/ or /Appweb/*. Try using http://localhost:8080/Appweb/Appweb (no trailing slash).

As for your error when you submit the form, that's because it's still trying to open http://localhost:8080/Appweb/. Unless you have an index.html, index.jsp or a welcome file in the root of your application, that URL simply does not exist.



Thank you! This is the solution! I have changed the url of the action="" to http://localhost:8080/Appweb/Appweb. Now it works.
 
Rob Spoor
Sheriff
Posts: 21689
101
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.

One more change you may want to make, and that is to remove the http://localhost:8080 part from the form action. That causes the form to only work on your local machine. If you deploy your application somewhere, the form will still try to redirect to localhost:8080 - the user's own machine.

Three options:
* Absolute within the same host: /Appweb/Appweb. If you change your context path it will break though.
* Relative to the current page: Appweb (note: no leading /).
* Change hello.html into a JSP file and use ${pageContext.request.contextPath}/Appweb. This is like the first option but if the context path changes, the form action changes with it.
 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!