Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot access a servlet from a Java application

 
Alejandro Barrero
Ranch Hand
Posts: 335
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know how, but I solved the problem. I just re created the servlet from scratch adding one bit of functionality and one external jar at a time and lo and behold it worked. I swear I didn't change anything in the web.xml file. I apologize for the time I took from some of you.


I am trying to access a servlet from a Java application

In the server web.xml MyEclipse created


I am getting the exception "java.io.FileNotFoundException: http://localhost:8080/PaperlessOfice/Paperless/".
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Where is that error message appearing?
2. Why are you doing a POST but not sending a request body?

Bill
 
Alejandro Barrero
Ranch Hand
Posts: 335
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you William. I am running the program in the MyEclipse debugger; the message comes in the console. I get the same error even if I send data in the request

I have Tomcat running; I can use

and it works fine. Initially, the web application was created with index.jsp specified in the web.xml and my request was running the JSP; so Tomcat is running my war. I think that my client code is correct, but I have to do something in web.xml. In the client I have tried all combinations of PaperlessOffice, Paperless and servlet to no avail.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you able to hit that component with a browser?
If so, then the web portion is OK, and the problem is in the client.

Likewise, you can test the client code by aiming it at URL that you know works.

 
Alejandro Barrero
Ranch Hand
Posts: 335
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just don't getit.
I am using "serverAddress = new URL("http://localhost:8080/Paperless/servlet/Paperless/");" the idea is to invoke the url-pattern "servlet/Paperless" in the war file "Paperless".
I am using

in my web.xml file. It associates the url pattern "servlet/Paperless" with the name "Paperless". In the servlet tag this name is associated with class com.paperless.Paperless. This class exists in WEB-INF/classes. It should find this calls, but I am getting a 404 error in the tomcat log which tells me thta the resource is not found and In Java I get "java.io.FileNotFoundException: http://localhost:8080/Paperless/servlet/Paperless/".
When I use "serverAddress = new URL("http://localhost:8080/Paperless/" )"I get the text of the index.jsp file in <welcome-file> in web.xml, so "http://localhost:8080/Paperless/" is a web address (I should know that because 404 means that the request was received).
I am getting the same error with Tomcat and GlassFish. I don't know what I am doing wrong in the web.xml file. I really need the help of an expert.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at the logs to see if the servlet wasn't able to be deployed?
 
Alejandro Barrero
Ranch Hand
Posts: 335
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ben. I haven't seen anything in the Tomcat or GlassFish logs. But on GlassFish I just saw "[#|2011-05-12T12:46:02.684-0400|INFO|oracle-glassfish3.1|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=193;_ThreadName=Thread-1;|PaperlessOfice was successfully deployed in 316 milliseconds.|#]

".
But I am still having the same error with "serverAddress = new URL("http://localhost:8080/Paperless/paperless");". Using
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic