3

When switching my grails app from Java 8 to Java >=9 (actually testing with Java 11) I get different ClassNotFound exceptions.

The problem is, that some Java EE API modules are marked @Deprecated(forRemoval=true), so they may be removed in Java 11.

I already upgraded another app, that's having a Maven pom.xml file. Adding these deps, resolves the problem:

<dependencies>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-core</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.3.0</version>
    </dependency>
</dependencies>

But now I have to update an app that has no pom file. For now I've imported the project in IntelliJ. I tried to add a Maven/pom.xml but everytime I build the exploded war and run it with Jetty, the deps can't be found.

Resolve java.lang.ClassNotFoundException: javax.xml.bind.JAXBException

What is the proposed way to add these missing deps (with or without using Maven)?

pnine
  • 83
  • 1
  • 8
  • 1
    You should use Maven. I think you need a plugin to tell it to create a fat WAR with the dependencies added. Or you could use Spring Boot and forego a WAR. – duffymo Jun 26 '18 at 11:46
  • You can import 3rd party libraries at module settings menu. Try to specify jaxb-api .jar file. – Mikhail Kholodkov Jun 26 '18 at 11:57
  • See https://www.jetbrains.com/help/idea/working-with-module-dependencies.html. – CrazyCoder Jun 26 '18 at 18:21
  • Thanks, I finally got it working by adding the deps to grails BuildConfig.groovy with maven central repository. Maybe gradle is the way to go, since grails 3 is using the gradle build system? – pnine Jun 26 '18 at 21:47

0 Answers0