[英]Java servlet app worked on my pc local but not working on my server development
我已經將我的 java servlet web 應用程序部署到我的服務器。 顯示了我的 Web 界面,但是當我嘗試從我的網頁注冊/登錄時,它拋出了HTTP Status 500 ? Internal Server Error exception like below
HTTP Status 500 ? Internal Server Error exception like below
根本原因
java.lang.NoClassDefFoundError: org/apache/commons/codec/digest/DigestUtils com.mockup.Register.doPost(Register.java:38) javax.servlet.http.HttpServlet.service(HttpServlet.java:652) javax.servlet .http.HttpServlet.service(HttpServlet.java:733) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 根本原因
java.lang.ClassNotFoundException: org.apache.commons.codec.digest.DigestUtils org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1358) org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java :1180) com.mockup.Register.doPost(Register.java:38) javax.servlet.http.HttpServlet.service(HttpServlet.java:652) javax.servlet.http.HttpServlet.service(HttpServlet.java:733) org .apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
說明是這樣說的
服務器遇到了阻止它完成請求的意外情況。
pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<packaging>bundle</packaging>
<name>JSON.simple</name>
<version>1.1.1</version>
<description>A simple Java toolkit for JSON</description>
<url>http://code.google.com/p/json-simple/</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<id>Yidong</id>
<name>Yidong Fang</name>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
<timezone>+8</timezone>
</developer>
</developers>
<scm>
<connection>scm:svn:http://json-simple.googlecode.com/svn/trunk/</connection>
<developerConnection>scm:svn:http://json-simple.googlecode.com/svn/trunk/</developerConnection>
<url>http://json-simple.googlecode.com/svn/trunk/</url>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.6</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.2</source>
<target>1.2</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
我在使用 centos 8 OS 的服務器上安裝了 tomcat 8.5。 在我的本地計算機上一切正常,但是當我部署到我的服務器時,它拋出了這個錯誤。 抱歉,如果我不能清楚地傳達我的信息,但希望它有所幫助
那么堆棧跟蹤是非常不言自明的:
java.lang.ClassNotFoundException: org.apache.commons.codec.digest.DigestUtils
在服務器上部署應用程序時,應用程序無法加載上述類。 這可能是因為加載的 apache commons jar 版本在您的服務器中與本地不同,或者您沒有提供依賴項。 請分享您的 pom.xml 以進行更多分析,並分享整個堆棧跟蹤。
如果您使用的是 maven,請確保將它添加到您的 pom 中,例如:
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.