• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

URL not getting through to servlet

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all

I have some strange behaviour in my application that I don't understand. I've cut it down to the bare minimum, and will try to explain the problem.

I have a mainmenu.jsp file which looks like this:



I also have a slimmed-down controller which looks like this:



As you can see, all four of the links just return you to the same page. All, that is, apart from the fourth one, logout.do, which simply doesn't work. My Logger class, which just writes the incoming URLs to a file, registers nothing, and instead of returning to the mainmenu.jsp page I get a completely different page. The page that I'm getting is the home page of the app, which is really where I want the logout link to go, but it seems to be getting there by some weird route that doesn't involve my controller at all.


I'm approaching the hair-tearing out stage here. Can anyone suggest what might be happening?

Paul
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you had a look at the log of the HTTP server?
This should show all requests that come in from the browser, maybe
it gives some more insight?

Another thing to look at might be the file in which you tell the application server to route requests to your controller servlet. It might contain a special entry for the request that behaves in a strange way.

Also, you never know, it could be that your HTML causes the problem. You should put </a> before </p>.

Good luck!
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul
Check your mapping file of struts. The problem lies there is what i sense. Check out your mapping for logout.do.

Let me know...

Regards
Makarand Parab
 
Paul Hennessey
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Martin and Makarand,

Thanks for your suggestions. I've had a look at the logs and something seems to be wrong, but I don't understand the messages. I'll show you some edited highlights of the localhost.log:



SEVERE: Servlet /BeerStruts threw load() exception
java.lang.NoClassDefFoundError: org/apache/commons/collections/FastHashMap
at org.apache.struts.action.ActionServlet.<init>(ActionServlet.java:348)
.
.
.
INFO: Marking servlet org.apache.catalina.INVOKER.Kodaly-v11 as unavailable
07-Aug-2005 10:41:47 org.apache.catalina.core.ApplicationContext log
SEVERE: Error loading WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@192a848
Kodaly-v11
java.lang.ClassNotFoundException: Kodaly-v11
.
.
.
07-Aug-2005 10:41:47 org.apache.catalina.core.ApplicationContext log
SEVERE: invoker: Cannot allocate servlet instance for path /servlet/Kodaly-v11/logout.do
javax.servlet.ServletException: Wrapper cannot find servlet class Kodaly-v11 or a class it depends on
.
.
.
INFO: Marking servlet org.apache.catalina.INVOKER.logout.do as unavailable
07-Aug-2005 10:42:03 org.apache.catalina.core.ApplicationContext log
SEVERE: Error loading WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@192a848
logout.do
java.lang.ClassNotFoundException: logout.do



As you suggested, Makarand, Struts seems to be involved in these exceptions, but the odd thing is I'm not using Struts in this app, although I do have it on my system.

Can anyone suggest what might be causing these errors?

Paul
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul,
Did you check the web.xml to verify that the struts action servlet is not loaded at startup? Because it seems that the struts action servlet is loading on startup but is missing the commons collections jars from apache. If you don't need struts try not loading the struts action servlet at startup.
 
Paul Hennessey
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lars,

Here is my web.xml.



As you can see, I don't explicitly load the Struts action servlet, although I admit I don't really understand everything that the header is doing, I just typed it in from the HFSJ book.

Paul
 
Lars Vonk
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Indeed you are not loading the struts servlet in this application. Maybe another application on your server attempts to load it? Although i am not sure if this error then relates to your problem because it is not in the same application. But maybe its worth a look.
The header information tells you you are using Servlet specification version 2.4. You should check that the version of your server supports this version. If you are using Tomcat: Tomcat 4.1 supports version 2.3, tomcat 5 supports 2.4.

Hope this helps keeping your hair
 
Paul Hennessey
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I've made some progress, but not much.

I found that there was a struts jar file in my CLASSPATH , so I removed it. After that, I stopped getting all those exceptions in the logs, so that's good.

However, the problem hasn't gone away. The logout.do link that I mentioned in my first email still goes to my homepage, index.html, when it shouldn't. I don't understand how - is there any other place that Tomcat stores mappings, other than web.xml, which I've already checked?

Even more bizarrely, the index.html that is being called shouldn't even exist any more. I've renamed it myindex.html, and have changed the text that it displays, but it is the old file that keeps appearing. This suggests to me that Tomcat caches these things somewhere, but the problem persists even afer rebooting the machine.

Paul (still tearing hair!)
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Originally posted by Paul.
The logout.do link that I mentioned in my first email still goes to my homepage, index.html, when it shouldn't



1. Right click and view the html source. Does the link's href still point to index.html ?

2. If the answer to #1 is 'yes', force a jsp recompile. Just add a space somewhere and then delete the extra space. The timestamp would change forcing the jsp to be recompiled and then test again.


Even more bizarrely, the index.html that is being called shouldn't even exist any more.



Check #1 above. The index.html may probably be cached by the browser.

cheers,
ram.
 
Paul Hennessey
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've managed to make the test app that I was moaning about earlier work most of the time now - I suspect stuff was being cached by the browser as Ramprasad suggested. But my real app still isn't right. This is what I think should happen:

- Mainmenu.jsp sends logout.do to my controller servlet.
- Controller routes request to logoutAction class.
- LogoutActionclass does some tidying up, invalidates the session, then returns 'index.html' to controller.
- Controller forwards index.html to browser.

To check what's going on, my controller writes all incoming URLs to a file. The first time round, everything works fine, but after that the URL that asks for logout.do simply doesn't get sent to the controller. Despite that, my system still goes to index.html.

What this means is that it looks as if it's working, but it really isn't because my LogoutAction class with its tidying up code isn't getting called. I've worked round it for now by putting all the tidying up stuff elsewhere, but I'm still puzzled and would love to know what's going on.

Could the browser somehow be creating a map between logout.do and index.html?

Paul

Paul
 
Lars Vonk
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul,
Do I understand it correct that the first time you sends logout.do it works fine and gets logged by the Controller, but the second time and so on it doesn't get to the Controller anymore?
Do you still get exceptions in your log? Which type/version of server are you using?
Lars
 
Paul Hennessey
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's it, after the first time any call to logout.do does not get to the controller, it's as if the browser just switches to my home page (index.html) without bothering to send a message to the server. Very strange.

I'm using Tomcat 5.5.9.
 
Lars Vonk
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Paul,
I tried your example application and it worked fine on my pc. Are there no more exception's in your log that gives you more information?

Maybe you can try to delete the compiled jsp's that tomcat uses from tomcat's working directory. That directory can be found in \Tomcat5.5\work\Catalina\localhost. There delete your application directory (Kodaly-v11) there and start tomcat again. (although editing your jsp should force tomcat to recompile your jsp like ramprasad said).

You can also try the TCP Tunnel that comes with Apache SOAP. With this tool you can see what request actually is send to the server (is it really asking for logout.do?). A good quick tutorial can be found here: http://builder.com.com/5100-6389-1049605.html.

Good luck!
 
Paul Hennessey
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I'll try that and let you know how I get on.

Thanks for your help.

Paul
 
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try commenting the <Context path> tags in your server.xml in conf folder for all other apps . Restart and check.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic