简体   繁体   English

RepositoryRestMvcConfiguration无法强制转换为javax.servlet.Servlet

[英]RepositoryRestMvcConfiguration cannot be cast to javax.servlet.Servlet

I am trying to deploy one war file to tomcat but the log file shows the following exception : 我正在尝试将一个war文件部署到tomcat,但是日志文件显示以下异常:

SEVERE: Servlet [rest] in web application [/sample] threw load() exception
java.lang.ClassCastException: org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration cannot be cast to javax.servlet.Servlet
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1148)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5253)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5543)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1095)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1930)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Here is the build.gradle file 这是build.gradle文件

repositories {

    mavenCentral()
}

dependencies {
   providedCompile   'org.apache.tomcat:tomcat-servlet-api:7.0.37'
   providedCompile   'javax.servlet:javax.servlet-api:4.0.0-b01'

    // Spring Framework Jars 
    compile 'org.springframework:spring-context:4.1.0'
    compile 'org.springframework.ws:spring-ws-core:2.2.2.RELEASE'
    compile 'org.springframework.data:spring-data-jpa:1.9.0.RELEASE'


    // Spring Integration Jars
    compile 'org.springframework.integration:spring-integration-core:4.1.2.RELEASE'
    compile 'org.springframework.integration:spring-integration-stream:4.1.2.RELEASE'
    compile 'org.springframework.integration:spring-integration-jms:4.1.2.RELEASE'
    compile 'org.springframework.integration:spring-integration-xml:4.1.2.RELEASE'
    compile 'org.springframework.integration:spring-integration-http:4.1.2.RELEASE'
    compile 'org.springframework.integration:spring-integration-mail:4.1.2.RELEASE'
    compile 'org.springframework:spring-webmvc:4.2.2.RELEASE'
    compile 'org.springframework.data:spring-data-rest-webmvc:2.4.0.RELEASE'
    // Spring Batch Framework Jars
    compile 'org.springframework.batch:spring-batch-infrastructure:3.0.4.RELEASE' 
    compile 'org.springframework.batch:spring-batch-core:3.0.4.RELEASE'

    // Log4j Jar
    compile 'log4j:log4j:1.2.17'

    // IBM JMS MQ Jars
    compile 'com.ibm:com.ibm.mq:7.0.1.0'
    compile 'com.ibm:com.ibm.mq.jmqi:7.0.1.0'
    compile 'com.ibm:com.ibm.mqjms:7.0.1.0'
    compile 'javax.jms:jms-api:1.1-rev-1'


    // Hibernate JARS
    compile 'org.hibernate:hibernate-entitymanager:5.0.1.Final'

    //Oracle JDBC Jar 
    compile 'com.oracle:ojdbc6:11.2.0.3.0'

    //Mail Jar
     compile 'javax.mail:javax.mail-api:1.5.4'


} 

And this is my web.xml file . 这是我的web.xml文件。

<web-app>
<display-name>sample Web Application</display-name>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>
<listener>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/config/sample-servlet.xml</param-value>
</context-param>

<servlet>
    <servlet-name>rest</servlet-name>
    <servlet-class>org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration
    </servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>rest</servlet-name>
    <url-pattern>/api/*</url-pattern>
</servlet-mapping>

I have tried to exclude "javax.servlet-api " ,but with no avail . 我试图排除“ javax.servlet-api”,但无济于事。

If anyone can help me in finding the reason behind this exception ,that would be of great help . 如果有人可以帮助我找到导致此异常的原因,那将是非常有帮助的。

Thanks 谢谢

Made a silly mistake ,instead of using 犯了一个愚蠢的错误,而不是使用

"org.springframework.data.rest.webmvc.RepositoryRestDispatcherServlet" “ org.springframework.data.rest.webmvc.RepositoryRestDispatcherServlet”

,i used ,我用了

"org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration" “ org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration”

.

Hope after seeing this post other people will not make the same mistake 希望看到这篇文章后其他人不会犯同样的错误

暂无
暂无

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

相关问题 java.lang.ClassCastException:无法转换为javax.servlet.Servlet - java.lang.ClassCastException: cannot be cast to javax.servlet.Servlet java.lang.ClassCastException:无法将 Servlet.Telnet 转换为 javax.servlet.Servlet - java.lang.ClassCastException: Servlet.Telnet 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 在我的spring项目中,ServletDispatcher不能转换为Javax.servlet.Servlet异常 - ServletDispatcher cannot be cast to Javax.servlet.Servlet exception in my spring project 使用SpringBootServletInitializer:应用程序不是javax.servlet.Servlet - Using SpringBootServletInitializer: Application is not a javax.servlet.Servlet eclipse servlet java.lang.ClassNotFoundException:javax.servlet.Servlet - eclipse servlet java.lang.ClassNotFoundException: 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 无法将Maven强制转换为javax.servlet.Filter - Maven cannot be cast to javax.servlet.Filter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM