Tag: tomcat8

在Tomcat 8中将外部资源添加到类路径

我有一个Tomcat应用程序,需要引用应用程序外部的一些属性文件。 通常这些存储在C:\PROJECT_NAME\conf\等特定位置的本地计算机上。 在Tomcat 7中,这可以通过在/META-INF/放置一个context.xml文件来实现,该文件使用VirtualWebappLoader实际上将此位置添加到应用程序类路径,如下所示: 如何在Tomcat 8中实现同样的function?

获取NoSuchMethodError:javax.servlet.ServletContext.getVirtualServerName()

在Tomcat 8中部署服务时遇到问题。出现以下错误: 引起:java.lang.NoSuchMethodError:javax.servlet.ServletContext.getVirtualServerName()Ljava / lang / String; 在org.apache.tomcat.websocket.server.WsServerContainer。(WsServerContainer.java:149)org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131)org.apache.tomcat.websocket。服务器.WsSci.onStartup(WsSci.java:47)位于org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)的org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5244) ……还有10个 方法getVirtualServerName是在Servlet 3.1中引入的,在从我的servlet-api jar中提取MANIFEST.MF ,我得到了以下细节: Specification-Title: Java API for Servlets Specification-Version: 3.1 Specification-Vendor: Sun Microsystems, Inc. Implementation-Title: javax.servlet 其中说它有3.1。 那么这个错误还有其他原因吗? 请帮忙

对于HttpServletRequest类型,未定义方法getDispatcherType()

当我从Eclipse运行我的应用程序时,它运行时没有任何错误的servlet api 3.1.0和3.0.1。 javax.servlet javax.servlet-api 3.1.0 我使用tomcat 8.0.21进行eclipse。 我在ubuntu机器上设置了tomcat8,它运行在tomcat 8.0.14稳定版本上。 不幸的是,如果我使用servlet api 3.1.0,我会收到以下错误消息。 但它适用于旧版本3.0.1。 root cause org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: [50] in the generated java file: [/var/lib/tomcat8/work/Catalina/localhost/ROOT/org/apache/jsp/WEB_002dINF/view/templates/login_002dtemplate_jsp.java] The method getDispatcherType() is undefined for the type HttpServletRequest Stacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:199) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:450) org.apache.jasper.compiler.Compiler.compile(Compiler.java:361) org.apache.jasper.compiler.Compiler.compile(Compiler.java:336) org.apache.jasper.compiler.Compiler.compile(Compiler.java:323) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) […]