Couchbase java lite 1.4.4 + Java 11 (oracle or OpenJDK)

Hy,

couchbase-lite-java Pullreplication|PushReplication doesn’t work with openjdk 11 | Oracle Java 11

JavaContext context = new JavaContext();
Manager manager = new Manager(context, Manager.DEFAULT_OPTIONS);
CouchbaseLiteHttpClientFactory cblHttpClientfactory = new CouchbaseLiteHttpClientFactory(db.getPersistentCookieStore());
cblHttpClientfactory.allowSelfSignedSSLCertificates();
manager.setDefaultHttpClientFactory(cblHttpClientfactory);
Replication pull = db.createPullReplication(url);
pull.setContinuous(true);
pull.start();

PullReplicator start but nothing else. No synchronize

Can you help me please ?

Probably the url is wrong. Add a listener/observer to the replication and see what errors you get.

CBL 1.4 is almost at end-of-life and none of us have worked with it much in a long time. Are you planning to upgrade to 2.x soon?

Hy,
thank you for your reply
I am talking about couchbase java lite and not Android
I think there is no version 2 yet for this API
Concerning my problem, it works perfectly with Java8 but not with Java11

I found the solution. In fact, it comes from okhttpclient (used by couchbase lite)
Here’s the code for it to work if someone meets the problem

    try {
        TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        trustManagerFactory.init((KeyStore) null);
        TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
        if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) {
            throw new IllegalStateException("Unexpected default trust managers:" + Arrays.toString(trustManagers));
        }
        X509TrustManager trustManager = (X509TrustManager) trustManagers[0];
        SSLContext sslContext = SSLContext.getInstance("SSL");
        sslContext.init(null, trustAllCerts, null);
        SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
        OkHttpClient client = new OkHttpClient.Builder().sslSocketFactory(sslSocketFactory, trustManager).build();
        HttpClientFactoryGN clientFactory = new HttpClientFactoryGN(client);
        manager.setDefaultHttpClientFactory(clientFactory);
    } catch (KeyStoreException e) {
        e.printStackTrace();
    }