vert-x3 / issues

Apache License 2.0
37 stars 5 forks source link

Infinispan got error with SqlAuthentication #589

Closed junnhk closed 3 years ago

junnhk commented 3 years ago

Hi Vertx team,

We are using Vertx on our private project, and we got the error.

Our environments:

  1. Vertx : 4.2.0/4.1.5
  2. Java : 17/11
  3. Linuxmint 20

We created a Service Proxy for user to sign-up and sign-in, the constructor of implementation class of Service interface has following code:

public class UserServiceImpl implements UserService {
    private SqlClient pgService = null;
    private SqlAuthentication sqlAuthProvider = null;

    public UserServiceImpl(Vertx vertx) {

        vertx.executeBlocking(promise -> {
            pgService = PgPool.client(vertx, PgConnectOpts(), .PgPoolOpts());
            if(pgService != null) {
                promise.complete(pgService);
            } else {
                promise.fail("Failed to create SqlClient");
            }
        }, res -> {
            if(res.succeeded()) {
                sqlAuthProvider = SqlAuthentication.create((SqlClient)res.result(), new SqlAuthenticationOptions());
            } 
        });
    }
   ...................
}

The build was as normal but when we run fat jar then we got this error

Oct 31, 2021 2:16:44 AM io.vertx.ext.cluster.infinispan.InfinispanClusterManager
WARNING: Cannot find Infinispan config 'infinispan.xml', using default
Oct 31, 2021 2:16:45 AM org.infinispan.registry.impl.InternalCacheRegistryImpl registerInternalCache
WARN: ISPN000569: Unable to persist Infinispan internal caches as no global state enabled
Oct 31, 2021 2:16:45 AM org.infinispan.factories.GlobalComponentRegistry preStart
INFO: ISPN000128: Infinispan version: Infinispan 'Taedonggang' 12.1.7.Final
Oct 31, 2021 2:16:45 AM org.infinispan.marshall.core.impl.DelegatingUserMarshaller start
INFO: ISPN000556: Starting user marshaller 'org.infinispan.commons.marshall.ImmutableProtoStreamMarshaller'
Oct 31, 2021 2:16:45 AM org.infinispan.remoting.transport.jgroups.JGroupsTransport start
INFO: ISPN000078: Starting JGroups channel ISPN with stack jgroups
Oct 31, 2021 2:16:45 AM org.jgroups.stack.Configurator resolveAndAssignField
WARNING: JGRP000014: STABLE.stability_delay has been deprecated: always 0
Oct 31, 2021 2:16:48 AM org.jgroups.protocols.pbcast.ClientGmsImpl joinInternal
INFO: home-61660: no members discovered after 2006 ms: creating cluster as coordinator
Oct 31, 2021 2:16:48 AM org.infinispan.remoting.transport.jgroups.JGroupsTransport receiveClusterView
INFO: ISPN000094: Received new cluster view for channel ISPN: [home-61660|0] (1) [home-61660]
Oct 31, 2021 2:16:48 AM org.infinispan.remoting.transport.jgroups.JGroupsTransport startJGroupsChannelIfNeeded
INFO: ISPN000079: Channel ISPN local address is home-61660, physical addresses are [172.23.0.1:7800]
Oct 31, 2021 2:16:49 AM org.jboss.threads.Version <clinit>
INFO: JBoss Threads version 2.3.3.Final
Oct 31, 2021 2:16:49 AM io.vertx.core.impl.ContextImpl
SEVERE: Unhandled exception
java.util.ServiceConfigurationError: io.vertx.ext.auth.HashingAlgorithm: Provider io.vertx.ext.auth.impl.hash.PBKDF2 could not be instantiated
    at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:586)
    at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:813)
    at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:729)
    at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1403)
    at io.vertx.ext.auth.HashingStrategy.load(HashingStrategy.java:44)
    at io.vertx.ext.auth.sqlclient.impl.SqlAuthenticationImpl.<init>(SqlAuthenticationImpl.java:44)
    at io.vertx.ext.auth.sqlclient.SqlAuthentication.create(SqlAuthentication.java:52)
    at io.returvis.service.impl.UserServiceImpl.lambda$new$1(UserServiceImpl.java:44)
    at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:141)
    at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:54)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.util.ServiceConfigurationError: java.net.spi.URLStreamHandlerProvider: Provider org.infinispan.commons.jdkspecific.ClasspathURLStreamHandlerProvider not found
    at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:593)
    at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1219)
    at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1228)
    at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1273)
    at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309)
    at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393)
    at java.base/java.net.URL$1.getNext(URL.java:1317)
    at java.base/java.net.URL$1.hasNext(URL.java:1332)
    at java.base/java.net.URL$2.run(URL.java:1359)
    at java.base/java.net.URL$2.run(URL.java:1356)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
    at java.base/java.net.URL.lookupViaProviders(URL.java:1355)
    at java.base/java.net.URL.getURLStreamHandler(URL.java:1441)
    at java.base/java.net.URL.<init>(URL.java:680)
    at java.base/java.net.URL.<init>(URL.java:569)
    at java.base/java.net.URL.<init>(URL.java:516)
    at java.base/javax.crypto.JceSecurity.<clinit>(JceSecurity.java:246)
    at java.base/javax.crypto.SecretKeyFactory.nextSpi(SecretKeyFactory.java:299)
    at java.base/javax.crypto.SecretKeyFactory.<init>(SecretKeyFactory.java:117)
    at java.base/javax.crypto.SecretKeyFactory.getInstance(SecretKeyFactory.java:164)
    at io.vertx.ext.auth.impl.hash.PBKDF2.<init>(PBKDF2.java:46)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789)
    ... 15 more

This happened only with infinispan cluster while it worked with hazelcast cluster (same code)

junnhk commented 3 years ago

We got same above error when we created our own hashingPassword function instead of using SqlAuthentication.

tsegismont commented 3 years ago

It seems infinispan-commons JAR has a /META-INF/services/java.net.spi.URLStreamHandlerProvider file which contains:

org.infinispan.commons.jdkspecific.ClasspathURLStreamHandlerProvider

But the corresponding class in not available in the JAR, only in infinispan-commons-jdk11.

Is that a known issue @tristantarrant?

tristantarrant commented 3 years ago
unzip -v infinispan-commons-12.1.7.Final.jar |grep ClasspathURLStreamHandlerProvider
    1677  Defl:N      778  54% 2021-07-14 08:35 3309a4c5  META-INF/versions/11/org/infinispan/commons/jdkspecific/ClasspathURLStreamHandlerProvider$1.class
     968  Defl:N      484  50% 2021-07-14 08:35 c909fda9  META-INF/versions/11/org/infinispan/commons/jdkspecific/ClasspathURLStreamHandlerProvider.class

Are you by any chance creating a uberjar and forgetting to enable the Multi-Release: true in the META-INF/MANIFEST.MF file ?

tsegismont commented 3 years ago

Thank you @tristantarrant

@junnhk can you confirm?

junnhk commented 3 years ago

@tsegismont sure, after re-packaging fat jar with missing class, the app worked properly.