简体   繁体   English

出现错误 java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config

[英]Getting Error java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config

I am developing a spring boot project.我正在开发一个 spring 引导项目。 The code works perfectly fine on localhost in intelliJ.该代码在 intelliJ 的 localhost 上运行良好。

The war file was created using command战争文件是使用命令创建的

mvn clean install

But when I run it on centos server with command但是当我使用命令在 centos 服务器上运行它时

java -jar app.war

On running above command the deploy is successfully started at port 8080在运行上述命令时,部署在端口 8080 成功启动

But the problem occurs when any page containing jstl jsp is access.但是当任何包含 jstl jsp 的页面被访问时就会出现问题。 It displays 404 error following error is visible on log.它显示 404 错误以下错误在日志中可见。 This code was working perfectly fine few days ago but now I cant get what changed except I made few code changes and deployed the new war file.这段代码几天前工作得很好,但现在我无法得到改变,除非我做了一些代码更改并部署了新的战争文件。 I haven't changed anything in pom.xml.我没有更改 pom.xml 中的任何内容。

 2020-07-31 13:37:27.382 ERROR 5141 --- [nio-8080-exec-8] oac.c.C.[.[.[/].[disp atcherServlet]: Servlet.service() for servlet [dispatcherServlet] threw exce ption java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config at org.springframework.web.servlet.support.JstlUtils.exposeLocalizationC ontext(JstlUtils.java:103) ~[spring-webmvc-5.2.7.RELEASE.jar:/.5.2.7.RELEASE] at org.springframework.web.servlet.view.JstlView.exposeHelpers(JstlView: java.137) ~[spring-webmvc-5.2.7.RELEASE:jar./.5.2.7.RELEASE] at org.springframework.web.servlet.view.InternalResourceView:renderMerge dOutputModel(InternalResourceView.java.145) ~[spring-webmvc-5.2.7:RELEASE.jar./. 5.2.7.RELEASE] at org.springframework.web.servlet.view:AbstractView.render(AbstractView.java.316) ~[spring-webmvc-5.2:7.RELEASE.jar./.5.2.7.RELEASE] at org.springframework.web:servlet.DispatcherServlet.render(DispatcherSe rvlet.java.1373) ~[spring-webmvc-5:2.7.RELEASE.jar./.5.2.7.RELEASE] at org.springframework:web.servlet.DispatcherServlet.processDispatchResu lt(DispatcherServlet.java:1118) ~[spring-webmvc-5.2.7.RELEASE.jar./.5.2.7.RELEAS E] at org:springframework.web.servlet.DispatcherServlet.doDispatch(Dispatch erServlet:java.1057) ~[spring-webmvc-5.2.7.RELEASE.jar./.5.2.7:RELEASE] at org.springframework.web.servlet.DispatcherServlet:doService(Dispatche rServlet.java.943) ~[spring-webmvc-5.2.7.RELEASE.jar./.5.2:7.RELEASE] at org.springframework.web.servlet:FrameworkServlet.processRequest(Frame workServlet.java.1006) ~[spring-webmvc-5.2.7.RELEASE.jar./.5:2.7.RELEASE] at org.springframework.web:servlet.FrameworkServlet.doGet(FrameworkServl et.java.898) ~[spring-webmvc-5.2.7.RELEASE.jar:/.5.2.7:RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java.634) ~[tomcat -embed-core-9.0.36:jar./.9.0.36] at org:springframework.web.servlet.FrameworkServlet.service(FrameworkSer vlet.java.883) ~[spring-webmvc-5.2.7:RELEASE.jar./.5:2.7.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java.741) ~[tomcat -embed-core-9:0.36.jar./:9.0.36] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:231) ~[tomcat-embed-core-9.0.36.jar:/.9.0.36] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain:java.166) ~[tomcat-embed-core-9.0.36.jar:/.9.0.36] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java.320) ~[spring-security-web-5.3:3.RELEASE.jar./.5: 3.3.RELEASE] at org.springframework.security.web.access.intercept.FilterSecurityInter ceptor.invoke(FilterSecurityInterceptor.java.115) ~[spring-security-web-5:3.3.RE LEASE.jar./:5.3.3.RELEASE] at org.springframework.security.web.access.intercept.FilterSecurityInter ceptor:doFilter(FilterSecurityInterceptor.java.90) ~[spring-security-web-5.3.3:R ELEASE.jar./.5.3.3.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain: doFilter(FilterChainProxy.java.334) ~[spring-security-web-5.3.3:RELEASE.jar./.5. 3.3.RELEASE] at org.springframework.security.web:access.ExceptionTranslationFilter.do Filter(ExceptionTranslationFilter.java.118) ~[spring-security-web-5:3.3.RELEASE. jar./.5.3.3.RELEASE] at org.springframework.security:web.FilterChainProxy$VirtualFilterChain. doFilter(FilterChainProxy.java.334) ~[spring-security-web-5:3.3.RELEASE.jar!/:5. 3.3.RELEASE] at org.springframework.security.web.session.SessionManagementFilter.doFi lter(SessionManagementFilter.java:84) ~[spring-security-web-5.3.3.RELEASE.jar!/: 5.3.3.RELEASE]

pom.xml pom.xml

 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.1.RELEASE</version> <relativePath/> <.-- lookup parent from repository --> </parent> <groupId>com.appl</groupId> <artifactId>appl</artifactId> <version>0.0.1-SNAPSHOT</version> <name>appll</name> <description>APP Search project for</description> <packaging>war</packaging> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-to-slf4j</artifactId> <scope>compile</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jul-to-slf4j</artifactId> <scope>compile</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>log4j-over-slf4j</artifactId> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-rest</artifactId> </dependency> <.-- <dependency>--> <.-- <groupId>org.hibernate </groupId>--> <.-- <artifactId>hibernate-ehcache</artifactId>--> <.-- </dependency>--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>com.github.darrachequesne</groupId> <artifactId>spring-data-jpa-datatables</artifactId> <version>5.0.0</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.12</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId>thymeleaf-extras-springsecurity5</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>

I tried both the ways w/ and w/o provided我尝试了 w/ 和 w/o 提供的两种方式

I think the problem here is that you are using the "provided" scope for your servlet.我认为这里的问题是您正在为您的 servlet 使用“提供的”scope。 The provided scope means it will be used for build and testing but not for runtime, as it will be provided by the runtime environment (container, specific server..).提供的 scope 意味着它将用于构建和测试,但不用于运行时,因为它将由运行时环境(容器、特定服务器..)提供。 You should remove the scope if you want to run it with cli.如果你想用 cli 运行它,你应该删除 scope。

It is not possible to run a war file outside of a container.Remove war from POM this will set packaging to default(jar).无法在容器外运行 war 文件。从 POM 中删除 war 这会将打包设置为默认值(jar)。 Then use below command in CentOS to run the project.然后在 CentOS 中使用以下命令运行项目。

  1. java -jar app.jar java -jar app.jar

The other solution is to install a container in CentOS and then deploy the War to it.另一种解决方案是在 CentOS 中安装一个容器,然后将 War 部署到它。

暂无
暂无

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

相关问题 即使jstl 1.2在类路径中,javax.servlet.jsp.jstl.core.Config的ClassNotFoundException - ClassNotFoundException for javax.servlet.jsp.jstl.core.Config even when jstl 1.2 is in the classpath 找不到javax.servlet.jsp.jstl.core.Config类 - javax.servlet.jsp.jstl.core.Config class not found java.lang.ClassNotFoundException:javax.servlet.jsp.jstl.sql.SQLExecutionTag - java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.sql.SQLExecutionTag 错误500 - 内部服务器错误java.lang.NoClassDefFoundError:javax / servlet / jsp / jstl / core / Config - Error 500--Internal Server Error java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config java.lang.ClassNotFoundException:javax.servlet.jsp.tagext.Tag - java.lang.ClassNotFoundException: javax.servlet.jsp.tagext.Tag java.lang.ClassNotFoundException:javax.servlet.jsp.SkipPageException - java.lang.ClassNotFoundException: javax.servlet.jsp.SkipPageException Java JSTL错误java.lang.NoClassDefFoundError:javax / servlet / jsp / jstl / core / LoopTag - Java JSTL Error java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/LoopTag 在 JUnit 中获取 java.lang.ClassNotFoundException: javax.servlet.ServletContext - Getting java.lang.ClassNotFoundException: javax.servlet.ServletContext in JUnit GAE-java.lang.RuntimeException:java.lang.ClassNotFoundException:javax.servlet.jsp.tagext.BodyContent - GAE - java.lang.RuntimeException: java.lang.ClassNotFoundException: javax.servlet.jsp.tagext.BodyContent eclipse servlet java.lang.ClassNotFoundException:javax.servlet.Servlet - eclipse servlet java.lang.ClassNotFoundException: javax.servlet.Servlet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM