Java,Spring,Tomcat,挂在“INFO:Initializing Spring root WebApplicationContext”,我想我改变了整个系统允许的内存堆
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5147254/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java, Spring, Tomcat, hangs at "INFO: Initializing Spring root WebApplicationContext", I think I changed the allowed memory heap for my entire system
提问by Rick
I was playing around with the Java memory heap allocation and I think I did something that set it not just for any specific tomcat folder but for the entire system as I can't run my application in Spring or with a custom tomcat folder that I had been also using for testing. When I try to run the application, it just hangs at "INFO: Initializing Spring root WebApplicationContext".
我在玩 Java 内存堆分配,我想我做了一些事情,不仅为任何特定的 tomcat 文件夹而且为整个系统设置了它,因为我无法在 Spring 中运行我的应用程序或使用我拥有的自定义 tomcat 文件夹也一直用于测试。当我尝试运行应用程序时,它只是挂在“信息:初始化 Spring 根 WebApplicationContext”处。
I am not fully clear on how I could have set this on the Linux command line by doing something like "export CATALINA_OPTS="-Xms2000m -Xmx4500m"
or "JAVA_OPTS="-Xms2000m -Xmx4500m -XX:MaxPermSize=4500m"
我不完全清楚如何通过执行类似"export CATALINA_OPTS="-Xms2000m -Xmx4500m"
或"JAVA_OPTS="-Xms2000m -Xmx4500m -XX:MaxPermSize=4500m"
I think I accidentally put the settings I had meant for my cloud server (which has a higher amount of memory) so I gave it more memory allocation than my entire system has.
我想我不小心为我的云服务器(它有更多的内存)设置了我的设置,所以我给了它比整个系统更多的内存分配。
I would appreciate any help if anyone can let me know if it is possible I did this and if this could be causing the issue and how I can get an output from my system as to the current allocation so I can check / change it, I have tried "export CATALINA_OPTS="-Xms2000m -Xmx4500m"
but it still won't work for me.
如果有人可以让我知道我是否可以这样做,以及这是否可能导致问题以及如何从系统中获取有关当前分配的输出,以便我可以检查/更改它,我将不胜感激,我将不胜感激已经尝试过,"export CATALINA_OPTS="-Xms2000m -Xmx4500m"
但它仍然对我不起作用。
I would like to restore everything to default settings. I normally set the memory heap allocation in the /bin/startup.sh file in the tomcat folder but I had forgotten this, I think, and was experimenting with things on the command line.
我想将所有内容恢复为默认设置。我通常在 tomcat 文件夹中的 /bin/startup.sh 文件中设置内存堆分配,但我想我忘记了这一点,并且正在命令行上进行试验。
Thanks
谢谢
采纳答案by matt b
Check all of the log files for Tomcat. It's possible that the startup of the Spring WebApplicationContext is encountering errors, but logging it elsewhere.
检查 Tomcat 的所有日志文件。Spring WebApplicationContext 的启动可能遇到错误,但将其记录在其他地方。
Setting the max heap size too large for Tomcat sounds like a red herring to me. If the initial heap size argument is larger than the maximum size of memory on the system, the Java process will fail immediately - Tomcat will not get to the point of initializing your Spring application.
对 Tomcat 而言,将最大堆大小设置得太大对我来说就像是一个红鲱鱼。如果初始堆大小参数大于系统上的最大内存大小,Java 进程将立即失败 - Tomcat 将无法初始化 Spring 应用程序。
回答by meriton
Isn't finding bugs what debuggers are for? Why not simply start your Tomcat in debug mode, wait until it "hangs", and find out what it is doing by suspending the relevant thread and looking at the stack trace?
调试器不是用来发现错误的吗?为什么不简单地以调试模式启动 Tomcat,等到它“挂起”,然后通过挂起相关线程并查看堆栈跟踪来找出它在做什么?
Or even simpler, do a "thread dump" once the app hangs?
或者更简单的是,一旦应用程序挂起就执行“线程转储”?
回答by sumit
See if you can increase the server timeout if you are running it from an IDE. From command line, you'll have to wait. If the problem persists, try cleaning /reloading the application
如果从 IDE 运行它,看看是否可以增加服务器超时。从命令行,您将不得不等待。如果问题仍然存在,请尝试清理/重新加载应用程序