Linux Tomcat Intellij 理念:远程部署
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14085371/
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
Tomcat Intellij Idea: Remote deploy
提问by ?mer Faruk Almal?
RackSpace Cloud Server Ubuntu-12.04, Intellij Idea-11.1.2, Windows-8, Tomcat-7.0.26, JDK-6.
RackSpace 云服务器 Ubuntu-12.04、Intellij Idea-11.1.2、Windows-8、Tomcat-7.0.26、JDK-6。
On Intellij Idea when i try to run jsf project on my remote Tomcat 7 server it says:
在 Intellij Idea 上,当我尝试在远程 Tomcat 7 服务器上运行 jsf 项目时,它说:
Error running servername: Unable to connect to the ip-address:1099
运行服务器名称时出错:无法连接到IP 地址:1099
It seems problem is about JNDI port which is 1099 but I couldn't activate it I guess. Tomcat config is sth. like that:
似乎问题是关于 JNDI 端口的,它是 1099,但我猜我无法激活它。Tomcat 配置是…… 像那样:
What I've tried?
我试过什么?
Setting CATALINA_OPTS or JAVA_OPTS on the server side with:
使用以下命令在服务器端设置 CATALINA_OPTS 或 JAVA_OPTS:
CATALINA_OPTS=-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=1099
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
and
和
JAVA_OPTS=-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=1099
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
But this one did not work, any ideas?
但是这个没有用,有什么想法吗?
采纳答案by ?mer Faruk Almal?
My answer to my question:
我对我的问题的回答:
The correct way to deploy remotely is editing JAVA_OPTS environment variable on the remote server. Just enter the command below:
远程部署的正确方法是在远程服务器上编辑 JAVA_OPTS 环境变量。只需输入以下命令:
export JAVA_OPTS="-Dcom.sun.management.jmxremote=
-Dcom.sun.management.jmxremote.port=1099
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false"
If that's not going to work and if you don't have any obsession to deploy your website via Intellij Idea, I've got the solution for this problem. To be able to run your website under Tomcat, you can/should get artifact in form of .war
file.
如果这行不通,并且您不着迷于通过 Intellij Idea 部署您的网站,那么我已经找到了解决此问题的方法。为了能够在 Tomcat 下运行您的网站,您可以/应该以.war
文件的形式获取工件。
It can be done in Intellij from project settings(ctrl+alt+shift+s) then hit the plus button and add new artifact(web:application archieve)
它可以在 Intellij 中从项目设置(ctrl+alt+shift+s)中完成,然后点击加号按钮并添加新工件(web:application archieve)
After rebuilding the artifact, .war
file can be seen in project-folder\out\artifacts
. Next, you should place this file into your tomcat/webapps
folder.
重建工件后,.war
文件可以在project-folder\out\artifacts
. 接下来,您应该将此文件放入您的tomcat/webapps
文件夹中。
For example if you are using Tomcat-7, the folder that I mean exists in /var/lib/tomcat7/webapps
. Before copying your .war file
you should rename it as ROOT.war
. This provides to access your site directly by http://youripaddress:8080
. After restarting Tomcat7 service you can access the site.
例如,如果您使用的是 Tomcat-7,我所说的文件夹存在于/var/lib/tomcat7/webapps
. 在复制之前,.war file
您应该将其重命名为ROOT.war
. 这提供了直接通过 访问您的网站http://youripaddress:8080
。重启Tomcat7服务后即可访问该站点。
But not finished yet, you can debug your project remotely like you are debugging your project at your local machine with Intellij Idea. Open Run/Debug Configuration in Idea, hit the plus button and there must be Remote
. This is the way to debug your projects for application servers like JBoss, Glassfish as well in Idea. Enter your host and port numbers, select your project as a module.
但还没有完成,您可以远程调试您的项目,就像您在本地机器上使用 Intellij Idea 调试您的项目一样。在Idea中打开Run/Debug Configuration,点击加号按钮,必须有Remote
. 这是在 Idea 中为 JBoss、Glassfish 等应用程序服务器调试项目的方法。输入您的主机和端口号,选择您的项目作为模块。
Before starting to debug, as Intellij says you should give the following parameter to your server JVM:
在开始调试之前,正如 Intellij 所说,您应该为服务器 JVM 提供以下参数:
JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
To be able to do that in Ubuntu and for Tomcat-7, modified the catalina.sh file in usr/share/tomcat7
folder. I inserted the parameter above of the if [ -z "$LOGGING_MANAGER" ]; then
line. It must be on the middle part of the file. Then you should be able to debug your project with Intellij Idea.
为了能够在 Ubuntu 和 Tomcat-7 中做到这一点,修改了文件usr/share/tomcat7
夹中的 catalina.sh 文件。我在该if [ -z "$LOGGING_MANAGER" ]; then
行的上方插入了参数。它必须位于文件的中间部分。然后您应该能够使用 Intellij Idea 调试您的项目。