aspose file tools*
The moose likes Servlets and the fly likes Cannot access a servlet from a Java application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Cannot access a servlet from a Java application" Watch "Cannot access a servlet from a Java application" New topic
Author

Cannot access a servlet from a Java application

Alejandro Barrero
Ranch Hand

Joined: Aug 01, 2005
Posts: 319
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/".


Your help will be greatly appreciated,
Alejandro Barrero
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
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

Joined: Aug 01, 2005
Posts: 319
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

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Alejandro Barrero
Ranch Hand

Joined: Aug 01, 2005
Posts: 319
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

Joined: Dec 11, 2004
Posts: 13410

Have you looked at the logs to see if the servlet wasn't able to be deployed?
Alejandro Barrero
Ranch Hand

Joined: Aug 01, 2005
Posts: 319
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot access a servlet from a Java application