kevoree / kevoree-library

Kevoree base library
GNU Lesser General Public License v3.0
2 stars 0 forks source link

Kevoree Java Class Loader #19

Closed tdalianis closed 8 years ago

tdalianis commented 8 years ago

Hi,

In my project I am trying to open some docker kevoree nodes programmatically and for that I am using the docker-java library. In order to add more nodes, the component responsible (DockerTrigger) first needs to receive a message from another component (DockerMessenger). The problem is that when DockerTrigger receives the message and tries to initialize the DockerHelper class I get an error which seems to be related with the class loader. The classes that are not found, are present in the maven repository.

The kevoree version is 5.3.1

dockerTester.zip

Any ideas?

tdalianis commented 8 years ago

With the new version (5.4.0-SNAPSHOT) on linux during maven install I get the attached errors. On windows 8.1 it builds successfully.

error_full.txt error_short.txt

maxleiko commented 8 years ago

In order for Maven to download SNAPSHOT artifacts you need to specify the proper repositories:

    <repositories>
        <repository>
            <id>kevoree-oss</id>
            <url>https://oss.sonatype.org/content/groups/public/</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>plugin.kevoree-oss</id>
            <url>https://oss.sonatype.org/content/groups/public/</url>
        </pluginRepository>
    </pluginRepositories>

Do you have that in your pom.xml ?

tdalianis commented 8 years ago

I have that yes.

It seems that the problem continues, in the 5.4.0-SNAPSHOT version as well. Please have a docker service running accessible by tcp (2375), change the dockerHost in the DockerTrigger class (addNode function) and then start two kevoree nodes in linux, one with name 'dockerMaster' and one with name 'tester' with mvn kev:run. You will get an output like

01:18 INFO: message received, scheduling... 01:23 INFO: in scheduler... 01:23 INFO: initializing docker client... dockerIP:192.168.1.177, port:2375 SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

At the same point that there was the class loader error now there is 'silence' but the program doesn't continue its tasks, which indicates a silent exception.

The correct output produced running the main function of the as java application should something like this:

00:00 INFO: in scheduler...initializing simple.. 00:00 INFO: initializing docker tester... dockerIP:192.168.1.177, port:2375 SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 00:01 INFO: client:com.github.dockerjava.core.DockerClientImpl@5fcd892a 00:01 INFO: adding new docker node...heads.test.DockerTester@8b87145 -Dnode.bootstrap=/opt/kevoree/tester.kevs com.github.dockerjava.api.command.CreateContainerResponse@5b67bb7e[id=11eeaac0d2df0b33e8bbf93e7f17e6155ffdcca50b93027f4955830e96ea3c34,warnings=] 00:02 INFO: node added {"host":"192.168.1.177","nodeType":"processor","nodeSubType":"testProcessor","nodeName":"tester","containerID":"11eeaac0d2df0b33e8bbf93e7f17e6155ffdcca50b93027f4955830e96ea3c34"}

maxleiko commented 8 years ago

dockerTester.tar.gz

This just works.

maxleiko commented 8 years ago

I let that open for you to test and tell me if Something goes wrong

tdalianis commented 8 years ago

I am afraid that you will have to test it with the two nodes. The problem is not on startup but when the second node receives the message and tries to initialize the docker client (DockerTrigger line 83, DockerTester line 69). With the old version there was an exception, with the new one no error but it simply stops. dockerTester.zip

maxleiko commented 8 years ago

https://github.com/kevoree/kevoree-library/commit/b9a23d75003087b4f2b6230b8b8c7629788e897b

This should fix the ClassNotFoundException for @Input method calls. The inputs were invoked with the Channel context ClassLoader instead of the Component context ClassLoader which obviously led to ClassLoading issues :)