为什么我的简单springmvc Web应用程序关闭了Jetty?

时间:2011-11-01 02:32:42

标签: java spring ubuntu jetty

查看我的一个简单的springmvc应用程序的日志文件(homecontroller索引操作输出'hello world'),该网站似乎因某种原因而关闭了?

我只是将我的.war文件推送到jetty_home / webapps文件夹,然后启动了jetty服务。

ubuntu@ip-10-123-44-55:/usr/share/jetty/logs$ cat 2011_11_01.stderrout.log.022538550 
2011-11-01 02:15:26.080:INFO::jetty-6.1.24
2011-11-01 02:15:26.192:INFO::Deploy /etc/jetty/contexts/javadoc.xml -> org.mortbay.jetty.handler.ContextHandler@8b819f{/javadoc,file:/usr/share/jetty/javadoc}
2011-11-01 02:15:26.338:INFO::Extract file:/var/lib/jetty/webapps/springmvc.war to /var/cache/jetty/data/Jetty__8080_springmvc.war__springmvc__s1aryk/webapp
2011-11-01 02:15:26.821:INFO::NO JSP Support for /springmvc, did not find org.apache.jasper.servlet.JspServlet
2011-11-01 02:15:28.245:INFO:/springmvc:Initializing Spring FrameworkServlet 'springmvc'
0    [main] INFO  org.springframework.web.servlet.DispatcherServlet  - FrameworkServlet 'springmvc': initialization started
69   [main] INFO  org.springframework.web.context.support.XmlWebApplicationContext  - Refreshing WebApplicationContext for namespace 'springmvc-servlet': startup date [Tue Nov 01 02:15:28 UTC 2011]; root of context hierarchy
145  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/servlet-context.xml]
504  [main] INFO  org.springframework.context.annotation.ClassPathBeanDefinitionScanner  - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
795  [main] INFO  org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor  - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
853  [main] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory  - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1cd107f: defining beans [homeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0]; root of factory hierarchy
1064 [main] INFO  org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping  - Root mapping to handler 'homeController'
1446 [main] INFO  org.springframework.web.servlet.DispatcherServlet  - FrameworkServlet 'springmvc': initialization completed in 1445 ms
2011-11-01 02:15:29.738:INFO::NO JSP Support for , did not find org.apache.jasper.servlet.JspServlet
2011-11-01 02:15:29.746:INFO::Opened /var/log/jetty/2011_11_01.request.log
2011-11-01 02:15:29.810:INFO::Started SelectChannelConnector@:8080
hello, world!
2011-11-01 02:24:01.775:INFO::Shutdown hook executing
2011-11-01 02:24:01.775:INFO::Graceful shutdown SelectChannelConnector@:8080
2011-11-01 02:24:01.828:INFO::Graceful shutdown org.mortbay.jetty.handler.ContextHandler@8b819f{/javadoc,file:/usr/share/jetty/javadoc}
2011-11-01 02:24:01.828:INFO::Graceful shutdown org.mortbay.jetty.webapp.WebAppContext@caf0ed{/springmvc,file:/var/lib/jetty/webapps/springmvc.war}
2011-11-01 02:24:01.828:INFO::Graceful shutdown org.mortbay.jetty.webapp.WebAppContext@18f6559{,file:/var/lib/jetty/webapps/root/}
2011-11-01 02:24:02.828:INFO::Stopped SelectChannelConnector@:8080
2011-11-01 02:24:02.829:INFO:/springmvc:Destroying Spring FrameworkServlet 'springmvc'
514583 [Shutdown] INFO  org.springframework.web.context.support.XmlWebApplicationContext  - Closing WebApplicationContext for namespace 'springmvc-servlet': startup date [Tue Nov 01 02:15:28 UTC 2011]; root of context hierarchy
514584 [Shutdown] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory  - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1cd107f: defining beans [homeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0]; root of factory hierarchy
2011-11-01 02:24:02.834:INFO::Shutdown hook complete

这是一个使用maven项目构建的IntelliJ .war文件。

这是我的第一次部署所以请不要假设我知道我在做什么:)

更新

实际上它似乎已经出现了,当我做一个wget localhost:8080 / springmvc /我收到消息:

Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response... 500 JSP support not configured
2011-11-01 02:33:34 ERROR 500: JSP support not configured.

由于某些原因,这不适用于jetty,它在tomcat上工作正常吗?

2 个答案:

答案 0 :(得分:3)

如果这是一个maven项目,将the yetty插件添加到你的pom文件

<plugins>
  <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <version>6.1.10</version>
  </plugin>
</plugins>

然后执行以下命令

mvn jetty:run

答案 1 :(得分:2)

根据this link

Jetty不直接实现JSP。相反,它使用servlet来提供servle规范所需的此功能。 [...] 2.5 servlet规范的配套是2.1 JSP规范

所以你需要一个带有JSP的jar。

如果您在maven插件中使用Jetty 6,我想Peter Szanto所回答的依赖将解决它。另一方面,如果您将其用作应用程序的一部分,则需要添加适当的jsp jar。

对于使用Jetty 6.1的Maven项目的示例,您可以包含在pom.xml中:

<dependency>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>jsp-2.1</artifactId>
  <version>6.1.14</version>
</dependency>