我的 jsp 页面从未加载
我有一个 J2EE Web 应用程序,它在服务器上的共享 Tomcat 上运行。 有时网站根本无法加载,几乎需要 5-10 分钟!在此期间它从未加载或显示任何错误,并且在尝试多次后,它最终显示错误:(111) 连接被拒绝
。 我不知道是什么原因。谁能告诉我可能是什么问题?是我的应用程序还是托管公司? 顺便说一句,网站持续工作 1.2 天,然后就会发生上述情况。
该应用程序是 JSP 并使用 Hibernate 连接到 MySQL 数据库。
I have a J2EE web application, that runs on a shared Tomcat on a server.
Sometimes the website never loads, takes almost 5-10 minutes! It never loads or show any error during that time, and after trying many times, it finally shows the error: (111) connection refused
.
I dont know what the cause is. Can anyone tell me what the problem could be? Is it my application or the hosting company ?
By the way the website keeps working for 1,2 days and then the above scenario happens.
The application is JSP and uses Hibernate to connect to a MySQL database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试在服务器上运行 jstack 命令一旦挂起。该命令将为正在运行(或阻塞)的线程创建一个非常有用的线程转储,您可以找出导致问题的原因。
Try running the jstack command on the server when as soon as it hangs. The command will create a very helpful thread dump of your running (or blocked) threads and you can figure out what is causing the trouble.
我在我的部署服务器上观察到了非常类似的情况,但还没有机会正确地追踪它(该服务器只安装了 JRE,没有安装完整的 JDK,而且它也有严格的防火墙)。通过观察日志,我知道它显然只是在(主要)web应用程序的初始化阶段挂起,并且在那段时间没有发生任何其他事情(通过观察系统日志;整个系统当时处于静止状态,没有进程可运行),而且我知道它似乎只在启动整个容器时发生,而在将 Web 应用程序安装到已运行的容器中时不会。
这让我推测问题是由于 Java 运行时和 Web 应用程序内部进行的密集类加载之间的某种令人不快的交互造成的。例如,如果 JIT 数据在真正完成之前就被 GC 从弱哈希映射中刷新,则可能会将所有内容推入代码中某个较慢的路径,并具有(许多)更多等待状态。 (我过去曾寻找过这样的东西;它们非常很难追踪,因为一切仍然表现正常,即使不是最佳的,而且它很可能是跨多个层面的问题 我最好的建议
是要
I've observed something very much like this with my deployment server, and not yet had the opportunity to chase it down properly (that server only has the JRE installed, not the full JDK, and it's heavily firewalled too). From watching the logs, I know that it is apparently just hanging during the initialization stage of the (principal) webapp, and nothing else is happening during that time (from watching system logs; the whole system is quiescent at the time, with no processes being runnable) and I know that it only seems to happen when booting the whole container, and not when installing the webapp into an already-running container.
That leads me to speculate that the problem is due to some kind of unpleasant interaction between the Java runtime and the intensive class loading going on inside the webapp. For example, if there's JIT data that's getting flushed by the GC from a weak hash map before it's really finished with, that could push everything into some slower path through the code with (many) more wait states. (I've hunted such things in the past; they're very hard to track down because everything is still behaving correctly, if non-optimally, and it could well be a problem across many levels of an application.)
My best advice is to
我终于找到了问题:
正如您在上面看到的, getSessionFactory() 方法总是导致 buildSessionFactory() ,所以每次我调用 hibernateUtil.getSessionFactory() 时 在我的代码中的任何位置,hibernate 与数据库建立了越来越多的连接,并且使数据库无响应:)
i finally find the problem :
as you can see above the
getSessionFactory()
method always leads tobuildSessionFactory()
so every time that i calledhibernateUtil.getSessionFactory()
any where in my code, hibernate has made more and more connections to database and it made database non responsive :)