Java IntelliJ,无法启动简单的 Web 应用程序:无法在 localhost:1099 上 ping 服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19068977/
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
IntelliJ, can't start simple web application: Unable to ping server at localhost:1099
提问by Popcorn
I'm trying to make a simple web app in IntelliJ by following this tutorial: http://wiki.jetbrains.net/intellij/Creating_a_simple_Web_application_for_Tomcat_in_IntelliJ_IDEA_12
我正在尝试按照本教程在 IntelliJ 中制作一个简单的 Web 应用程序:http: //wiki.jetbrains.net/intellij/Creating_a_simple_Web_application_for_Tomcat_in_IntelliJ_IDEA_12
I believe my Tomcat is installed correctly since I see the tomcat pictures when I go to
http://localhost:8080/
我相信我的 Tomcat 安装正确,因为我去的时候看到了 tomcat 图片
http://localhost:8080/
I've followed all the steps up until the part it tells me to run index.jsp
, at which point I get the error:
我已经按照所有步骤进行操作,直到它告诉我运行的部分index.jsp
,此时我收到错误消息:
Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: nodename nor servname provided, or not known
I see this in the log:
我在日志中看到了这一点:
Application Server was not connected before run configuration stop, reason:
Unable to ping server at localhost:1099
This 1099 comes from the JMX port in Run -> Edit Configurations.
这个 1099 来自 Run -> Edit Configurations 中的 JMX 端口。
How do I fix this?
我该如何解决?
回答by bond
To fix this you need add your machine name in the /etc/hosts file to point to localhost(127.0.0.1).
要解决此问题,您需要在 /etc/hosts 文件中添加您的机器名称以指向 localhost(127.0.0.1)。
You can find your machine name by running the following command:
您可以通过运行以下命令找到您的机器名称:
$ hostname
macbook-pro
From the output above you know your hostname is "macbook-pro". Edit "/etc/hosts" file and add that name at the end of line that lists 127.0.0.1
从上面的输出中,您知道您的主机名是“macbook-pro”。编辑“/etc/hosts”文件并在列出 127.0.0.1 的行的末尾添加该名称
127.0.0.1 localhost macbook-pro
Save the file.
保存文件。
Now you IntelliJ should be able to start your server.
现在您的 IntelliJ 应该能够启动您的服务器了。
回答by Beth
This appears to be a problem with the way mac is handling reading the /etc/hosts file. See for example http://youtrack.jetbrains.com/issue/IDEA-96865
这似乎是 mac 处理读取 /etc/hosts 文件的方式的问题。参见例如http://youtrack.jetbrains.com/issue/IDEA-96865
Adding the hostname to the hosts file as bond described should not be required, but it does solve the problem.
不需要按照描述的绑定将主机名添加到主机文件中,但它确实解决了问题。
回答by cagigas
I solve this problem adding the environment variables JAVA_HOME(C:\Program Files\Java\jdkx.x.x_xx) and JRE_HOME.
我通过添加环境变量 JAVA_HOME(C:\Program Files\Java\jdkx.x.x_xx) 和 JRE_HOME 解决了这个问题。
回答by Mike
This error came to me when I configured (wrong) 3 Gb memory where there was none. IntelliJ does shows the real error message (Could not reserve enough space for object heap) in the Output frame. I was confused, and attracted by the message in the Event Log, which is to be ignored in this case.
当我配置(错误的)3 Gb 内存而没有内存时,出现了这个错误。IntelliJ 确实在输出帧中显示了真正的错误消息(无法为对象堆保留足够的空间)。我很困惑,并被事件日志中的消息所吸引,在这种情况下将被忽略。
回答by Trideep Gogoi
FYI Under certain network conditions your hostname may change or be incorrect. If you are on a mac the following will let you set your hostname fairly permanently:
仅供参考 在某些网络条件下,您的主机名可能会更改或不正确。如果您使用的是 mac,以下内容将让您相当永久地设置您的主机名:
sudo scutil --set HostName correct-name
回答by Amalgovinus
On top pointing my hostname to 127.0.0.1 in hosts (just run hostname
in cmd to get it) as well as doing what David GC mentioned, for me the error cleared and debugging worked when I went into the tomcat configuration and changed the debugging startup script from startup.bat
(which was just my monkeying around) back to the catalina.bat start
default.
最重要的是,将我的主机名指向主机中的 127.0.0.1(只需hostname
在 cmd 中运行即可获取它)并执行 David GC 提到的操作,对我而言,当我进入 tomcat 配置并更改调试启动脚本时,错误已清除且调试工作正常从startup.bat
(这只是我的胡闹)回到catalina.bat start
默认值。
回答by vasil todorov
I added my hostname to /etc/hosts on localhost. Added JAVA_HOME but still it showed the same error. In the console, there was output:
我将我的主机名添加到本地主机上的 /etc/hosts。添加了 JAVA_HOME 但仍然显示相同的错误。在控制台中,有输出:
Unable to start as CATALINA_BASE contains a colon (:) character
I solved the problem by going to Edit configurations -> Startup/Connection -> changing CATALINA_BASE value to the tomcat installation folder. Before that, it was
我通过转到编辑配置 -> 启动/连接 -> 将 CATALINA_BASE 值更改为 tomcat 安装文件夹解决了该问题。在此之前,它是
CATALINA_BASE: C:\Program Files\Apache Software Foundation\Tomcat 8.0
which can't be correct on a linux machine ;)
这在 linux 机器上是不正确的;)
回答by Johannes Staehlin
None of the answers above worked for me. In the end I figured out it was an configuration error (I used the android SDK and not Java SDK for compilation).
上面的答案都不适合我。最后我发现这是一个配置错误(我使用了 android SDK 而不是 Java SDK 进行编译)。
Got to [Right Click on Project] --> Open Module Settings --> Module --> [Dependendecies] and make sure you have configured and selected the Java SDK (not the android java sdk)
转到 [右键单击项目] --> 打开模块设置 --> 模块 --> [依赖项] 并确保您已配置并选择了 Java SDK(不是 android java sdk)
回答by fxlex
My problem was that tomcat 8 and higher are not compatible with java 6. Changing to java 7 solved it.
我的问题是 tomcat 8 及更高版本与 java 6 不兼容。更改为 java 7 解决了它。
回答by user5091911
I meet this question when i use intellij 15.0,then i update to 15.02 version. after that, I edit configurations and reset the Default JRE to my own JRE.It works well for me;
我在使用 intellij 15.0 时遇到了这个问题,然后我更新到 15.02 版本。之后,我编辑配置并将默认 JRE 重置为我自己的 JRE。它对我来说效果很好;