Skip to content

Commit e0e63e4

Browse files
committed
Dynamic loading of slf4j binding does not work
See https://github.com/culturegraph/metafacture-runner/issues/2 This commit adds the log4j binding for slf4j to the class path. Our attempts to load the slf4j binding dynamically from the `provided-libs` dir does not work as expected. slf4j does not consider the context class loader for loading its binding but relies on the class loader which was used to load the classes of the slf4j api. Until a solution is found for this problem, the binding need to be placed on the class pathslf4j does not consider the context class loader for loading its binding but relies on the class loader which was used to load the classes of the slf4j api. Until a solution is found for this problem, the binding need to be placed on the class path.
1 parent e988cfe commit e0e63e4

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

pom.xml

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -222,27 +222,34 @@
222222
<version>2.0.0-SNAPSHOT</version>
223223
</dependency>
224224

225-
<!-- The following dependencies are placed in the "provided"
226-
scope to prevent them from being included in the class
227-
path but still have them available for building the
228-
distribution assembly.
229-
The reason for this is that appropriate implementations
230-
for slf4j and jndi depend on the runtime environment and
231-
should be chosen by the user of the package and not the
232-
package implementer. However, since we are not also
233-
building a distribution package which should include
234-
everything that is required for metafacture-runner/Flux
235-
to work out of the box. By including the dependencies
236-
in the assembly without putting them on the class path,
237-
the user can replace them easily with other
238-
implementations if necessary. -->
225+
<!-- In a perfect world the slf4j binding would be a
226+
provided dependency so that the user can replace
227+
it easily with a different binding. However, slf4j
228+
does not use the context class loader for loading
229+
its binding but the same class loader which was
230+
used to load the classes of the slf4j-api. Until
231+
a solution is found for this problem, the binding
232+
need to be placed on the class path. -->
239233
<dependency>
240234
<groupId>org.slf4j</groupId>
241235
<artifactId>slf4j-log4j12</artifactId>
242236
<version>1.7.6</version>
243-
<scope>provided</scope>
244237
</dependency>
245238

239+
<!-- The following dependencies are placed in the "provided"
240+
scope to prevent them from being included in the class
241+
path but still have them available for building the
242+
distribution assembly.
243+
The reason for this is that an appropriate implementation
244+
for jndi depends on the runtime environment and
245+
should be chosen by the user of the package and not the
246+
package implementer. However, we also attempt to build
247+
a distribution package which should include everything
248+
that is required for metafacture-runner/Flux to work out
249+
of the box. By including the dependencies in the assembly
250+
without putting them on the class path, the user can
251+
replace them easily with other implementations if
252+
necessary. -->
246253
<dependency>
247254
<groupId>simple-jndi</groupId>
248255
<artifactId>simple-jndi</artifactId>

0 commit comments

Comments
 (0)