Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Cannot access a servlet from a Java application

 
Ranch Hand
Posts: 484
  • 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/".
 
Author and all-around good cowpoke
Posts: 13078
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: 484
  • 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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • 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: 484
  • 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 VI Editor Redhat
  • 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: 484
  • 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
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic