Lyndon Lyndon - 1 month ago 11
Java Question

OpenShift, Log4j2 & Maven - Could not resolve dependencies for project

I have created and run a stand-alone Java program that logs via Log4j2 using Slf4j. The logging worked as expected.

I then added this functionality to an existing (and working) OpenShift Java web application that I am developing in an Eclipse IDE.

I added the following dependencies to pom.xml

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.7</version>
</dependency>


I used a simple log4j2.xml configuration file and added some logging code to a Java class.

I ran the web application locally and the logging worked fine.

I then moved pom.xml and log4j2.xml to the Git Staging Area and did a Commit and Push. This normally works fine and there are no problems.

This time I got the following error message in the dialog console window:

[ERROR] Failed to execute goal on project testdb: Could not resolve dependencies for project testdb:testdb:war:1.0: Failure to find org.apache.logging.log4j:log4j-api:jar:2.7 in http://maven.repository.redhat.com/techpreview/all was cached in the local repository, resolution will not be reattempted until the update interval of eap has elapsed or updates are forced -> [Help 1]


It seems to be saying that log4j-api version 2.7 is not available in the RedHat Maven Repository. But I am surely not the first person to do this, so I suspect there is some underlying error.

Any ideas? Any help would be much appreciated...

Answer

Hope this is timely and helpful. I was able to force an update and resolve this issue by deleting the invalid locally cached dependency in ~/.m2/repository/path/to/your/dependency on OpenShift, and then initiating another git push to trigger maven build.