简体   繁体   中英

Java local Servlet debugging with remote connection

I don't really know where to start with this issue, so I'll just say what's wrong:

I'm running some code in Eclipse that is connecting to our remote "dev" server and presumably using the server there. This means that when I update code in the servlet or any code that actually uses the servlet, no changes are reflected on my local machine.

My question is how can I run the servlet on my local machine and have it connect to the dev server to use its MySQL DB to get the data. Presumably this will allow me to make changes to the servlet locally and still use test data.

I am running Tomcat 5.5 as well, and in Debug Configurations I tell the servlet to run on localhost:8000, but it says it can't connect.

I'm really stuck here and it's disheartening since any changes I make to the code aren't even reflected at all. Moreover I can't see any debug information to tell if my changes are even working at all much less how I intend.

I also tried to make some noticeable changes to parts of the code so that it would be easy to see that I'm affecting it and it doesn't look like they're actually having an effect when I run the code.

tl;dr I'm stupid and don't know what to do.

The servlet is part of a web application; if you have the source code for that app, it's not hard to deploy locally, on Tomcat, and debug it with Eclipse.

If the app is hard-coded to use the dev database, or if you have the configuration files for the app that point to the db, then as long as the database is accessible to your localhost, you're OK; if it's configured separately, you'll need to figure out how to duplicate that configuration.

If Eclipse isn't able to connect to your local Tomcat server, try connecting to it yourself from your browser; that will help you narrow down where the problem is.

You need to get the tomcat container working on your workstation. Have all configuration mimicking what you have in the server environment, all libs, etc.

If you need to connect to the TestDB and you can't ping that from your machine perhaps you can do a tunnel to the Test Server containing the TestDB as follows (assuming MySQL):

ssh -L3306:localhost:3306 youruser@tesetserver

This routes your workstation's port to the testserver, effectively making your local port be the one in the testserver.

Start your web application on tomcat and see how it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM