简体   繁体   English

Tomcat 构建错误:java.lang.NoClassDefFoundError

[英]Tomcat Build Error: java.lang.NoClassDefFoundError

The projet work fine in tomcat localhost but when I upload it in a remote tomcat I get this bug:/, I have the jar that contain the ImageReaderFactory class in classpath, I didn't understand what can be the problem, I cleared the /tomcat/work/Catalina/localhost folder but always the same bug: java.lang.NoClassDefFoundError The projet work fine in tomcat localhost but when I upload it in a remote tomcat I get this bug:/, I have the jar that contain the ImageReaderFactory class in classpath, I didn't understand what can be the problem, I cleared the / tomcat/work/Catalina/localhost 文件夹但总是相同的错误: java.lang.NoClassDefFoundError

07-Oct-2019 23:06:25.584 SEVERE [http-apr-8080-exec-267] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [UploadServlet] in context with path [/MyServer] threw exception [Servlet execution threw an exception] with root cause
 java.lang.NoClassDefFoundError: org/dcm4che3/imageio/codec/ImageReaderFactory
    at org.dcm4che3.imageio.plugins.dcm.DicomImageReader.setMetadata(DicomImageReader.java:794)
    at org.dcm4che3.imageio.plugins.dcm.DicomImageReader.readMetadata(DicomImageReader.java:713)
    at org.dcm4che3.imageio.plugins.dcm.DicomImageReader.read(DicomImageReader.java:452)
    at com.project.dicomserver.UploadServlet.getFrameIcon(UploadServlet.java:86)
    ....

Does anyone have any ideas?有没有人有任何想法?

image图片

There is a bunch of things that could be go wrong in your specific case.在您的特定情况下,有很多事情可能是 go 错误的。 So answering with the best of my knowledge.因此,尽我所知回答。 Make amendments, by adding as much details as possible, to the question and we can help you further.通过添加尽可能多的细节来对问题进行修改,我们可以为您提供进一步的帮助。

Every application in tomcat needs to have a specific folder structure. tomcat 中的每个应用程序都需要具有特定的文件夹结构。 The folder structure is documented here .文件夹结构在此处记录。 In short, war files must be deployed into $CATALINA_BASE/webapps/ directory.简而言之,war 文件必须部署到$CATALINA_BASE/webapps/目录中。

So if your application is " myapp ", then there must be a $CATALINA_BASE/webapps/myapp directory.因此,如果您的应用程序是“ myapp ”,那么必须有一个$CATALINA_BASE/webapps/myapp目录。

Inside $CATALINA_BASE/webapps/myapp directory, we need to have WEB-INF .$CATALINA_BASE/webapps/myapp目录中,我们需要有WEB-INF Not $CATALINA_BASE/webapps/myapp/WebContent/WEB-INF , but $CATALINA_BASE/webapps/myapp/WEB-INF .不是$CATALINA_BASE/webapps/myapp/WebContent/WEB-INF ,而是$CATALINA_BASE/webapps/myapp/WEB-INF And the case matters.案件很重要。

If this is not how your application is deployed into a vanilla tomcat, it will not work properly.如果这不是您的应用程序部署到 vanilla tomcat 的方式,它将无法正常工作。 Read the official documentation阅读官方文档

Now about your development environment, see whether your eclipse configurations have been modified.现在关于你的开发环境,看看你的 eclipse 配置是否被修改过。 The Export As War options can be modified at multiple locations and all of them can have impact on the war file you have generated. Export As War选项可以在多个位置进行修改,并且所有这些选项都会对您生成的 war 文件产生影响。 When in doubt, I look at this link如有疑问,我会查看此链接

Use a build tool like maven or gradle .使用mavengradle 之类的构建工具。 These tools bring standards for compiling, archiving, testing and deploying applications and makes you worry less on environment related issues.这些工具为编译、归档、测试和部署应用程序带来了标准,让您减少对环境相关问题的担忧。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM