IDEA啟動Tomcat報錯


使用IDEA開啟Tomcat時候報了這么個錯:Application Server was not connected before run configuration stop, reason: Unable to ping server at localhost:1099

上網查了查,發現大家給了這么幾個解決方法

1. 換端口

有些人說是端口被占用了,換了一個就可以了,不過我自己試了下,貌似沒用

2.JVM的內存不夠

這個我感覺可能性不大,事實也證明至少我這個不是這個錯

下面就是我這一次出現問題的真正原因:

3.java環境沒有配置

Tomcat是需要jre的,如果你的JAVA_HOME沒有配置,那肯定是起不來的

不過我的java環境是配置過的,但是這個IDEA很奇怪,不止要JAVA_HOME,還要一個JRE_HOME,你需要再在環境變量里面把你的JRE_HOME也配置一下

如果這樣做了,問題還是沒解決,那還是有幾種可能的

1.你的電腦里有多個jre,在IDEA里給Tomcat選jre時候必須要選你配置了環境變量的那個

這里寫圖片描述

2.這種情況也就是我的這種情況,在選擇jre時候或者是在配置JRE_HOME時候,你必須要選jdk目錄下的那個jre,也就是說你要選

C:\Program Files\Java\jdk1.8.0_121\jre

而不是

C:\Program Files\Java\jre1.8.0_131

3.如果還沒有解決,我建議你看一下tomcat的bin目錄下的setclasspath.bat文件,看一下下面加粗的兩行是不是還是不對,如果不對的話,改一下,就可以運行了

rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an “AS IS” BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

rem —————————————————————————
rem Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings
rem are valid and consistent with the selected start-up options and set up the
rem endorsed directory.
rem —————————————————————————

set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_121
set JRE_HOME=C:\Program Files\Java\jdk1.8.0_121\jre

rem Make sure prerequisite environment variables are set

rem In debug mode we need a real JDK (JAVA_HOME)
if “”%1”” == “”debug”” goto needJavaHome

rem Otherwise either JRE or JDK are fine
if not “%JRE_HOME%” == “” goto gotJreHome
if not “%JAVA_HOME%” == “” goto gotJavaHome
echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
echo At least one of these environment variable is needed to run this program
goto exit

:needJavaHome
rem Check if we have a usable JDK
if “%JAVA_HOME%” == “” goto noJavaHome
if not exist “%JAVA_HOME%\bin\java.exe” goto noJavaHome
if not exist “%JAVA_HOME%\bin\javaw.exe” goto noJavaHome
if not exist “%JAVA_HOME%\bin\jdb.exe” goto noJavaHome
if not exist “%JAVA_HOME%\bin\javac.exe” goto noJavaHome
set “JRE_HOME=%JAVA_HOME%”


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM