How do I place jars in jetty/lib on the jetty classpath?

故事扮演 提交于 2019-12-01 17:30:44

What documentation are you reading? (link please)

The whole concept of a start.config only exists in Jetty 8 and earlier.

Current documentation is at http://www.eclipse.org/jetty/documentation/current/

That text is not valid for Jetty 9.2.3.v20140905

There is never a good reason to have ALL of the jars in lib/ in the server classpath at the same time. In fact it would result in an invalid environment, as there are different implementations of several core technologies that you can change (such as jsp, jstl, and javax.el). There are also libraries present in lib/ that require 3rd party optional libraries to function (like npn, alpn), which require you to acknowledge a license before they are downloaded.

What libraries are loaded, from either {jetty.home}/lib and/or {jetty.base}/lib are determined by what modules you have enabled in your jetty instance configuration.

To learn about startup, start.jar, command line, modules, libs, xml configuration, configuration properties, {jetty.base}, {jetty-dir}, and {jetty.home}, see the "Startup Documentation" at http://www.eclipse.org/jetty/documentation/current/startup.html

To address your specific question about starting jetty and webapps. (Again, this is all documented in the "Startup Documentation" URL above)

Here's a quick example using {jetty.home} itself (not recommended anymore, but works):

# Unpack the distribution
[~]$ unzip jetty-distribution-9.2.3.v20140905
[~]$ cd jetty-distribution-9.2.3.v20140905

# Copy your war into place
[jetty-distribution-9.2.3.v20140905]$ cp ~/Projects/mywebapp.war webapps/

# Run Jetty
[jetty-distribution-9.2.3.v20140905]$ java -jar start.jar

Now for the more appropriate way, using a {jetty.base}:

# Unpack the distribution
[~]$ unzip jetty-distribution-9.2.3.v20140905

# Make a {jetty.base} directory to house your configuration
[~]$ mkdir myappbase
[~]$ cd myappbase

# Since this is a new {jetty.base}, lets initialize it
[myappbase]$ java -jar ../jetty-distribution-9.2.3.v20140905/start.jar \
  --add-to-start=http,logging,deploy,jsp,ext,resources
INFO: http            initialised in ${jetty.base}/start.ini (appended)
INFO: server          initialised in ${jetty.base}/start.ini (appended)
INFO: logging         initialised in ${jetty.base}/start.ini (appended)
MKDIR: ${jetty.base}/logs
INFO: deploy          initialised in ${jetty.base}/start.ini (appended)
MKDIR: ${jetty.base}/webapps
...(snip)...
MKDIR: ${jetty.base}/lib
MKDIR: ${jetty.base}/lib/ext
INFO: resources       initialised in ${jetty.base}/start.ini (appended)
MKDIR: ${jetty.base}/resources

# Lets see what we have now
[myappbase]$ ls -F
lib/  logs/  resources/  start.ini  webapps/

# Copy your webapp into place
[myappbase]$ cp ~/Projects/mywebapp.war webapps/

# Run Jetty
[myappbase]$ java -jar ../jetty-distribution-9.2.3.v20140905/start.jar
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!