无法使我的spring启动应用程序与jsp一起工作 [英] Can't make my spring boot application work with jsp

查看:99
本文介绍了无法使我的spring启动应用程序与jsp一起工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 spring boot 网络应用程序存在问题。它使用嵌入式jetty (它必须是jetty - 而不是tomcat)并使用 jsp 视图。但似乎没有办法让嵌入式jetty与jsp视图一起工作。实际上,当我运行mu app服务器启动成功,但当我尝试访问我的网络应用程序的任何网址时 - 我收到错误:

I have problem with my spring boot web app. It uses embedded jetty (it must be jetty - not tomcat) and it uses jsp views. But seems like there is no way to make embedded jetty work with jsp views. Actually at the moment when I run mu app server starts successfully but when I try to access any url of my web app - I get error:

org.apache.jasper.JasperException: java.lang.IllegalStateException: No Java compiler available
    at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:591) ~[apache-jsp-8.0.27.jar:2.3]
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:397) ~[apache-jsp-8.0.27.jar:2.3]
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) ~[apache-jsp-8.0.27.jar:2.3]
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) ~[apache-jsp-8.0.27.jar:2.3]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ~[javax.servlet-api-3.1.0.jar:3.1.0]
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) ~[jetty-servlet-9.2.17.v20160517.jar:9.2.17.v20160517]
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) ~[jetty-servlet-9.2.17.v20160517.jar:9.2.17.v20160517]
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199) ~[spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) ~[jetty-servlet-9.2.17.v20160517.jar:9.2.17.v20160517]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:108) ~[spring-security-web-3.2.5.RELEASE.jar:3.2.5.RELEASE]
......................
Caused by: java.lang.IllegalStateException: No Java compiler available
at org.apache.jasper.JspCompilationContext.createCompiler(JspCompilationContext.java:231) ~[apache-jsp-8.0.27.jar:2.3]
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:577) ~[apache-jsp-8.0.27.jar:2.3]
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363) ~[apache-jsp-8.0.27.jar:2.3]

如何才能使其有效?有什么办法吗?
如果春季启动不可能,那么替代方式是什么让我的应用程序在嵌入式Jetty上使用jsp?

How can I make it work? Is there any way? And if it is not possible with spring boot then what are alternative ways to make my app work on embedded jetty with jsp?

这是我在 github 上的项目的链接。请看看它并帮助我!如果您尝试在IDE中运行它(建议使用IntelliJ IDEA)并找到问题的原因,那将是非常好的。

Here is link to my project on github. Please look at it and help me! It would be just great if you try to run it in your IDE (IntelliJ IDEA recommended) and find the reason of the problem.

更新1(2016年7月15日)

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [sample.jetty.jsp.SampleJettyJspApplication]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.support.SpringBootServletInitializer
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:187) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:321) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:523) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.RC1.jar:1.4.0.RC1]
    at sample.jetty.jsp.SampleJettyJspApplication.main(SampleJettyJspApplication.java:33) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_65]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_65]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na]
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.boot.web.support.SpringBootServletInitializer
    at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:163) ~[spring-core-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:300) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:237) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:204) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:173) ~[spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    ... 17 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
    at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_65]
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_65]
    at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_65]
    at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:152) ~[spring-core-4.3.1.RELEASE.jar:4.3.1.RELEASE]
    ... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_65]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_65]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_65]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_65]
    ... 25 common frames omitted


推荐答案

您正在使用Spring Boot 1.3.6并且在< a href =http://docs.spring.io/spring-boot/docs/1.3.6 .RELEASE / reference / htmlsingle / #boot-features-jsp-limitsrel =nofollow>文档的JSP限制部分它说:

You are using Spring Boot 1.3.6 and in the JSP limitations section of the documentation it says:


Jetty目前不能用作带JSP的嵌入式容器。

Jetty does not currently work as an embedded container with JSPs.

增强功能,这意味着只要你使用war,JSP就可以与嵌入式Jetty一起使用打包。如果您不想等待1.4.0被释放,则增强功能在1.4.0.RC1中,可从 https://repo.spring.io/libs-milestone 。还有一个可能感兴趣的新样本申请

There's an enhancement coming in Spring Boot 1.4 that means the JSPs will work with embedded Jetty as long as you use war packaging. If you don't want to wait for 1.4.0 to be released, the enhancement is in 1.4.0.RC1 which is available from https://repo.spring.io/libs-milestone. There's also a new sample application that may be of interest.

这篇关于无法使我的spring启动应用程序与jsp一起工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆