有没有办法只使用Jetty(或Tomcat)的servlet引擎(删除所有JSP功能)?

时间:2017-02-05 23:17:16

标签: java tomcat servlets jetty

我已经尝试过第一个Jetty,因为他们宣称它是从头开始设计的模块化设计但是在评论了“--module = jsp”中的行:

{jetty.home}/start.ini
{jetty.home}/demo-base/start.d/jsp.ini

正在加载大量JSP功能:

_STOP_PORT=65521
_STOP_KEY="stop_now_123"

java -jar ../start.jar STOP.PORT="${_STOP_PORT}" STOP.KEY="${_STOP_KEY}" --list-modules=jsp

 Available Modules:
 ==================
 tags: [jsp]

 Enabled Modules:
 ================
     0) ext             ${jetty.base}/start.d/ext.ini
     1) resources       ${jetty.base}/start.d/resources.ini
     2) server          ${jetty.base}/start.d/server.ini
     3) jndi            ${jetty.base}/start.d/jndi.ini
     4) security        transitive provider of security for webapp
                        transitive provider of security for plus
     5) servlet         transitive provider of servlet for webapp
                        transitive provider of servlet for servlets
                        transitive provider of servlet for jsp
     6) webapp          transitive provider of webapp for plus
                        transitive provider of webapp for deploy
                        init template available with --add-to-start=webapp
     7) plus            transitive provider of plus for annotations
     8) annotations     ${jetty.base}/start.d/annotations.ini
     9) apache-jsp      transitive provider of apache-jsp for jsp
    10) apache-jstl     transitive provider of apache-jstl for jstl
    11) client          ${jetty.base}/start.d/client.ini
    12) continuation    ${jetty.base}/start.d/continuation.ini
    13) deploy          ${jetty.base}/start.d/deploy.ini
    14) http            ${jetty.base}/start.d/http.ini
    15) ssl             transitive provider of ssl for https
                        init template available with --add-to-start=ssl
    16) https           ${jetty.base}/start.d/https.ini
    17) jaas            ${jetty.base}/start.d/demo.ini
    18) jsp             ${jetty.base}/start.d/jsp.ini
    19) jstl            ${jetty.base}/start.d/jstl.ini
    20) rewrite         ${jetty.base}/start.d/demo.ini
    21) servlets        ${jetty.base}/start.d/servlets.ini
    22) websocket       ${jetty.base}/start.d/demo.ini

〜  作为测试,我还启动了Jetty并在使用其JSP测试页时记录了所有已加载的类(即使JSP模块据说不被jetty的启动引擎使用)

_LOG_FL="jetty_startup_loaded_classes_$(date +%Y%m%d%H%M%S).log"

java  -d64 -server -verbose:class -jar ../start.jar STOP.PORT="${_STOP_PORT}" STOP.KEY="${_STOP_KEY}") > "${_LOG_FL}" 2>&1

$ cat "${_LOG_FL}" | grep jsp > "${_LOG_FL}"_jsp_classes_lines.log

$ ls -l "${_LOG_FL}"_jsp_classes_lines.log

$ wc -l "${_LOG_FL}"_jsp_classes_lines.log

$ cat "${_LOG_FL}"_jsp_classes_lines.log | grep "\[Loaded org.apache.jsp.jsp"
[Loaded org.apache.jsp.jsp.dump_jsp from file:/tmp/jetty-0.0.0.0-8080-test.war-_test-any-3200093898214200160.dir/jsp/]
[Loaded org.apache.jsp.jsp.bean1_jsp from file:/tmp/jetty-0.0.0.0-8080-test.war-_test-any-3200093898214200160.dir/jsp/]
[Loaded org.apache.jsp.jsp.bean2_jsp from file:/tmp/jetty-0.0.0.0-8080-test.war-_test-any-3200093898214200160.dir/jsp/]
[Loaded org.apache.jsp.jsp.tag_jsp from file:/tmp/jetty-0.0.0.0-8080-test.war-_test-any-3200093898214200160.dir/jsp/]
[Loaded org.apache.jsp.jsp.tagfile_jsp from file:/tmp/jetty-0.0.0.0-8080-test.war-_test-any-3200093898214200160.dir/jsp/]
[Loaded org.apache.jsp.jsp.tagfile_jsp$Helper from file:/tmp/jetty-0.0.0.0-8080-test.war-_test-any-3200093898214200160.dir/jsp/]
[Loaded org.apache.jsp.jsp.tag2_jsp from file:/tmp/jetty-0.0.0.0-8080-test.war-_test-any-3200093898214200160.dir/jsp/]
[Loaded org.apache.jsp.jsp.tag2_jsp$Helper from file:/tmp/jetty-0.0.0.0-8080-test.war-_test-any-3200093898214200160.dir/jsp/]
[Loaded org.apache.jsp.jsp.expr_jsp from file:/tmp/jetty-0.0.0.0-8080-test.war-_test-any-3200093898214200160.dir/jsp/]
[Loaded org.apache.jsp.jsp.foo.foo_jsp from file:/tmp/jetty-0.0.0.0-8080-test.war-_test-any-3200093898214200160.dir/jsp/]

〜  lbrtchx

2 个答案:

答案 0 :(得分:0)

您还需要停用--module=jstl,这取决于jsp模块。

 Module: jstl  
       : Enables JSTL for all webapplications deployed on the server  
 Depend: jsp, apache-jstl

参考:Managing Startup Modules

答案 1 :(得分:0)

根据Sierra和Erdfelt的建议,我确实删除了所有jsp和jslt模块的依赖关系,并将{jetty.home} / lib / apache-jsp移离{jetty.home}。一切似乎都运转良好,但当我试图停止码头时,我得到了:

$ time java -jar ../start.jar STOP.PORT="${_STOP_PORT}" STOP.KEY="${_STOP_KEY}" --stop
java.lang.NullPointerException
 at org.eclipse.jetty.start.Main.stop(Main.java:576)
 at org.eclipse.jetty.start.Main.stop(Main.java:519)
 at org.eclipse.jetty.start.Main.doStop(Main.java:507)
 at org.eclipse.jetty.start.Main.start(Main.java:402)
 at org.eclipse.jetty.start.Main.main(Main.java:77)

Usage: java -jar $JETTY_HOME/start.jar [options] [properties] [configs]
 java -jar $JETTY_HOME/start.jar --help  # for more information

real    2m8.334s
user    0m1.737s
sys 0m0.193s

〜  我要做的就是检查org.eclipse.jetty.start.Main中的停止线和相应的启动线。我仍然想知道我的猴子方式如何影响一些内部依赖并重新实现没有JSP的cdi和jfx