aspose file tools*
The moose likes Tomcat and the fly likes Problems getting Tomcat to work without Eclipse IDE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Problems getting Tomcat to work without Eclipse IDE" Watch "Problems getting Tomcat to work without Eclipse IDE" New topic
Author

Problems getting Tomcat to work without Eclipse IDE

Kyle R Hunt
Greenhorn

Joined: Feb 16, 2009
Posts: 8
I created a Java Servlet with Eclipse and WDT. I had eclipse create the Tomcat server, and all config files and everything.

I trigger the Servlet using an HTML form I created.

When I launch the form threw Eclipse, everything works fine. The Form loads in Eclipse, I enter the information and the Servlet works correctly. When I package as a WAR file, using Eclipse's exporter, add the WAR to the webapps directory of the Tomcat server and launch the Tomcat server with the startup bat file, the form loads fine, but I get a HTTP Post 405 error when I trigger the Servlet.

HTTP Status 405 - HTTP method POST is not supported by this URL

I tried changing my web.xml file, but that didn't help at all. I am very new to Tomcat and would appreciate any suggestions. Below is my web.xml file. ContactUs.HTML is the form page, and ContactUsLeadCreator is the Servlet.
Let me know if you need me to post anything else.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

Does the servlet have a doPost() implementation?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Kyle R Hunt
Greenhorn

Joined: Feb 16, 2009
Posts: 8
The Servlet does have a method
protected void doPost(HttpServletRequest request, HttpServletResponse response)

And I have tried adding the following to my web.xml file with no change:


I don't know of anything else I need to do to implement doPost.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

This is not a security issue.

Please go back through your posts adding code tags to make the XMl readable, and post your servlet code.
Kyle R Hunt
Greenhorn

Joined: Feb 16, 2009
Posts: 8
I added the security constraint information because I had found information on a web site that said that had worked for someone else.

Below is my Servlet code, I am passing the data to a web service. I have previously used all the custom libraries, and have added all needed libraries to the %BASEDIR%/lib folder

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

What's up with this line?

Do you know what this will do? If not, why is it there?
Kyle R Hunt
Greenhorn

Joined: Feb 16, 2009
Posts: 8
It is there because Eclipse put it in when it created the Servlet. I assumed there was a doPost method I was overwriting and that will call the original doPost method in HttpServlet.

If I remove the line I do not get errors, however I do not get post back at all. just a white page. And no attempt to log into the web service. No abnormal log entries either.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

The doPost() implementation of the base class reports that POSTs are not supported. In other words, don't ever call it.

OK, now you need to find out what else is happening. What have you done to debug the "white page"?
Kyle R Hunt
Greenhorn

Joined: Feb 16, 2009
Posts: 8
I have tried running it through eclipse again, that worked fine as well, no changes with or without the super call.
I have discovered the servlet is executing, and am trying to figure out exactly how far it gets now, using System.out.println calls and seeing how many print. I will get back to you after I do some more research. Thank you for your help to this point, and for fixing the 405 error
Kyle R Hunt
Greenhorn

Joined: Feb 16, 2009
Posts: 8
The line that is failing is This line is what actually calls the web service.
However this line handles logging into the web service and is not actually hitting the web service, according to the logs on the web service machine.

I am also getting a warning on the Tomcat command line that Attachment support is disabled. I also get this line in Eclipse, but everything still works, so I have been ignoring it. I'm not sure if this is a feature I am using but I will add the Jar to the lib folder.
Kyle R Hunt
Greenhorn

Joined: Feb 16, 2009
Posts: 8
I fixed the Attachment support error, added a few ant jars to the %BASEDIR%/lib folder.

The error I am getting is java.net.ConnectException: Connection refused: connect
full axis fault error screen shot is attached.

The error is thrown on line

which creates the soap object and sends it to the web service server.

However I am still not getting a login attempt on the server side.
Thank you for your help to this point, and for any suggestions anyone can give me.



[Thumbnail for untitled.JPG]

Kyle R Hunt
Greenhorn

Joined: Feb 16, 2009
Posts: 8
All problems have been solved. Thank everyone for their help and for maintaining this site.
Original error was
HTTP Status 405 - HTTP method POST is not supported by this URL

This was caused because the super call

disabling POST when called. Removing this line fixed the initial error. This line was added to the class file upon creation in Eclipse. This error is NOT triggered when Eclipse is used to launch the Tomcat server.
Second error was the httpURLConnectVariable.getResponseCode() method was throwing a null pointer exception, causing login to fail. This caused a number of other confusing errors, see past posts. The underlying problem here was a bad urll. Adding the correct URL to the config file solved this problem.

Thank everyone for their kind curious speedy responses.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems getting Tomcat to work without Eclipse IDE