简体   繁体   English

使用SpringBootServletInitializer:应用程序不是javax.servlet.Servlet

[英]Using SpringBootServletInitializer: Application is not a javax.servlet.Servlet

I receive the following error when running my built war file within jetty: 在码头内运行构建的战争文件时,我收到以下错误:

>>> cd $JETTY_BASE; java -jar $JETTY_HOME/start.jar

2018-05-24 11:02:05.024:INFO::main: Logging initialized @386ms to org.eclipse.jetty.util.log.StdErrLog                                               
2018-05-24 11:02:05.201:INFO:oejs.Server:main: jetty-9.4.9.v20180320; built: 2018-03-20T05:21:10-07:00; git: 1f8159b1e4a42d3f79997021ea1609f2fbac6de5$
 jvm 1.8.0_172-b11                                                                                                                                   
2018-05-24 11:02:05.214:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:///Users/dlynch/Srv/bubbleshadow/webapps/] at interval 1       
2018-05-24 11:02:05.590:INFO:oejw.StandardDescriptorProcessor:main: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet         
2018-05-24 11:02:05.596:INFO:oejs.session:main: DefaultSessionIdManager workerName=node0                                                             
2018-05-24 11:02:05.596:INFO:oejs.session:main: No SessionScavenger set, using defaults                                                              
2018-05-24 11:02:05.597:INFO:oejs.session:main: Scavenging every 600000ms                                                                            
2018-05-24 11:02:05.604:WARN:oejshC.ROOT:main: unavailable                                         
javax.servlet.UnavailableException: Servlet class net.firezeal.bubbleshadow.Application is not a javax.servlet.Servlet                               
        at org.eclipse.jetty.servlet.ServletHolder.checkServletType(ServletHolder.java:553)           

bubbleshadow2.xml bubblehadow2.xml

<Configure id="bubbleshadow" class="org.eclipse.jetty.webapp.WebAppContext">

  <Set name="contextPath">/</Set>
  <Set name="war"><Property name="jetty.webapps" default="."/>/bubbleshadow2.war</Set>

  <Set name="extractWAR">true</Set>
  <Set name="copyWebDir">false</Set>
  <Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set>
  <Set name="overrideDescriptor"><Property name="jetty.webapps" default="."/>/bubbleshadow2.d/override-web.xml</Set>

</Configure>

override-web.xml overlay-web.xml

<web-app>
   xmlns="http://xmlns.jcp.org/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
   metadata-complete="false"
   version="3.1">

  <servlet>
    <servlet-name>bubbleshadow2</servlet-name>
    <servlet-class>net.firezeal.bubbleshadow.Application</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>bubbleshadow2</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

</web-app>

Application.java 应用程序

package net.firezeal.bubbleshadow;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableScheduling
public class Application extends SpringBootServletInitializer {
  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(Application.class);
  }

  public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
  }

  @Bean
  public StartupRunner schedulerRunner() {
    return new StartupRunner();
  }
}

I'm sure why my "Application" class it not seen as a javax.servlet.Servlet because I thought extending from SpringBootServletInitializer would be the correct way of doing that. 我确定为什么我的“ Application”类不被视为javax.servlet.Servlet,因为我认为从SpringBootServletInitializer进行扩展将是正确的方法。

Standard Servlet rules apply here. 标准Servlet规则在这里适用。

net.firezeal.bubbleshadow.Application does not extend from javax.servlet.Servlet and as such cannot be defined as a <servlet-class> in the web descriptor. net.firezeal.bubbleshadow.Application不能从javax.servlet.Servlet扩展,因此不能在Web描述符中定义为<servlet-class>

Typically the "Application" (in Spring-Boot terms, or even Jax-RS / Jersey terms) is a configuration, seen either as <init-param> values on a standard servlet, or declared using configuration files outside of the web descriptor. 通常,“应用程序”(以Spring-Boot术语,甚至是Jax-RS / Jersey术语)是一种配置,在标准Servlet上显示为<init-param>值,或者使用Web描述符外部的配置文件声明。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 RepositoryRestMvcConfiguration无法强制转换为javax.servlet.Servlet - RepositoryRestMvcConfiguration cannot be cast to javax.servlet.Servlet Servlet类com.foobar.jaxrs.application.MyApplication不是javax.servlet.Servlet - Servlet class com.foobar.jaxrs.application.MyApplication is not a javax.servlet.Servlet 将Servlet:“ main”强制转换为javax.servlet.Servlet时出错 - Error casting servlet: “main” to javax.servlet.Servlet UnavailableException: Servlet class 不是带有 Jetty 的 javax.servlet.Servlet - UnavailableException: Servlet class is not a javax.servlet.Servlet with Jetty eclipse servlet java.lang.ClassNotFoundException:javax.servlet.Servlet - eclipse servlet java.lang.ClassNotFoundException: javax.servlet.Servlet java.lang.ClassCastException:无法转换为javax.servlet.Servlet - java.lang.ClassCastException: cannot be cast to javax.servlet.Servlet java.lang.ClassCastException:org.glassfish.jersey.servlet.ServletContainer无法转换为javax.servlet.Servlet - java.lang.ClassCastException: org.glassfish.jersey.servlet.ServletContainer cannot be cast to javax.servlet.Servlet 尝试使用 Servlet 打包 REST App 时如何修复“无法转换为 javax.servlet.Servlet”错误 - How to fix 'cannot be cast to javax.servlet.Servlet' error while trying to package REST App with Servlet java.lang.ClassCastException:无法将 Servlet.Telnet 转换为 javax.servlet.Servlet - java.lang.ClassCastException: Servlet.Telnet cannot be cast to javax.servlet.Servlet Servlet类引用未实现接口javax.servlet.Servlet的“ org.springframework.web.servlet.DispatcherServlet” - servlet-class references to “org.springframework.web.servlet.DispatcherServlet” that does not implement interface javax.servlet.Servlet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM