Payara, "java.lang.NoSuchMethodError: com.google.common.collect..." Problem and Solution

Payara Server loads own libraries / jars like e.g. Google's Guava first. In case your application uses a recent feature (e.g. a method) in a newer version of such a library, you will get an exception like:

Caused by: java.lang.NoSuchMethodError: com.google.common.collect.Sets$SetView.iterator()Lcom/google/common/collect/UnmodifiableIterator;

Turning off the class loader delegation solves the problem:


<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE payara-web-app PUBLIC "-//Payara.fish//DTD Payara Server 4 Servlet 3.0//EN" "https://docs.payara.fish/schemas/payara-web-app_4.dtd">
    <payara-web-app error-url="">
    <class-loader delegate="false"/>
</payara-web-app>

However, a code refactoring and the removal of the dependency from the pom.xml and using Java 8+ / Java EE features only will make your WARs thinner and docker deployments faster:

See you at Web, MicroProfile and Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


Cloudy Jakarta EE and MicroProfile: Microservices, Clouds and Beyond Jakarta EE / MicroProfile airhacks workshops at MUC airport, Winter Edition

airhacks.fm the podcast:

Stay in touch: airhacks.news.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
realworldpatterns.com
...the last 150 posts
...the last 10 comments
License