I have a maven project that uses hibernate-annotations 3.4.0.GA, which use slf4j-api version 1.5.5 (checked through the dependency tree in the pom.xml file). Further project A indicates the version slf4j-log4j12 version 1.4.2 as a dependency.
Which is not recommended, you should use the same version of slf4j artifacts. From the FAQ:
With rare theoretical exceptions, the SLF4J variants are lagging behind compatible. This means that you can upgrade SLF4J version 1.0 to any later version without a problem.
However, although the SLF4J API is very stable from the point of view of the client, SLF4J such as slf4j-simple or slf4j-log4j12 may require the version of slf4j-api. Mixing different versions of slf4j artifacts can be problematic and very discouraged. For example, if you use slf4j-api-1.5.6.jar, then you should also use slf4j-simple-1.5.6.jar, using slf4j-simple-1.4.2.jar will not work.
At initialization time, if SLF4J suspects that there might be a version issue with a mismatch, it issues a warning about the indicated mismatch. For the exact details of the detection version mismatch, see the corresponding entry in this FAQ.
Something to fix.
which builds fine with maven from the command line. But when I start the project from the eclipse launch configuration, I get (...)
The problem is that you get SLF4J artifacts from B and from A (transitively) and you end up mixing several versions of slf4j-api (1.5.5 and 1.6.1) and several bindings ( slf4j-log4j12 and logback-classic ). SLF4J complains about a later issue at runtime, but you have to fix both.
This message indicates that I need to update the binding in project A to 1.6.x, but I donโt see how this is possible, since it is included in the sleep mode dependency.
Yes, the message suggests updating the binding to a later version. But, more importantly, it says that you have more than ONE binding to the class path: you need to select log4j and logback as logging and provide the appropriate binding, but not both of them.
Is it possible to switch the binding (updating route information) when starting project B so that instead of the version from hibernate version 1.6.1 is used?
To strictly answer this question about version control in transitive dependencies, this can be done using the dependencyManagement element. Here is an example:
<project> ... <dependencyManagement> <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.1</version> </dependency> </dependencies> </dependencyManagement> ... <dependencies> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>3.4.0.GA</version> </dependency> </dependencies> ... </project>
And artifacts with slf4j-api as a dependency, such as the Hibernate EntityManager, will use version 1.6.1, as shown below:
$ mvn dependency: tree
...
[INFO] + - org.hibernate: hibernate-entitymanager: jar: 3.4.0.GA: compile
[INFO] | + - org.hibernate: ejb3-persistence: jar: 1.0.2.GA: compile
[INFO] | + - org.hibernate: hibernate-commons-annotations: jar: 3.1.0.GA: compile
[INFO] | + - org.hibernate: hibernate-annotations: jar: 3.4.0.GA: compile
[INFO] | + - org.hibernate: hibernate-core: jar: 3.3.0.SP1: compile
[INFO] | | + - antlr: antlr: jar: 2.7.6: compile
[INFO] | | \ - commons-collections: commons-collections: jar: 3.1: compile
[INFO] | + - org.slf4j: slf4j-api: jar: 1.6.1: compile
[INFO] | + - dom4j: dom4j: jar: 1.6.1: compile
[INFO] | | \ - xml-apis: xml-apis: jar: 1.0.b2: compile
[INFO] | + - javax.transaction: jta: jar: 1.1: compile
[INFO] | \ - javassist: javassist: jar: 3.4.GA: compile
But, as I said, the real problem is that you only need to have one binding in the classpath. Either choose log4j or logback, just not both, and specify the appropriate bindings.