10

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.

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)

This is detail error :

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)
0

1 Answer 1

22

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

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>

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

requires java.activation;
Sign up to request clarification or add additional context in comments.

13 Comments

javax.activation:javax.activation-api:1.2.0 is not a module, so requires java.activation has no meaning. In Java 9 and 10, you can use requires java.activation or --add-modules java.activation instead of including the dependency. In Java 11+ the module doesn't exist in the JDK anymore, so requires java.activation won't work there.
@nullpointer Thank you for your help, I don't use maven on project now. I'm using java build path. I added javax.activation-api:1.2.0 to external JARs, but that error still occurred ?
@Andreas Do you mean that adding external lib is no meaning with java 11 ? Then, could you help me a more detail suggestion for solve this problem ?
@Andreas I am aware of the fact that the javax.activation:javax.activation-api:1.2.0 is not a module and hence mentioned it as a dependency(just a way of depicting a complete artifact name). Could not relate to the question being asked in terms of framework in use earlier. And yes, in Java 11 the module is not there, but if you explicitly add the dependency and prefer to have a module-info.java in the project the requires is as valid as in Java 9.10.
@SuperBeam While you're executing the application where do you see the dependency being involved in? Is it present in the classpath?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.