1

I generated a "package" .jar with dependancies using maven, however when deployed, developer who deployed it have the following error :

10:23:27.604 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver - Resolving exception from handler [public org.springframework.http.ResponseEntity<?> company.Api.convertXmlToPdf(javax.servlet.http.HttpServletRequest)]: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: javafx/util/Pair
10:23:27.606 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver - Resolving exception from handler [public org.springframework.http.ResponseEntity<?> company.Api.convertXmlToPdf(javax.servlet.http.HttpServletRequest)]: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: javafx/util/Pair
10:23:27.606 [http-nio-8080-exec-1] DEBUG org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver - Resolving exception from handler [public org.springframework.http.ResponseEntity<?> company.Api.convertXmlToPdf(javax.servlet.http.HttpServletRequest)]: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: javafx/util/Pair

Seems like the .jar does not include any dependance with javafx/util/Pair.

I've tried to add the dependancies using maven, adding the lib to the project :

    <dependency>
        <groupId>javafx</groupId>
        <artifactId>jfxrt</artifactId>
        <version>2.2.3</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/lib/jfxrt.jar</systemPath>
    </dependency>

Does not work.

I've tried to add

    <plugin>
            <groupId>com.zenjava</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>8.8.3</version>
            <configuration>
                <mainClass>hermes.Api</mainClass>
            </configuration>
    </plugin>

in my build configuration (pom). Does not work either...

When tested in local, it runs well all tests are passed and I've a result. When building the package lifecycle build with maven, the Build is successful. However, when deployed, I've the error mentionned above, like the Pair class is not found...

Both the developer machine and deployement machine are using

java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

(deployement machine is using _172 version...)

EDIT: it is not a solution to the issue, but since the only part of the javafx used in the code is Pair, I've repalced it by AbstractMap.SimpleEntry which is mostly the same as Pair. I hope this might help someone...

Cromm
  • 328
  • 6
  • 25
  • Check this thread : https://stackoverflow.com/questions/16868446/javafx-exception-in-thread-main-java-lang-noclassdeffounderror-javafx-applica – Anwar Benhamada Jun 24 '19 at 10:01
  • @Cromm Looks like it is jdk/jre versions nightmare. javafx.util.* is not included in OpenJDK which is supposed to be used on deployement machine. If you use only Pair class from javafx.util.* just try to find alternative implementation of Pair i.e.Apache Commons library. – Oleks Jun 24 '19 at 14:07
  • 1
    @Oleksandr : Thanks, yes, it was most likely a versionning issue, as stated in the last edit of my question, I implemented an alternative and changed Pair to SimpleEntry. – Cromm Jun 25 '19 at 13:45

0 Answers0