• 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
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Tomcat servlet works on local machine but breaks on server

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
m assuming I'm doing something simple and stupid since I'm new to this. But I have a working Tomcat servlet. On my local machine, when the connection is created with:



it works just fine. In fact, I accidentally loaded it to the server with that and of course it still worked :P.

However, whenever I try to run the servlet on the server itself:



it dies, saying that a connection cannot be established to the server. To be honest, I used this https://www.digitalocean.com/community/tutorials/install-tomcat-9-debian-9 to set up the server.  I thought I even briefly disabled the firewall.
 
Ranch Foreman
Posts: 96
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"It doesn't work" unfortunately isn't that much of an information. Unless the Exception is silently suppressed there's a rather helpful IOException telling you the issue. Most likely either a no route to host meaning the dns resolution failed or a connection refused which often means the firewall is blocking (unless the server isn't running at all).
So, to help us to help you to figure out the issue it's best to show us the error message (please post text output as text rather than taking a screenshot as it's hard to read on a mobile device).
I'm sure one here can spot the issue and give you some advice.
 
Saloon Keeper
Posts: 6385
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks like JavaScript code - is there further information (or maybe error messages) in the browser console?
 
Calvin Dobson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I looked in the console.  The only message I seem to be able to get out of it goes along the lines of "could not connnect to server."  It doesn't include any other information about where in the protocol the process failed.  
 
Calvin Dobson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I've managed to tease out some more debugging information:

This is Debain 9 and tomcat 9.
Firefox won't give an error code, chrome gives: failed: Error during WebSocket handshake: Unexpected response code: 500.  I think the error on the tomcat side is:




I tried it on FreeBSD, and this just changed the error to 404 from 500.  However  I also noticed that my subroutine which starts with

and prints a simple website works fine on my computer, but it doesn't work so well on the remote server.  Could a problem with web.xml cause this issue?
 
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic