I have a problem when building a default project created by NetBeans when Maven-Java Web application is created. When I add Spring MVC dependency under Properties->Framework category and build a project I get this error:
Failure to find org.springframework:spring-framework-bom:jar:4.0.1.RELEASE in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
You have a placeholder in your local repo, try to delete this placeholder
delete the folder
~/.m2/repository/org/springframework/spring-framework-bom/4.0.1.RELEASE
Then rebuild with
mvn clean install -U
This assume your maven instillation is correct.
Did you add this dependency?
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.0.1.RELEASE</version>
<type>pom</type>
</dependency>
and throws you that error? Could be a missed library.
Before adding it manually (or any other solution), make sure u really need the spring bom in your dependencies...
The bom should go under dependencyManagement section in your parent pom xml.
BTW the bom is only available as "POM" , not as "jar" scope.
Related
I am new to Maven Project. I am making changes to one of the open source maven project. I am facing a problem in adding a library to the project. So far i have done this :-
I added a library named jni4net.j-0.8.8.0.jar to the resources folder of the project.
I right clicked the jar(in Intellij) and clicked 'Add as library'.
Then in the pom.xml i added:-
<dependency>
<groupId>jar.0.8.8.0.jni4net</groupId>
<artifactId>jar.0.8.8.0.jni4net</artifactId>
<version>0.8.8.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/resources/jni4net.j-
0.8.8.0.jar</systemPath>
</dependency>
But when i build this project(build is successful, test cases are running) and use this it throws following error:-
java.lang.NoClassDefFoundError: net/sf/jni4net/Bridge
Please help me resolve it. I am new to maven and pom. I have looked at various answers, but not getting it right.
PS - I named groupId and artifactID as just reverse of jar file
This is not the right way to add that dependency.
All you need is:
<dependency>
<groupId>net.sf.jni4net</groupId>
<artifactId>jni4net.j</artifactId>
<version>0.8.8.0</version>
</dependency>
The dependency will be retrieved from Maven Central when you build.
Using <systemPath>...</systemPath> is highly discouraged as it usually ties your project to a local environment.
Since jni4net.j dependency is available in maven central, You don't have to download and put the dependency manually. Maven will download and store the dependency locally in `'.m2' folder. Just add dependency as bellow.
<dependency>
<groupId>net.sf.jni4net</groupId>
<artifactId>jni4net.j</artifactId>
<version>0.8.8.0</version>
</dependency>
I am trying to revive my old project. I want to use maven for it and I want to add AbsoluteLayout dependency. I am kinda new in maven so I have no idea what is wrong. I have found that this should work:
<dependency>
<groupId>org.netbeans.external</groupId>
<artifactId>AbsoluteLayout</artifactId>
<version>RELEASE802</version>
</dependency>
but I only get this error:
Failed to execute goal on project XXX: Could not resolve dependencies for project xx.xxxx:XXX:jar:1.0-SNAPSHOT: Failure to find org.netbeans.external:AbsoluteLayout:jar:RELEASE802 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
After this I manually added this dependency from my netbeans folder in my computer. And it is working. Is there another way how to add this dependency? I would like to include it in my pom file. Any ideas?
You need to add a Netbeans repository to your POM:
<repositories>
<repository>
<id>netbeans</id>
<name>Netbeans rep</name>
<url>http://bits.netbeans.org/maven2/</url>
</repository>
</repositories>
I added the below dependency block to my POM and after updating my maven indices it worked just fine.
<!-- https://mvnrepository.com/artifact/org.netbeans.external/AbsoluteLayout -->
<dependency>
<groupId>org.netbeans.external</groupId>
<artifactId>AbsoluteLayout</artifactId>
<version>RELEASE802</version>
</dependency>
So you might want to try updating your maven indices and see if that does it for you. This dependency block came directly from mvnrepository.com/, and worked without me needing to add any special repo as far as I'm aware.
Look like that dependency is not exists in the public repository, you can register an account and upload it, or, from my view point is better, you can setup your own private maven repository server, there many software support to do this, for example JFrog Artifactory, it is easy to install and manipulate.
I couldn't find the spring-ldap jar in central maven starting from version 1.3.2.
We use maven to manage dependency and we pull the spring jars from central maven (in turn using an internal repository)because this jar is not available in central maven we are not able to pull it. Please advice why this jar is missing in Maven central and what alternate options are available?
Even in spring repo(https://repo.spring.io/release) the artifact are provided as a zip file and the jar isn't provided directly.
Looking for the below artifact
Group ID: org.springframework.ldap
Artifact ID: spring-ldap
version: 2.0.2
The best option, as for me, is to use needed submodules of spring-ldap, for instance spring-ldap-core:
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId>
<version>2.0.4.RELEASE</version>
</dependency>
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...
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.
I have the SAME PROBLEM with RedHat Maven Repository on my current project.
To esclude all possible problem due to code of my current project, I created a new project and applied to it a little update on index.html file (I simply added a space character).
Then, after a "git push" command, I obtained the same error on remote build phase, but this time with the download of basic plugin maven-clean-plugin :
remote: [ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1
or one of its dependencies could not be resolved: Failed to read artifact
descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1:
Failure to find org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1 in
http://mirror.ops.rhcloud.com/nexus/content/groups/public was cached in the
local repository, resolution will not be reattempted until the update
interval of nexus has elapsed or updates are forced -> [Help 1]
It's clear that OPENSHIFT platform had some problem since today.
Yesterday, I tried this and it worked for me:
Create an empty file called force_clean_build inside application .openshift/markers directory. Commit the file and push the changes. This will remove the .m2 repository and download all the dependencies and plugins again.
I am working on a Java project, using maven as our dependency manager/build tool. I am currently having a problem resolving a dependency's dependency to the correct version.
The dependency in question is called jasperreports-functions-6.1.0.jar which is not hosted in a maven repo but provided in jar form.
The problem I'm having is that jasperreports-functions needs commons-lang 2.6. Inconveniently, during "compile" Maven itself builds commons-lang 2.1 to create the reduced-pom. It seems this leads to jasperreports-functions trying to use commons-lang 2.1 because it is available, but this is not valid (method undefined errors at runtime.)
I have tried adding commons-lang 2.6 as a dependency but still it seems jasperreports-functions is using the 2.1 version.
pom.xml snip:
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.1.0</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-functions</artifactId>
<version>6.1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/jasperreports-functions-6.1.0.jar</systemPath>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
Using "mvn dependency:tree" I can see that no dependency requires commons-lang.
If I delete 2.1 from ".m2\repository\commons-lang\commons-lang" it gets recreated by maven. If I empty the folder and lock the permissions on it, then run maven again I get the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.4:jar (default-jar) on project JavaLibrary: Execution default-jar of goal org.apache.maven.plugins:maven-jar-plugin:2.4:jar failed: Plugin org.apache.maven.plugins:maven-jar-plugin:2.4 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-jar-plugin:jar:2.4 -> commons-lang:commons-lang:jar:2.1: Failed to read artifact descriptor for commons-lang:commons-lang:jar:2.1: Could not transfer artifact commons-lang:commons-lang:pom:2.1 from/to central (https://repo.maven.apache.org/maven2): C:\Users\Lowell\.m2\repository\commons-lang\commons-lang\2.1\commons-lang-2.1.pom.part.lock (Access is denied) -> [Help 1]
How can I force the jar dependency to use a certain version of a sub-dependency?
Have you tried to reorder the depency entries,
first to load commons-lang then to load jasperreports ?
Edit:
Maybe this should help you: dependency:analyze-dep-mgt
What you are doing should be enough. The newer version should override the older version AND the version you specify explicitly should override any transient dependency. I believe Maven 2.x had problems in this area which is why I updated to Maven 3.x
I suspect the problem is somewhere else. I suggest trying to delete common-lang 2.1 and I suspect this should show you what the real problem is.
Try this:
1> Maven clean.
2> Right click on project->maven -> update project configuration - > force update