Jetty9 NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet

来源:互联网 发布:网络信息发布审查制度 编辑:程序博客网 时间:2024/05/18 04:53

第一次使用Jetty9时,出现的问题

第一次使用Jetty9时,出现的问题 当现在好Jetty9后(可以在官方网站上下载,当前的最新版为Revision 9.1.0-SNAPSHOT),之后解压到本地,不用配置,看解压后目录文件:
目录图1
在jetty的根目录也就是${JETTY_HOME},打开cmd,或打开cmd后,切换到${JETTY_HOME}下,
>java -jar start.jar

这样就可以启动Jetty服务器了,但是,你在页面中是访问不到的,比如输入http://localhost:8080,是得不到任何的返回结果的,为什么呢?请看下面的摘录:

You can point a browser at this server athttp://localhost:8080.Since release 9.1.0, the jetty  distribution does not deploy any demo web applications, so to see a more  interesting demonstration of the server you need to run from the demo-base  directory as follows:

意思是说:从9.1.0版本开始,不是默认的部署示例应用,需要自己去启动

> cd $JETTY_HOME/demo-base/
> java -jar ../start.jar




将路径切换到demo-base目录下:

D:\JAVA\jetty-distribution-9.1.0.v20131115>cd demo-base

这样的话你就可以在浏览器中看到示例页面了。

再看看官网的介绍:

Creating a new Jetty Base

The demo-base directory described above is an example of the    jetty.base mechanism added in Jetty 9.1. A jetty base allows the    configuration and web applications of a server instance to be stored    separately from the jetty distribution, so that upgrades can be done with    minimal disruption. Jetty's default configuration is based on two    properties:

jetty.homeThe property that defines the location of the jetty distribution, its libs, default modules and default XML files (typically start.jar, lib, etc)

jetty.baseThe property that defines the location of a specific instance of a jetty server, its configuration, logs and web applications(typically start.ini, start.d, logs and webapps)


这说明要部署应用,都需要自己的BASE,从上面部署demo时就可以看出来。

creatBaseDirectory

但是,问题出来了:

当我新建好mybase文件夹后,将以前做好的web app放到该目录的webapps后,在启动etty时 ,出现以下问题:

2013-11-27 12:05:22.981:INFO:oejw.StandardDescriptorProcessor:main: NO JSP Suppo
rt for /, did not find org.apache.jasper.servlet.JspServlet
2013-11-27 12:05:23.012:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppCo
ntext@1c86116{/,file:/D:/JAVA/jetty-distribution-9.1.0.v20131115/mybase/webapps/
ROOT/,AVAILABLE}{D:\JAVA\jetty-distribution-9.1.0.v20131115\mybase\webapps\ROOT}

2013-11-27 12:05:23.075:INFO:oejw.StandardDescriptorProcessor:main: NO JSP Suppo
rt for /MMS1.0, did not find org.apache.jasper.servlet.JspServlet

就是那个NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet,

经过查询,说明文档说的是JSP需要编译,单是Jetty不会默认的保存,编译需要JDK,如果System中也就是系统没有装JDK的话,需要在配置文当中开启使用自己的编译器,但是我有啊,java、javac都能使用,再查说是要加参数:

java -jar jetty.jar OPTIONS=Server,jsp

但是用了,还是没用,最后擦看文档,有个命令可以查看环境:

D:\JAVA\jetty-distribution-9.1.0.v20131115\mybase>java -jar ../start.jar --version


Jetty Server Classpath:
-----------------------
Version Information on 11 entries in the classpath.
Note: order presented here is how they would appear on the classpath.
      changes to the --module=name command line options will be reflected here.
0:                    3.1.0 | ${jetty.home}\lib\servlet-api-3.1.jar
1:                  3.1.RC0 | ${jetty.home}\lib\jetty-schemas-3.1.jar
2:          9.1.0.v20131115 | ${jetty.home}\lib\jetty-http-9.1.0.v20131115.jar
3:          9.1.0.v20131115 | ${jetty.home}\lib\jetty-server-9.1.0.v20131115.jar
4:          9.1.0.v20131115 | ${jetty.home}\lib\jetty-xml-9.1.0.v20131115.jar
5:          9.1.0.v20131115 | ${jetty.home}\lib\jetty-util-9.1.0.v20131115.jar
6:          9.1.0.v20131115 | ${jetty.home}\lib\jetty-io-9.1.0.v20131115.jar
7:          9.1.0.v20131115 | ${jetty.home}\lib\jetty-security-9.1.0.v20131115.jar
8:          9.1.0.v20131115 | ${jetty.home}\lib\jetty-servlet-9.1.0.v20131115.jar
9:          9.1.0.v20131115 | ${jetty.home}\lib\jetty-webapp-9.1.0.v20131115.jar
10:          9.1.0.v20131115 | ${jetty.home}\lib\jetty-deploy-9.1.0.v20131115.jar

我一看,是不是少了编译JSP的jar,试着添加:

D:\JAVA\jetty-distribution-9.1.0.v20131115\mybase>java -jar ../start.jar --add-to-start=jsp


WARNING: jsp             initialised in ${jetty.base}\start.ini (appended)
WARNING: jsp             enabled in     ${jetty.base}\start.ini
WARNING: server          enabled in     ${jetty.base}\start.ini



这一看,添加过了,我才记起,刚才在start.ini中打开了一(ˇˍˇ) 想项配置:

--Dorg.apache.jasper.compiler.disablejsr199=true

这块原先是被注释掉的,可以打开,然后再base目录下的start.ini中出现了一行:

#
# Initialize module jsp
#
--module=jsp

# JSP Configuration
# To use an non-jdk compiler for JSP compilation uncomment next line
# -Dorg.apache.jasper.compiler.disablejsr199=true



我记得原先好像没有出现,现在有了,在他的下面也有那个开启jsp编译的选项,但是被注释点了,不知道是咋弄好的,这时候,可以正常启动了。打开浏览器可以正常访问了。



。。。。。。。







原创粉丝点击