从 ubuntu 中的 jar 文件启动 tomcat [英] starting tomcat from jar file in ubuntu

查看:43
本文介绍了从 ubuntu 中的 jar 文件启动 tomcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是第一次使用tomcat.我已经下载并解压了 tomcat 7.0.28.我可以通过 ./startup.sh 和 ./shutdown.sh 从命令提示符启动和关闭它.到目前为止它工作正常.我也可以在浏览器中看到 tomcat 主页和示例.

I am using tomcat for the first time. I have downloaded and unzipped tomcat 7.0.28. I am able to start and shutdown it form the command prompt by ./startup.sh and ./shutdown.sh. So far it works fine. I can see tomcat homepage and examples also in the browser.

但我想要的是用 java profiler 来分析 tomcat 服务器.为此,我想从 jar 文件中运行它.像 java -jar tomcat_allrequiredclasses.jar 之类的东西. 有什么办法可以像这样启动 tomcat 服务器吗?我试图运行驻留在 bin 目录中的 tomcat jar 文件,但给了我 classNotdefined 异常(只是为了尝试我这样做).

But what I want is to profile tomcat server with java profiler. For that I want to run it from jar file. Something like java -jar tomcat_allrequiredclasses.jar. Is there any way I can start tomcat server like this ? I tried to run jar files of tomcat residing in bin directory but gave me classNotdefined exception(just to try i did that).

谢谢..

推荐答案

Tomcat 需要在 JVM 启动时设置很多系统属性和诸如此类的东西,因此除非您打算使用嵌入式 Tomcat",否则脚本是必需的并使用 Tomcat 的嵌入式编写您自己的启动驱动程序司机.

Tomcat needs a lot of system properties and things like that to be set at JVM launch, so the script is necessary unless you are going to use "embedded Tomcat" and write your own launch driver using Tomcat's embedded driver.

我认为仅附加一个分析器就太过分了.大多数分析器都带有一个 JVM代理",您可以将其配置为使用 -agentpath 命令行选项在 JVM 启动时附加.这是我附加 YourKit Java Profiler 的方式,例如:

I think that's overkill for just attaching a profiler. Most profilers come with a JVM "agent" that you can configure to attach on JVM launch using the -agentpath command-line option. This is how I attach YourKit Java Profiler, for example:

CATALINA_OPTS="-agentpath:/path/to/yourkit/libyjpagent.so=${yourkit.options}"
$CATALINA_HOME/bin/startup.sh

这将以通常的方式启动 Tomcat,但包括 JVM 分析器代理,以便您之后可以附加到它.

This will launch Tomcat in the usual way, but include the JVM profiler agent so you can then attach to it afterward.

更新以包含 OP 的示例

你想这样做:

$ export CATALINA_OPTS="-javaagent:lib/jborat-agent.jar -Xss256m -Xms256m  \ -Dch.usi.dag.jborat.exclusionList="conf/exclusion.lst" \ -Dch.usi.dag.jp2.dumpers="ch.usi.dag.jp2.dump.xml.XmlDumper" \ -Xbootclasspath/p:./lib/Thread_JP2.jar:lib/jborat-runtime.jar:lib/jp2-runtime.ja‌​r"
$ $CATALINA_HOME/bin/startup.sh

我鼓励您尽可能使用完整路径(例如,不要使用 lib/jborat-agent.jar -- 添加完整路径).

I encourage you to use complete paths whenever possible (e.g. don't use lib/jborat-agent.jar -- add the full path).

请注意,通过使用 -Xss256M,您将线程堆栈大小设置为 256M 而不是堆大小.我怀疑您打算使用 -Xmx256M 来设置堆的最大大小.

Note that by using the -Xss256M, you are setting the thread stack size to 256M and not the heap size. I suspect you meant to use -Xmx256M to set the maximum size of the heap.

这篇关于从 ubuntu 中的 jar 文件启动 tomcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆