Maven, lost local dependency | Could not resolve dependencies for project - java

Hi guys I have a Maven project working well since 9 months.
But today I get a error in Maven build
[ERROR] Failed to execute goal on project bon: Could not resolve dependencies for project com.mydev:bon:war:1.0.20.1: Failure to find com.mydev:utils:jar:1.0.0-BUILD-SNAPSHOT in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of maven2 has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
The project is a Dynamic Web Project with maven
In pom I have a dependency to local jar
<dependency>
<groupId>com.mydev</groupId>
<artifactId>utils</artifactId>
<version>1.0.0-BUILD-SNAPSHOT</version>
</dependency>
The project com.mydev.utils has installed in my PC in .m2 folder, I check the folder D:\.m2\repository\com\mydev\utils\1.0.0-BUILD-SNAPSHOT\ and everything seems in order
_rzi_0.118
_rzi_0.227
_maven.repositories
utils-1.0.0-BUILD-SNAPSHOT.jar
utils-1.0.0-BUILD-SNAPSHOT.jar.lastUpdate
utils-1.0.0-BUILD-SNAPSHOT.pom
utils-1.0.0-BUILD-SNAPSHOT.pom.lastUpdate
m2e.lastUpdate.properties
maven-metadata-local.xml
resolver-status.properties
I do not think the problem is the pom, I have not changed anything
I tried to build another project with the same unit, and get the same error.
I install software yesterday (DB2 Express-C database server), not if maven may have lost some settings for it. wheninstall the software, do not restart
Today try to generate the war, but I get the error, I reboot the PC, but I have the same error
Edit:

One more thing you do not need to do copy and paste thing , you can just easily modify your maven setting.xml for maven repo and in eclipse point it to correct file. In above scree shot user setting path should be you maven installation dir like <your dir>\apache-maven-xxx\conf\settings.xml
settings.xml
<localRepository>D:\.m2</localRepository>

Related

What is the difference between running a java springboot project in an IDE and using maven clean package?

I am new to Java Springboot and I have been tinkering with it for a while now (implement caching ).
I am trying to recreate the **
samples/coherence-spring-demo/coherence-spring-demo-boot project
** in the following Github repo https://github.com/coherence-community/coherence-spring following the instructions in https://spring.coherence.community/3.1.0/refdocs/reference/htmlsingle/index.html#coherence-spring-documentation
I have been working on VS Code with the STS extension and when I click on run, the application runs fine. But when I build it using
mvnw clean package
I get the following error.
[ERROR] Failed to execute goal on project coherence-spring-demo-boot:
Could not resolve dependencies for project
com.oracle.coherence.spring:coherence-spring-demo-boot:jar:3.3.0-SNAPSHOT:
com.oracle.coherence.spring:coherence-spring-demo-core:jar:3.3.0-SNAPSHOT
was not found in
https://oss.sonatype.org/content/repositories/snapshots during a
previous attempt. This failure was cached in the local repository and
resolution is not reattempted until the update interval of
snapshots-repo has elapsed or updates are forced -> [Help 1] [ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with
the -e switch. [ERROR] Re-run Maven using the -X switch to enable full
debug logging. [ERROR] [ERROR] For more information about the errors
and possible solutions, please read the following articles: [ERROR]
[Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
I have checked the pom.xml file and the dependency has been added and also checked the nexus repository to find the same package.
If it could resolve the dependency while running the application while running, why could it not have found the dependency while trying to build it?
Also can you tell me what the difference between Run as spring-boot app and building the package is in springboot? and
Run as Spring-boot app -> Startup Embedded Tomcat server (or ThymeLeaf or Jetty) along with your spring boot application (Starts up IOC container, initializes beans , dependencies etc internally )
mvn clean package ->
mvn -> Maven command
clean -> Maven goal, which cleans (removes) classes, resources and artifacts available as part of Target folder
package -> Maven phase, which packages your application (In JAR or WAR whichever specified in POM) and puts the artifact in your local repository
Maven is a build tool i.e. It provides a basic structure of how your project should look like or be organized. For example, which file stays where, place for your external resources, dependencies etc
While, Spring-boot is a module of Spring framework which can be simply run as Java application
Read more on mvn here
https://www.journaldev.com/33659/maven-build-lifecycle-phases-goals#:~:text=Maven%20goals%20represent%20a%20specific,goals%20through%20the%20command%20line.&text=Here%20is%20an%20example%20to,goal%20from%20the%20command%20line.
Spring boot features and technicals here
https://spring.io/projects/spring-boot

spring project (from the spring initialzr plug in on the IDE) being Unloadable

When i create an spring project (from the spring initialzr plug in on the IDE) on netbeans 8.2 it ends up being Unloadable. How can i fix that problem?
This is the error i find:
Scanning for projects...
Downloading: http://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.4.3/spring-boot-starter-parent-2.4.3.pom
The build could not read 1 project -> [Help 1]
The project com.nexus:RegistroEmpleados:0.0.1-SNAPSHOT (C:\Users\RobotDyn\Documents\NetBeansProjects\InitializrSpringbootProject\pom.xml) has 1 error
Non-resolvable parent POM: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.4.3 from/to central (http://repo.maven.apache.org/maven2): Failed to transfer file: http://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.4.3/spring-boot-starter-parent-2.4.3.pom. Return code is: 501 , ReasonPhrase:HTTPS Required. and 'parent.relativePath' points at no local POM # line 5, column 10 -> [Help 2]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
This is my parent code:
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.4.3
Maven dependencies are failing with a 501 error
Easiest way is to update Maven to version >= 3.2.3.
Update the Maven version repository:
Download the Apache Maven binary that includes the default https addresses (Apache Maven 3.6.3 binary). And open the Options dialog window in tools of NetBeans menu bar (Java Maven Dialog View). And select browse option in Maven Home List Box (Maven Home List Box View). After adding the Apache Maven newly downloaded version (Updated Maven Home List Box View), the project builds and runs successfully.

Not able to deploy artifacts to Nexus repository from Jenkins

I am trying to push my artifacts to Nexus from Jenkins. I am getting the following error while I deploy to Nexus from Jenkins:
Error message in Jenkins Console Output:
15:59:06 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project sbx-java-webapp: Failed to deploy artifacts/metadata: Cannot access with type default using the available connector factories: BasicRepositoryConnectorFactory: Cannot access using the registered transporter factories: WagonTransporterFactory: java.util.NoSuchElementException
15:59:06 [ERROR] role: org.apache.maven.wagon.Wagon
15:59:06 [ERROR] roleHint: "http
15:59:06 [ERROR] -> [Help 1]
15:59:06 [ERROR]
15:59:06 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
15:59:06 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
15:59:06 [ERROR]
15:59:06 [ERROR] For more information about the errors and possible solutions, please read the following articles:
15:59:06 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
I have tried several methods to make this work. But when I use maven deploy goal in my windows machine, it is deploying my artifacts to the same Nexus Repository without any failure. However from Jenkins, I am getting this error. In both environment the pom.xml and settings.xml that I use are same. I have tried with different maven versions as well in jenkins to solve this issue, but no help.
I have already tried mentioning wagonProvider in CLI as well as settings.xml and also I tried using extensions for wagonProviders in build and I even used extensions.xml and include this in descriptor in maven version 3.0.5 where WagonTransporterFactory is available, but none of them help me out. I also tried reinstalling and reconfiguring Jenkins, but that also doesn't help me.
If we can solve this issue, it will be great help. Thanks.
Oh....I got the issue resolved. Another example that teaches me a small error can result in bigger issue.
The issue occurred as I was passing my Nexus Repository URL as system variable in jenkins for maven deploy command as follows:
nexus_rel_repo="${NEXUS_REPO_URL}"
where NEXUS_REPO_URL was already a String Parameter that I assigned in Jenkins. And nexus_rel_repo is my system variable and you can see here that I was using double quotes when I was assigning my Nexus Repository URL which is already a String Parameter to nexus_rel_repo. The occurrence of these extra double quotes disturbed the connection.
Thanks for everyone who has looked into this issue and who has already done some research on it.

Maven time out on Central Repository - No Proxy setting - Windows

Maven throws time out when try to clean the project
USER>mvn clean
After this command the build throw:
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dep
endencies could not be resolved: Failed to read artifact descriptor for org.apac
he.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apa
che.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven
.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org
/23.235.46.215] failed: Connection timed out: connect -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResoluti
onException
Do you have any other repositories configured in your ${HOME}/.m2/settings.xml (or pom.xml)? If so, make sure that none of them have the id of central or you may have reconfigured the location of maven-central.
Also, if you use a locally hosted "proxy" maven repository, do not reconfigure central to point to the locally hosted maven repository, instead use a "mirror" directive, configuring the repository to be something with an id like "localrepo" and specifying it as a "mirrorOf" central.
Finally, avoid any "proxy" settings unless you want all of your searches to start searching for repositories outside of your network (aka on the internet).
Maven manages dependencies in a very specific manner, which provides repeat-ability of builds. Basically it needs to be encoded in the pom.xml. Yes, you can do some magic to pass such things through using the command line, but if you do that, you are working against the design of maven (and robbing yourself of most of it's utility at the same time).
If you need something to "update" a build, consider making a script that updates and checks in the pom.xml for the artifact, or (less ideal) base the dependency on a snapshot version.

Does the Spring-Flex 1.5 Sample work?

The samples and documentation in question can be found here: http://static.springsource.org/spring-flex/docs/1.5.0.M1/
The reference doc ( here ) tells us to download the sample application:
Included in the project distribution
is a collection of samples called the
Spring BlazeDS Integration Test Drive.
This samples project is set up to be
built with Maven and then imported
into Eclipse for running the
application via WTP.
The samples in question, must either be spring-flex-testdrive-spring3.zip which is linked to in the document or spring-flex-testdrive-spring3.zip based on the notion that this is release 1.5.0.M1 (docs and samples).
After I configure maven as described with the proper environment variable:
MAVEN_OPTS="-Xms256m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m"
I then execute (per instruction) the command to install: mvn clean install from the extracted samples directory (in my case C:\spring-flex-testdrive ), I receive the following error:
C:\spring-flex-testdrive>mvn clean install
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project org.springframework.flex.samples:spring-flex-testdrive:1.5.0.M1 (C:\spring-flex-testdrive\pom.xml) has 1 error
[ERROR] Non-resolvable parent POM: Failure to find org.springframework.flex:spring-flex-parent:pom:1.5.0.M1 in http://maven.springframework.org/external was cached in the local repository, resolution will not be
reattempted until the update interval of spring-external has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM # line 5, column 10 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
C:\spring-flex-testdrive>
I have managed to get a "Spring BlazeDS" application working (with Flex), but now I'm at the point where I need to implement security, and if the samples would compile and run correctly, it'd be a huge help. I am new to Maven, but any help would be greatly appreciated!
Thanks in advance StackOverflow community!
Brian, please add the following snippet to the pom.xml in the root of the samples (from where you execute mvn clean install) and re-run Maven:
<repository>
<id>spring-milestone</id>
<name>Spring Milestone Repository</name>
<url>http://maven.springframework.org.s3.amazonaws.com/milestone</url>
</repository>
Hope that helps.
Christian
I get the same error. Spring Flex 1.5M2 will be out very soon. So maybe give it another try with that.
I would recommend that if go with Parsley for Actionscript/Flex framework. It is more mature in may ways than Spring-Actionscript. Moreover it is a required library for much of Cairngorm 3. Good luck.

Categories