Coder Social home page Coder Social logo

Comments (5)

viktortnk avatar viktortnk commented on August 28, 2024

Hi. Could you tell what is inside 'MyDockerCassandraService' trait. It might lead to NullPointerException if it uses 'docker' object before it is initialised.

If you make a fork of this repo and put your code there, I'll have a look

from docker-it-scala.

UriShohet avatar UriShohet commented on August 28, 2024

Hi,

Sorry for the delayed reply. MyDockerCassandraService is just a copy of your DockerCassandraService, it was a desperate move :-)

I've cloned today your repo and tried to run sbt test and it failed as follows:

[error] Uncaught exception when running whisk.docker.AllAtOnceSpec: java.lang.NullPointerException
sbt.ForkMain$ForkError
    at com.github.dockerjava.jaxrs.DockerCmdExecFactoryImpl.init(DockerCmdExecFactoryImpl.java:111)
    at com.github.dockerjava.core.DockerClientImpl.withDockerCmdExecFactory(DockerClientImpl.java:60)
    at com.github.dockerjava.core.DockerClientBuilder.build(DockerClientBuilder.java:61)
    at whisk.docker.Docker.<init>(Docker.scala:7)
    at whisk.docker.DockerKit$class.$init$(DockerKit.scala:12)
    at whisk.docker.AllAtOnceSpec.<init>(AllAtOnceSpec.scala:8)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at java.lang.Class.newInstance(Class.java:442)
    at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:646)
    at sbt.ForkMain$Run$2.call(ForkMain.java:294)
    at sbt.ForkMain$Run$2.call(ForkMain.java:284)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[error] Uncaught exception when running whisk.docker.MongodbServiceSpec: java.lang.NullPointerException
sbt.ForkMain$ForkError
    at com.github.dockerjava.jaxrs.DockerCmdExecFactoryImpl.init(DockerCmdExecFactoryImpl.java:111)
    at com.github.dockerjava.core.DockerClientImpl.withDockerCmdExecFactory(DockerClientImpl.java:60)
    at com.github.dockerjava.core.DockerClientBuilder.build(DockerClientBuilder.java:61)
    at whisk.docker.Docker.<init>(Docker.scala:7)
    at whisk.docker.DockerKit$class.$init$(DockerKit.scala:12)
    at whisk.docker.MongodbServiceSpec.<init>(MongodbServiceSpec.scala:8)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at java.lang.Class.newInstance(Class.java:442)
    at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:646)
    at sbt.ForkMain$Run$2.call(ForkMain.java:294)
    at sbt.ForkMain$Run$2.call(ForkMain.java:284)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[error] Uncaught exception when running whisk.docker.KafkaServiceSpec: java.lang.NullPointerException
sbt.ForkMain$ForkError
    at com.github.dockerjava.jaxrs.DockerCmdExecFactoryImpl.init(DockerCmdExecFactoryImpl.java:111)
    at com.github.dockerjava.core.DockerClientImpl.withDockerCmdExecFactory(DockerClientImpl.java:60)
    at com.github.dockerjava.core.DockerClientBuilder.build(DockerClientBuilder.java:61)
    at whisk.docker.Docker.<init>(Docker.scala:7)
    at whisk.docker.DockerKit$class.$init$(DockerKit.scala:12)
    at whisk.docker.KafkaServiceSpec.<init>(KafkaServiceSpec.scala:8)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at java.lang.Class.newInstance(Class.java:442)
    at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:646)
    at sbt.ForkMain$Run$2.call(ForkMain.java:294)
    at sbt.ForkMain$Run$2.call(ForkMain.java:284)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[error] Uncaught exception when running whisk.docker.ElasticsearchServiceSpec: java.lang.NullPointerException

When I checked out this version - 57dbf52, and changed the
"docker-java" version to "1.2.0", because there was some problem with downloading 0.10.4, I got this error - it failed because it was trying to connect to localhost:2376:

[info] CassandraServiceSpec:
08:44:50.098 [ForkJoinPool-1-worker-13] DEBUG c.g.d.core.command.AbstrDockerCmd - Cmd: images 
08:44:50.421 [ForkJoinPool-1-worker-13] DEBUG c.g.d.jaxrs.DockerCmdExecFactoryImpl - 1 * Sending client request on thread ForkJoinPool-1-worker-13
1 > GET https://localhost:2376/images/json?all=0
1 > Accept: application/json

log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
[info] Exception encountered when attempting to run a suite with class name: whisk.docker.CassandraServiceSpec *** ABORTED ***
[info]   Exception encountered when attempting to run a suite with class name: whisk.docker.CassandraServiceSpec (DockerTestKit.scala:37)
08:44:50.688 [ForkJoinPool-1-worker-11] DEBUG c.g.d.core.command.AbstrDockerCmd - Cmd: images 
[info] Neo4jServiceSpec:
08:44:50.747 [ForkJoinPool-1-worker-11] DEBUG c.g.d.jaxrs.DockerCmdExecFactoryImpl - 1 * Sending client request on thread ForkJoinPool-1-worker-11
1 > GET https://localhost:2376/images/json?all=0
1 > Accept: application/json

[info] Exception encountered when attempting to run a suite with class name: whisk.docker.Neo4jServiceSpec *** ABORTED ***
[info]   Exception encountered when attempting to run a suite with class name: whisk.docker.Neo4jServiceSpec (DockerTestKit.scala:37)

When I did

export DOCKER_HOST=http://mydockerrepo:4243
sbt test

the tests passed - the old version and today's version.
Is your docker daemon listening on port 2376? What happens when you change it and try to run the test? When the port is different from 2376 and you override the implicit val docker - does it work for you?

Please let me know if you need more info from me.
Thanks in advance,
Uri

from docker-it-scala.

zapletal-martin avatar zapletal-martin commented on August 28, 2024

The NullPointerException may be caused by initialization order. See for example http://docs.scala-lang.org/tutorials/FAQ/initialization-order.html. It would be preferred if docker-it provided a convenient way to override the configuration.

Currently there are still options how to override the docker implicit val. One of them is the early initializer approach, e.g.

BackendITTest extends {
  override implicit val docker: Docker = ...
} 
with FlatSpecLike
with Matchers
...

from docker-it-scala.

viktortnk avatar viktortnk commented on August 28, 2024

According to stacktraces above, I see NullPointerException happens inside docker-java library.

Until very recent changes container definitions were bound to implicit docker: Docker value. I made them isolated.

Hopefully that should help with safer overriding of docker value. I suggest trying this with v0.4.0 of the library.

I'm sorry for not putting much attention to this issue :(

from docker-it-scala.

viktortnk avatar viktortnk commented on August 28, 2024

There was no updates for this issue. Before closing it, I'll just leave an example of how we overriding it

package whisk.docker.services

import com.github.dockerjava.core.DockerClientConfig
import com.github.dockerjava.jaxrs.DockerCmdExecFactoryImpl
import com.whisk.docker.{Docker, DockerKit}

trait DockerKitBase extends DockerKit {
  override implicit val docker: Docker =
    new Docker(
      DockerClientConfig.createDefaultConfigBuilder().build(),
      new DockerCmdExecFactoryImpl())
}

from docker-it-scala.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.