Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generateJooqClasses task fails on Windows [Workaround Available] #7

Closed
kzhang22 opened this issue Oct 15, 2022 · 2 comments
Closed

Comments

@kzhang22
Copy link

kzhang22 commented Oct 15, 2022

Hello!

Currently, when building this project on a Windows machine, the generateJooqClasses task fails. There appears to be an issue where docker-java attempts to use a unix socket although running from a Windows machine.

Windows 10 Home
Docker Version 20.10.17
Java 11.0.16.1

Steps to reproduce

  1. Clone the repository and go into the directory backend-coding-challenge
  2. Run the command ./gradlew.bat generateJooqClasses

Expected Behavior

JOOQ Classes generated.

Expected Output:

127.0.0.1:5432 - no response
waiting for db
127.0.0.1:5432 - no response
waiting for db
127.0.0.1:5432 - no response
waiting for db
127.0.0.1:5432 - accepting connections

BUILD SUCCESSFUL in 16s
1 actionable task: 1 executed

Current Behavior

> ./gradlew.bat generateJooqClasses --stacktrace
Error during callback
java.net.SocketException: A socket operation encountered a dead network.

        at org.newsclub.net.unix.NativeUnixSocket.connect(Native Method)
        at org.newsclub.net.unix.AFUNIXSocketImpl.connect(AFUNIXSocketImpl.java:263)
        at org.newsclub.net.unix.AFUNIXSocket.connect(AFUNIXSocket.java:156)
        at com.github.dockerjava.jaxrs.ApacheUnixSocket.connect(ApacheUnixSocket.java:62)
        at com.github.dockerjava.jaxrs.UnixConnectionSocketFactory.connectSocket(UnixConnectionSocketFactory.java:74)
        at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
        at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)
        at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
        at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
        at org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:480)
        at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:296)
        at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:623)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:205)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:390)
        at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:621)
        at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:432)
        at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:333)
        at com.github.dockerjava.jaxrs.async.POSTCallbackNotifier.response(POSTCallbackNotifier.java:29)
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:50)
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:24)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
> Task :generateJooqClasses FAILED

FAILURE: Build failed with an exception.

Workaround


I have found a related issue in the jooq-plugin library here: revolut-engineering/jooq-plugin#15

In order to workaround this, I had to update the com.revolut.jooq-docker plugin from version 0.3.3 -> 0.3.7 as well as go to my environment variables and add an extra system variable DOCKER_HOST as npipe:////./pipe/docker_engine.

If you look on the linked issue, there was a fix made on the docker-java library released here: https://github.com/docker-java/docker-java/releases/tag/3.2.12 in the following PR: (docker-java/docker-java#1701) to avoid adding the system variable workaround.

The base jooq-plugin library does not currently have this fix in yet. A fork can be created to simply update the docker-java version. There are also existing forks listed under the issue that have the fix implemented.

@ISafronenko
Copy link

ISafronenko commented Oct 18, 2022

I had the very same issue on MacBook Pro M1 2021:

Configuration:

  • OS: macOs Monterey 12.6
  • Docker: Client: Docker Engine - Community Version: 20.10.18
  • Gradle 7.5.1
  • openjdk version "17.0.3" 2022-04-19
  • com.revolut.jooq-docker 0.3.3

Stacktrace:

2022-10-18T20:32:45.685+0200 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Opening connection {}->unix://localhost:80
2022-10-18T20:32:45.685+0200 [DEBUG] [org.apache.http.impl.conn.DefaultManagedHttpClientConnection] http-outgoing-34: Shutdown connection
2022-10-18T20:32:45.686+0200 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Connection discarded
2022-10-18T20:32:45.686+0200 [DEBUG] [com.github.dockerjava.jaxrs.JerseyDockerCmdExecFactory$1] Connection released: [id: 34][route: {}->unix://localhost:80][total available: 0; route allocated: 0 of 2; total allocated: 0 of 20]
2022-10-18T20:32:45.686+0200 [INFO] [org.apache.http.impl.execchain.RetryExec] I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: Couldn't load native library
2022-10-18T20:32:45.686+0200 [DEBUG] [org.apache.http.impl.execchain.RetryExec] Couldn't load native library
java.io.IOException: Couldn't load native library
        at org.newsclub.net.unix.AFUNIXSocket.setIsCreated(AFUNIXSocket.java:58)
        at org.newsclub.net.unix.AFUNIXSocket.<init>(AFUNIXSocket.java:50)
        at org.newsclub.net.unix.AFUNIXSocket.newInstance(AFUNIXSocket.java:79)

After applying suggestions from @kzhang22 everything works as expected:

  • version of the com.revolut.jooq-docker bumped to 0.3.7
  • added DOCKER_HOST env var: export DOCKER_HOST=npipe:////./pipe/docker_engine

@aynroot
Copy link
Collaborator

aynroot commented Oct 21, 2022

Thanks, folks!

We have incorporated the suggestions and updated the README file accordingly.

@aynroot aynroot closed this as completed Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants