处理在IntelliJ IDEA中调试Servlet时出现“Error running Tomcat ...”的问题

昨天配置好Tomcat 8.0后在IntelliJ IDEA中顺利地对安卓手机的服务器Servlet程序进行了Debug和Run测试,


今天上班再次使用Debug时出现了以下提示:

“Error running Tomcat 8.0: Unable to open debugger port (127.0.0.1:3961): java.net.SocketException "socket closed" (moments ago)”


使用Run的时候出现如下提示:

“Error running Tomcat 8.0: Address localhost:8080 is already in use (moments ago)”


在网上搜索相关问题时有两种解决方案:

1.通过在IDEA对相关端口进行配置来解决(我试了没有作用)

2.通过将占用相关端口的程序给强制结束来解决(不推荐,我没有试)


后来我分析可能是我安装的Apache Tomcat 与IntelliJ IDEA启动的服务存在冲突,而是就将Apache Tomcat的服务关掉,再次进行Debug和Run测试时已经没有问题了。

我们可以将Apache Tomcat服务设置为手动启动,避免下次再发生上述问题。



分享给网友,希望对你有所帮忙。人人为我、我为人人!


  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
============================================<br><br>Out of the box, Tomcat 5.5 requires the Java 2 Standard Edition Runtime<br>Environment (JRE) version 5.0 or later. However, you can also run Tomcat<br>5.5 on earlier versions of the JRE, as detailed below.<br><br>=============================<br>Running With JRE 5.0 Or Later<br>=============================<br><br>(1) Download and Install the J2SE Runtime Environment (JRE)<br><br>(1.1) Download the Java 2 Standard Edition Runtime Environment (JRE),<br> release version 5.0 or later, from http://java.sun.com/j2se.<br><br>(1.2) Install the JRE according to the instructions included with the<br> release.<br><br>(1.3) Set an environment variable named JAVA_HOME to the pathname of<br> the directory into which you installed the JRE, e.g. c:\j2sdk5.0<br> or /usr/local/java/j2sdk5.0.<br><br><br>(2) Download and Install the Tomcat Binary Distribution<br><br>NOTE: As an alternative to downloading a binary distribution, you can create<br>your own from the Tomcat source repository, as described in "BUILDING.txt".<br>If you do this, the value to use for "${catalina.home}" will be the "dist"<br>subdirectory of your source distribution.<br><br>(2.1) Download a binary distribution of Tomcat from:<br><br> http://tomcat.apache.org<br><br>(2.2) Unpack the binary distribution into a convenient location so that the<br> distribution resides in its own directory (conventionally named<br> "apache-tomcat-[version]"). For the purposes of the remainder of this document,<br> the symbolic name "$CATALINA_HOME" is used to refer to the full<br> pathname of the release directory.<br><br><br>(3) Start Up Tomcat<br><br>(3.1) Tomcat can be started by executing the following commands:<br><br> $CATALINA_HOME\bin\startup.bat (Windows)<br><br> $CATALINA_HOME/bin/startup.sh (Unix)<br><br>(3.2) After startup, the default web applications included with Tomcat will be<br> available by visiting:<br><br> http://localhost:8080/<br><br>(3.3) Further information about configuring and running Tomcat can be found in<br> the documentation included here, as well as on the Tomcat web site:<br><br> http://tomcat.apache.org<br><br><br>(4) Shut Down Tomcat<br><br>(4.1) Tomcat can be shut down by executing the following command:<br><br> $CATALINA_HOME\bin\shutdown (Windows)<br><br> $CATALINA_HOME/bin/shutdown.sh (Unix)<br><br><br><br>====================================<br>Running Tomcat With J2SE Version 1.4<br>====================================<br><br>(1) Obtain the compat package:<br><br>(1.1) Download the compat package from the binary download site:<br> http://tomcat.apache.org<br><br> * Or build this package yourself from the source code: see <br> "BUILDING.txt" in this directory.<br><br>(2) Unzip the package in $CATALINA_HOME. It will place the XML<br> parser APIs and Xerces implementation in the common/endorsed<br> directory, and the JMX API jar (jmx.jar from Sun) in the bin<br> directory.<br><br>(3) Follow the same directions for starting and stopping the<br> server as if you were using J2SE 5.0.<br><br><br>==================================================<br>Advanced Configuration - Multiple Tomcat Instances<br>==================================================<br><br>In many circumstances, it is desirable to have a single copy of a Tomcat<br>binary distribution shared among multiple users on the same server. To make<br>this possible, you can pass a "-Dcatalina.base=$CATALINA_BASE" argument when<br>executing the startup command (see (2)). In this<br>"-Dcatalina.base=$CATALINA_BASE" argument, replace $CATALINA_BASE with the<br>directory that contains the files for your 'personal' Tomcat instance.<br><br>When you use this "-Dcatalina.base=$CATALINA_BASE" argument, Tomcat will<br>calculate all relative references for files in the following directories based<br>on the value of $CATALINA_BASE instead of $CATALINA_HOME:<br><br>* conf - Server configuration files (including server.xml)<br><br>* logs - Log and output files<br><br>* shared - For classes and resources that must be shared across all web<br> applications<br><br>* webapps - Automatically loaded web applications<br><br>* work - Temporary working directories for web applications<br><br>* temp - Directory used by the JVM for temporary files (java.io.tmpdir)<br><br>If you do not pass the "-Dcatalina.base=$CATALINA_BASE" argument to the<br>startup command, $CATALINA_BASE will default to the same value as $CATALINA_HOME,<br> which means that the same directory is used for all relative path resolutions.<br><br>The administration and manager web applications, which are defined in the<br>$CATALINA_BASE/conf/Catalina/localhost/admin.xml<br>and <br>$CATALINA_BASE/conf/Catalina/localhost/manager.xml files, will<br>not run in that configuration, unless either:<br>- The path specified in the docBase attribute of the Context element is made<br> absolute, and replaced respectively by $CATALINA_HOME/server/webapps/admin<br> and $CATALINA_HOME/server/webapps/manager<br>- Both web applications are copied or moved to $CATALINA_BASE, <br> and the path specified in the docBase attribute of the Context<br> element is modified appropriately.<br>- Both web applications are disabled by removing<br> $CATALINA_BASE/conf/Catalina/localhost/admin.xml<br> and<br> $CATALINA_BASE/conf/Catalina/localhost/manager.xml.<br><br><br>================<br>Troubleshooting<br>================<br><br>There are only really 3 things likely to go wrong during the stand-alone<br>Tomcat install:<br><br>(1) The most common hiccup is when another web server (or any process for that<br> matter) has laid claim to port 8080. This is the default HTTP port that<br> Tomcat attempts to bind to at startup. To change this, open the file:<br><br> $CATALINA_HOME/conf/server.xml<br><br> and search for '8080'. Change it to a port that isn't in use, and is<br> greater than 1024, as ports less than or equal to 1024 require superuser<br> access to bind under UNIX.<br><br> Restart Tomcat and you're in business. Be sure that you replace the "8080"<br> in the URL you're using to access Tomcat. For example, if you change the<br> port to 1977, you would request the URL http://localhost:1977/ in your browser.<br><br>(2) An "out of environment space" error when running the batch files in<br> Windows 95, 98, or ME operating systems.<br><br> Right-click on the STARTUP.BAT and SHUTDOWN.BAT files. Click on<br> "Properties", then on the "Memory" tab. For the "Initial environment" field,<br> enter in something like 4096.<br><br> After you click apply, Windows will create shortcuts which you can use<br> to start and stop the container.<br><br>(3) The 'localhost' machine isn't found. This could happen if you're behind a<br> proxy. If that's the case, make sure the proxy configuration for your<br> browser knows that you shouldn't be going through the proxy to access the<br> "localhost".<br><br> In Netscape, this is under Edit/Preferences -> Advanced/Proxies, and in<br> Internet Explorer, Tools -> Internet Options -> Connections -> LAN Settings.<br>
对于IntelliJ IDEA出现"Error running AdminServerApp. Command line is too long."错误,您可以尝试以下解决方法: 1. 使用更短的JVM参数:在IntelliJ IDEA,打开您的项目,然后转到"Run" -> "Edit Configurations"。在配置窗口,找到您的启动配置,并在"VM options"字段尝试缩短JVM参数。可以删除不必要的参数或缩短参数的名称来减少命令行的长度。 2. 使用配置文件:在IntelliJ IDEA,创建一个运行配置文件。转到"Run" -> "Edit Configurations",然后点击"+"按钮创建一个新的配置。在配置窗口,选择您的项目和主类,并在"Program arguments"字段指定命令行参数。这样可以将命令行参数整理到一个配置文件,避免命令行过长的问题。 3. 使用脚本:创建一个脚本文件,将命令行参数写在脚本,然后在IntelliJ IDEA运行该脚本。类似于配置文件的方式,通过脚本可以避免命令行过长的限制。 4. 增加命令行长度限制:在某些操作系统,有一定的命令行长度限制。您可以尝试增加该限制。对于Windows系统,可以使用`regedit`打开注册表编辑器,导航到`HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment`,然后找到或创建一个名为`CommandLineLength`的DWORD值,并将其设置为较大的值。对于Linux系统,可以编辑`/etc/security/limits.conf`文件,增加`env_max`的值。 这些方法的一种可能会解决您遇到的问题。如果问题仍然存在,建议您进一步检查和优化您的命令行参数,或者查阅IntelliJ IDEA的文档或寻求相关技术支持以获取更多帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值