简体   繁体   English

从Ubuntu中的jar文件启动tomcat

[英]starting tomcat from jar file in ubuntu

I am using tomcat for the first time. 我是第一次使用tomcat。 I have downloaded and unzipped tomcat 7.0.28. 我已经下载并解压缩了tomcat 7.0.28。 I am able to start and shutdown it form the command prompt by ./startup.sh and ./shutdown.sh. 我可以通过./startup.sh和./shutdown.sh在命令提示符下启动和关闭它。 So far it works fine. 到目前为止,它工作正常。 I can see tomcat homepage and examples also in the browser. 我也可以在浏览器中查看tomcat主页和示例。

But what I want is to profile tomcat server with java profiler. 但是我想要的是使用Java事件探查器来探查tomcat服务器。 For that I want to run it from jar file. 为此,我想从jar文件运行它。 Something like java -jar tomcat_allrequiredclasses.jar. 像java -jar tomcat_allrequiredclasses.jar之类的东西。 Is there any way I can start tomcat server like this ? 有什么办法可以启动tomcat服务器吗? I tried to run jar files of tomcat residing in bin directory but gave me classNotdefined exception(just to try i did that). 我试图运行驻留在bin目录中的tomcat的jar文件,但是给了我classNotdefined异常(只是尝试我做到了)。

Thank you.. 谢谢..

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 . Tomcat需要在JVM启动时设置许多系统属性和类似的东西,因此该脚本是必需的,除非您要使用“嵌入式Tomcat”并使用Tomcat的嵌入式驱动程序编写自己的启动驱动程序

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. 大多数探查器附带一个JVM“代理”,您可以使用-agentpath命令行选项将其配置为在JVM启动时附加。 This is how I attach YourKit Java Profiler, for example: 这就是我附加YourKit Java Profiler的方式,例如:

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

This will launch Tomcat in the usual way, but include the JVM profiler agent so you can then attach to it afterward. 这将以通常的方式启动Tomcat,但包括JVM Profiler代理,因此您以后可以将其附加到它。

Update to include OP's example 更新以包含OP的示例

You want to do this: 您想这样做:

$ 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

I encourage you to use complete paths whenever possible (eg don't use lib/jborat-agent.jar -- add the full path). 我鼓励您尽可能使用完整路径(例如,不要使用lib/jborat-agent.jar添加完整路径)。

Note that by using the -Xss256M , you are setting the thread stack size to 256M and not the heap size. 请注意,通过使用-Xss256M ,您可以将线程堆栈大小设置为256M而不是堆大小。 I suspect you meant to use -Xmx256M to set the maximum size of the heap. 我怀疑您打算使用-Xmx256M来设置堆的最大大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM