maruTA-bis5 / mattermost4j

Mattermost API v4 Client for Java
Apache License 2.0
31 stars 20 forks source link

java.lang.ClassNotFoundException: Provider for jakarta.ws.rs.client.ClientBuilder cannot be found #481

Closed euronymous closed 2 years ago

euronymous commented 2 years ago

Hi,

I don't know java stuff. I'm guessing that I'm doing something wrong... I'm still getting: java.lang.ClassNotFoundException: Provider for jakarta.ws.rs.client.ClientBuilder cannot be found

$ java -version
openjdk version "11.0.15" 2022-04-19

I'm building a fat jar of course. Iterated through many different SO topics/solutions. Added many different deps:

        "jakarta.activation"          % "jakarta.activation-api"    % "2.0.0",
        "jakarta.xml.bind"            % "jakarta.xml.bind-api"      % "4.0.0",
        "jakarta.ws.rs"               % "jakarta.ws.rs-api"         % "3.1.0",
        "org.glassfish.jersey.core"   % "jersey-client"             % "3.0.4",
        "org.glassfish.jersey.inject" % "jersey-hk2"                % "3.0.4",
        "org.glassfish.jersey.media"  % "jersey-media-json-binding" % "3.0.4",
        "com.fasterxml.jackson.core"  % "jackson-databind"          % "2.13.3",
        "org.glassfish.jersey"        % "jersey-bom"                % "3.0.4",
        "org.jboss.resteasy"          % "resteasy-client"           % "3.0.2.Final"

Then I've added the "activation api" and "xml bindings" (whatever that is) to the cp. Also haven't helped...

$ java -cp ~/.cache/coursier/v1/https/repo1.maven.org/maven2/jakarta/xml/bind/jakarta.xml.bind-api/4.0.0/jakarta.xml.bind-api-4.0.0.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/jakarta/ws/rs/jakarta.ws.rs-api/3.0.0/jakarta.ws.rs-api-3.0.0.jar:~/.cache/coursier/v1/https/repo1.maven.org/maven2/jakarta/activation/jakarta.activation-api/2.1.0/jakarta.activation-api-2.1.0.jar:~/mattermost-notifier/target/scala-2.13/mattermost-notifier-assembly-0.1.0-SNAPSHOT.jar pl.softwerk.mattermost_notifier.Main 
Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: Provider for jakarta.ws.rs.client.ClientBuilder cannot be found
    at jakarta.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:75)
    at net.bis5.mattermost.client4.MattermostClient.buildClient(MattermostClient.java:200)
    at net.bis5.mattermost.client4.MattermostClient.<init>(MattermostClient.java:272)
    at net.bis5.mattermost.client4.MattermostClient$MattermostClientBuilder.build(MattermostClient.java:245)
    at pl.softwerk.mattermost_idle.Main$.run(Main.scala:17)
    at cats.effect.IOApp.main(IOApp.scala:268)
    at cats.effect.IOApp.main$(IOApp.scala:203)
    at pl.softwerk.mattermost_notifier.Main$.main(Main.scala:13)
    at pl.softwerk.mattermost_notifier.Main.main(Main.scala)
Caused by: java.lang.ClassNotFoundException: Provider for jakarta.ws.rs.client.ClientBuilder cannot be found
    at jakarta.ws.rs.client.FactoryFinder.find(FactoryFinder.java:163)
    at jakarta.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:62)
    ... 8 more
maruTA-bis5 commented 2 years ago
  1. Your "jakarta.ws.rs" % "jakarta.ws.rs-api" % "3.1.0" is quite new. The "jersey-client" % "3.0.4" implements ws.rs-api 3.0.0.
  2. Mattermost4j doesn't support RESTEasy currently. It will be available by PR #450 after the release RESTEasy 6.1.0.Final. So you don't need "org.jboss.resteasy" % "resteasy-client" % "3.0.2.Final".

If these dependency changes haven't helped, I don't know about scala and its build system, but I think that your fat jar (or your classpath) does not contain implementation of jakarta.ws.rs.client.ClientBuilder.