迁移到JDK 11时发生错误"java.lang.NoClassDefFoundError:javax/activation/DataSource". (tomcat 9.0.12) [英] Migration to JDK 11 has error occure "java.lang.NoClassDefFoundError: javax/activation/DataSource" (tomcat 9.0.12)

查看:488
本文介绍了迁移到JDK 11时发生错误"java.lang.NoClassDefFoundError:javax/activation/DataSource". (tomcat 9.0.12)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JDK8迁移Java项目以使用JDK 11,然后发生了与javax激活有关的错误. 遵循Oracle的迁移指南,我看到java.activation该模块已从JDK 11中删除.

I'm migrating java project use JDK8 to use JDK 11 then has error occurred relate of javax activation. Following migration guide from Oracle, I see java.activation that module was removed from JDK 11.

此后,我建议添加第三方activation-1.0.2.jar *,但是仍然发生错误? 请给我一个关于问题的建议?能否告诉我有关从Java 8到Java 11的迁移体验(使用Tomcat 2018.09(4.9.0)的带有tomcat 9.0.12.编译器的服务器)

After that, I give a suggest to added third parties **activation-1.0.2.jar* but still, an error has occurred? Please give a suggestion about problem ? and could you tell me about experience of Migration source code use Java 8 to Java 11 (server with tomcat 9.0.12. compiler by Eclipse 2018-09(4.9.0)

这是详细信息错误:

Caused by: java.lang.NoClassDefFoundError: javax/activation/DataSource
    at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3167)
    at java.base/java.lang.Class.getDeclaredMethods(Class.java:2310)
    at org.apache.catalina.util.Introspection.getDeclaredMethods(Introspection.java:133)
    at org.apache.catalina.startup.WebAnnotationSet.loadMethodsAnnotation(WebAnnotationSet.java:285)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:138)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:69)
    at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:328)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:768)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5007)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)

推荐答案

您似乎包含了错误的工件(外部jar ).

You seem to have included an incorrect artifact(external jar).

您应将 javax.activation:javax.activation-api:1.2.0 作为项目的外部依赖项,以显式访问类 javax.activation.DataSource .相同的样本Maven依赖关系将是:

You should include javax.activation:javax.activation-api:1.2.0 as an external dependency to your project to explicitly access the class javax.activation.DataSource. Sample maven dependency for the same would be:

<dependency>
  <groupId>javax.activation</groupId>
  <artifactId>javax.activation-api</artifactId>
  <version>1.2.0</version>
</dependency>

此外,请注意 如果 使用模块化代码(包括module-info.java),则必须使用声明-

Also, note if using modularised code (includes module-info.java), you must state a dependence on the library using declaration -

requires java.activation;

这篇关于迁移到JDK 11时发生错误"java.lang.NoClassDefFoundError:javax/activation/DataSource". (tomcat 9.0.12)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆