POM for 'log4j:log4j:pom:1.2.15:compile' is invalid - maven

Can please anyone tell me what I am doing wrong here ?
I am getting the following warnings when I run mvn install:
[WARNING] POM for 'log4j:log4j:pom:1.2.15:compile' is invalid. It will be ignored for artifact resolution. Reason: Cannot read project model from interpolating filter of serialized version. for project log4j:log4j at Artifact [log4j:log4j:pom:1.2.15:compile]
[WARNING] POM for 'log4j:log4j:pom:1.2.15:compile' is invalid. It will be ignored for artifact resolution. Reason: Cannot read project model from interpolating filter of serialized version. for project log4j:log4j at Artifact [log4j:log4j:pom:1.2.15:compile]
Pom file has:
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<exclusions>
<exclusion>
<artifactId>mail</artifactId>
<groupId>javax.mail</groupId>
</exclusion>
<exclusion>
<artifactId>jms</artifactId>
<groupId>javax.jms</groupId>
</exclusion>
<exclusion>
<artifactId>jmxri</artifactId>
<groupId>com.sun.jmx</groupId>
</exclusion>
<exclusion>
<artifactId>jmxtools</artifactId>
<groupId>com.sun.jdmk</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>

There's nothing wrong with your dependency declaration. Therefore, I would guess something went wrong during the download of the POM.
Delete the relevant folder in your local repository (e.g. .m2/repository/log4j/log4j/1.2.15) and try again.

Related

project build error: 'dependencies.dependencies.version' for org.springframework.cloud:spring-cloud-starter-eureka-server:jar is missing

I'm using Springboot version 2.6.5. I'm getting below error when i add below dependencies. I'm using java version 1.8 and spring-cloud-version Greenwich.SR2
project build error: 'dependencies.dependencies.version' for org.springframework.cloud:spring-cloud-starter-eureka-server:jar is missing
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</exclusions>
<exclusion>
<groupId>com.sun.jersy</groupId>
<artifactId>jercy-client</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersy</groupId>
<artifactId>jercy-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersy</groupId>
<artifactId>jercy-apache-client4</artifactId>
</exclusion>
</exclusions>
</dependency>

Why isn't maven including a needed transitive dependency?

I am converting our Jenkins Freestyle build to Declarative Pipeline mode. I am using the same POM files.
But whenever i run the pipeline build, i see that the desired war is missing a transitive dependency. The Freestyle build includes that missing dependency however.
The Main parent POM includes:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>5.5.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
The second parent includes section below, :
<dependencies>
<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
</dependency>
</dependencies>
For both build processes, the dozer artifact is contained in the war file. But dozer contains a dependency of its own:
<dependencies>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.1</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
It is this commons-beanutils that I am missing from my final war when i do the Pipeline build. Since I am using the same POM files for both build processes, how can this be possible?
Please help

Multiple spring dependencies of different versions

I am working with spring-boot and want to include two different versions of spring-web in my project since one of the APIs in the latest version has been deprecated. In order to continue using that, I have included two dependencies of spring-web with different versions but eclipse is recognizing only of them.
I have tried excluding almost everything from the older version of spring-web but that doesn't seems to work either- any way out please?
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.2.RELEASE</version>
<exclusions>
<exclusion>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
</exclusion>
<exclusion>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
</exclusion>
<exclusion>
<groupId>com.caucho</groupId>
<artifactId>com.springsource.com.caucho</artifactId>
</exclusion>
<exclusion>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</exclusion>
<exclusion>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml</groupId>
<artifactId>jaxrpc-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
</exclusion>
<exclusion>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
You won't be able to have two different versions of a dependency in your project because of a Maven concept called 'Dependency Mediation'. Have a look at the Maven Introduction to the Dependency Mechanism documentation.
Dependency mediation - this determines what version of a dependency
will be used when multiple versions of an artifact are encountered.
Currently, Maven 2.0 only supports using the "nearest definition"
which means that it will use the version of the closest dependency to
your project in the tree of dependencies. You can always guarantee a
version by declaring it explicitly in your project's POM. Note that if
two dependency versions are at the same depth in the dependency tree,
until Maven 2.0.8 it was not defined which one would win, but since
Maven 2.0.9 it's the order in the declaration that counts: the first
declaration wins.

owl api - pellet used in osgi

I am trying to use OWL api and Pellet in an OSGI bundle. The bundle builds successfully but on runtime I am getting the following error: org.osgi.framework.BundleException: Unresolved constraint in bundle smp.lighting.client.osgi [2]: package; (package=org.mindswap.pellet).
These are the dependencies as they are declared in the pom file:
<dependency>
<groupId>edu.stanford.protege</groupId>
<artifactId>org.semanticweb.owl.owlapi</artifactId>
<version>3.4.4</version>
<exclusions>
<exclusion>
<artifactId>org.osgi.core</artifactId>
<groupId>org.apache.felix</groupId>
</exclusion>
<exclusion>
<artifactId>owlapi-apibinding</artifactId>
<groupId>net.sourceforge.owlapi</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.ansell.pellet</groupId>
<artifactId>pellet-owlapiv3</artifactId>
<version>2.3.3</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>log4j</groupId>
</exclusion>
<exclusion>
<artifactId>xercesImpl</artifactId>
<groupId>xerces</groupId>
</exclusion>
</exclusions>
</dependency>
Also, in the launch file of the bundle, I call:
mvn:edu.stanford.protege/org.semanticweb.owl.owlapi/3.4.4
and in the next level:
wrap:mvn:com.github.ansell.pellet/pellet-jena/2.3.3
wrap:mvn:com.github.ansell.pellet/pellet-owlapiv3/2.3.3
I do not know if I a missing something, any help is appreciated. Thank you in advance!
pellet-owlapiv3 is an adapter between Pellet and the OWL API, so it does not, itself, contain the core Pellet classes. From the error, I believe you need to wrap pellet-core as well, and possibly some others of the Pellet modules.

excluding log4j from third party jar in pom

I am creating a webservice which hits existing business code.
The required jar which deals with logging is org.ops4j.pax.logging.
I have include this in the pom
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-api</artifactId>
<version>1.6.0</version>
</dependency>
This jar allows access to a particular log4j method which is used throughout the business layer
LOGGER.debug(object, object);
One of the other required jars is a third party jar.
This jar contains a different version of log4j which does not implement the debug(object, object) method.
When I add this jar to the pom, the JVM finds the log4j classes in this third party jar first and the code falls over.
I have tried to exclude the log4j in the third party jar but to no avail.
<dependency>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
Any thoughts?
This is the correct answer from https://www.baeldung.com/slf4j-classpath-multiple-bindings
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
Sometimes log4j-core also shows up even after excluding log4j.Below configurations worked for me.
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</exclusion>
</exclusions>

Resources