我们如何调试我们的生产 Struts/Hibernate 应用程序?

发布于 2024-12-11 02:20:50 字数 519 浏览 1 评论 0原文

因此,我们使用 Netbeans 6.9.1,将代码推送到 SVN 服务器 (dev),并运行连接到 DEV 计算机上的 MySQL 的本地 Web 服务器 (Tomcat)。我们可以在调试模式下运行并单步执行我们的代码。

但是,我们随后将 WAR 文件推送到生产机器(在生产数据库上)。这台机器与开发完全分开。

但我们不断遇到问题。诸如 Hibernate 中的 null id 当我们对所有列进行三次检查等时,

我们需要的是一种将调试器附加到 Production 用户并单步执行代码的方法。

我们有什么选择?

感谢您的任何建议。

编辑

我想发布更多信息。感谢那些提出建议的人。

首先,我们的生产服务器托管 3 个应用程序(以及生产数据库)。我们遇到最多问题的应用程序只有一个用户,并且数据与我们在开发中的数据几乎相同。我们遇到了 JDBC 事务问题,并且无法找出它们来自何处。

So, we use Netbeans 6.9.1, push our code to a SVN server (dev) and run local webservers (Tomcat) that connect to MySQL on a DEV machine. We can run in debug mode and step through our code.

However, we then take our WAR file, push to a production machine (on a production database). This machine is completely separate from dev.

But we run into constant problems. Things like null id in Hibernate when we have triple-checked all columns, etc.

What we need is a way to attach a debugger to a PRODUCTION user and step through the code.

What are our options?

Thanks for any advice.

EDIT

I wanted to post a little more information. Thanks for those that have offered suggestions.

First, our production server hosts 3 apps (along with the prod db). The app we are having the most problems with just has one user and the data is almost identical to what we have in dev. We are having transaction problems with JDBC and can't find out where they are coming from.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夏九 2024-12-18 02:20:50

如果您确实想将调试器附加到正在运行的生产服务器,Java 完全有能力做到这一点。首先,使用以下命令运行服务器/JVM:

-Xrunjdwp:transport=dt_socket,address=8778,server=y,suspend=n

现在,您可以使用 EclipseIntelliJ IDEA

然而,有一些问题:

  • 您需要在指定端口上对生产服务器进行 TCP/IP 访问。可能会涉及一些防火墙/SSH 隧道。

  • 默认情况下,您的调试器可能会在遇到断点时挂起所有线程。确保您只暂停当前线程,否则您将冻结整个服务器。

  • ...是的,远程调试是危险,尤其是在生产中。

  • 处于调试模式/侦听调试连接的 JVM 可能会稍微慢一些(虽然还没有看到)。

If you really want to attach debugger to a running production server, Java is fully capable of doing this. First, run you server/JVM with the following commands:

-Xrunjdwp:transport=dt_socket,address=8778,server=y,suspend=n

Now you can attach your IDE using prd_server:8788 address in Eclipse or IntelliJ IDEA.

However there are few gotchas:

  • You need to have TCP/IP access to production server on a specified port. Probably some firewall/SSH tunnelling will be involved.

  • By default your debugger might suspend all threads when it hits the breakpoint. Make sure you only suspend the current one, otherwise you will freeze the whole server.

  • ...yes, remote debugging is dangerous, especially on production.

  • JVM in debug mode/listening for debug connections might be slightly slower (haven't seen it though).

秋风の叶未落 2024-12-18 02:20:50

可以配置 Tomcat 以允许远程调试器连接,但我不建议这样做,因为在附加调试器时会显着减慢 JVM 的执行速度,而且我相信每当遇到断点时,所有线程的执行都会暂停。

更好地使用开发服务器上的生产数据重新创建问题,添加更多日志记录等。

You can configure Tomcat to allow remote debugger connections, but I would not advise doing so as you will significantly slow down execution of the JVM while a debugger is attached, and I believe whenever a breakpoint is hit the execution of all threads will be paused.

Much better to recreate the problem using the production data on a dev server, add more logging, etc etc.

无需解释 2024-12-18 02:20:50

在尝试调试 Prod 之前,请将 Prod 数据迁移到 Dev 环境并在那里进行调试。如果您对非生产环境中的生产数据制定了安全策略,请根据需要清理数据。

如果问题与数据相关,您应该很快解决它。

Before you attempt to debug Prod, migrate your Prod data down to a Dev env and debug there. If you have a security policy against Prod data in a non-Prod env, sanitize the data as needed.

If the issue is data related, you should hit it fairly quickly.

自我难过 2024-12-18 02:20:50

如果您愿意远程调试生产环境,请注意它会减慢您的应用程序的速度。但如果您无法在开发服务器上复制问题,请按照以下步骤远程调试应用程序: -

  1. 确保您的生产服务器打开调试端口以远程连接调试。
  2. 不同应用程序服务器的调试设置有所不同
  3. 如果您使用 Eclispe,则右键单击项目并转到调试配置,输入生产服务器名称/IP 和端口号,然后单击调试按钮。确保您的服务器打开了调试端口

让我们知道您正在使用哪个生产服务器。

If you are willing to debug the production environment remotely than beware it will slow down your applicaton. But in case if you are not able to replicate the issue on development server than please follow the steps to remotely debug the applicaton : -

  1. Make sure your production server is having debug port open to connect debug remotely.
  2. Debug setting differ for different-different application server
  3. If you are using Eclispe than right click on the project and go to debug configuration enter the production server name/IP and the port number and than hit the debug button. Mkae sure your server is having debug port open

Let us know which production server you are using.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文