英文:
Java servlet app worked on my pc local but not working on my server development
问题
我已将我的Java Servlet Web应用部署到服务器上。我的Web界面已显示,但当我尝试从网页注册/登录时,抛出了以下类似的“HTTP状态500 - 内部服务器错误”异常:
根本原因
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>
我在我的服务器上安装了Tomcat 8.5,该服务器使用CentOS 8操作系统。在我的计算机本地一切正常,但在部署到服务器上时,抛出了此错误。如果我表达不清楚,请原谅,但希望能够帮助您。
英文:
I already deploy my java servlet web app to my server . My web interface was shown but when I try to register/login from my webpage its thrown HTTP Status 500 ? Internal Server Error exception like below
> Root Cause
>
> 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)
> Root Cause
>
> 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)
The description says that
> The server encountered an unexpected condition that prevented it from
> fulfilling the request.
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>
I installed tomcat 8.5 to my server which is using centos 8 OS . Everything worked fine in my computer local but when i deploy to my server it thrown this error . Sorry if i cant't deliver my message clearly but hope its help
答案1
得分: 0
好的,以下是翻译好的内容:
错误堆栈信息非常明显:
java.lang.ClassNotFoundException: org.apache.commons.codec.digest.DigestUtils
当您将应用部署到服务器上时,应用无法加载上述类。这可能是因为在服务器上加载的 apache commons jar 版本与本地版本不同,或者您没有提供依赖项。请分享您的 pom.xml 以进行更多分析,并分享完整的错误堆栈信息。
如果您正在使用 Maven,请确保在 pom.xml 中添加如下内容:
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
英文:
Well the stacktrace is pretty self explanatory :
java.lang.ClassNotFoundException: org.apache.commons.codec.digest.DigestUtils
When you deploy your application on your server, the application fails to load the above class. It might be because the version of the apache commons jar that is getting loaded is different in your server than in your local or you haven't provided the dependency. Please share your pom.xml for more analysis and also share entire stacktrace.
If you are using maven make sure you have it added in your pom like :
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论