What does "[ERROR] file doesn't exist" means when doing maven install? - java

When I execute maven install in my gitlab build, I get the following error message:
12338 [INFO] Installing com.mycompany:myartifact:1.0.0-SNAPSHOT at end
12338 [INFO] 12338 [INFO] --- maven-bundle-plugin:3.3.0:install
(default-install) # myartifact --- 12411 [ERROR] file doesn't exist:
file:/root/.m2/repository/com/mycompany/myartifact/1.0.0-SNAPSHOT/myartifact-1.0.0-SNAPSHOT.jar
I don't understand what does it mean. The file obviously doesn't exist because it was never installed in that environment, so it's strange that maven would complain about it.
I suppose this error hides some other error, like no write rights? But I see not other error in log. The build seems to be successful.

Try to make a clean install, maybe it's just a local repository issue
mvn clean install

When you do maven install, It usually looks into your .m2 folder and searches for the existence of the dependencies(mentioned in pom.xml). If it doesn't exist, maven will automatically download it. So the build will be successful.

Related

Compilation error/issues while executing maven install

I have a maven project and try to do a maven install.While performing the maven install, Im getting the below error.
[INFO] Compiling 403 source files to D:\\iTT_Backend\itt\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/iTT_Backend/itt/src/main/java/com/iowe/bean/Project.java:[5,27]
package com.cx.util does not exist
[ERROR]
/D:/iTT_Backend/itt/src/main/java/com/itt/controller/ScanController.java:
[21,39] package com.cx.business.to.scan does not exist
Above is the error Im getting while trying to do a clean install.The specified package in the above error message package com.cx.util is available as part of the itt.jar. That jar has been added as a dependency to this project. I dont see any errors in eclipse. Only while trying to do install, Im getting the above compilation error.
Analysis Done
Below are the analysis done
Checked for the dependency and the jar is available as part of dependency in pom.xml file.
The application does not show any dependency error in eclipse. Its able to navigate to the corresponding method in the jar file.The issue occurs while executing mvn install command.
Tried executing mvn install via command prompt. Still getting the same error as above.
Have renamed the .m2 repository folder to old repository and re executed the mvn install command. same issue exists.
Need help in getting the above issue resolved.
Any help on this is much appreciated. Thanks in Advance.
Remove from .m2 local repository and execute command mvn clean install
Try to remove and add again dependency in Pom.xml

Spring MVC tutorial project does not build on IntelliJ

I am trying to build and run a Spring MVC beginner lesson project using IntelliJ. I imported the existing project from GitHub. But when I try to build the project I keep getting:
Error:(3, 38) java: package org.springframework.stereotype does not exist
Error:(4, 47) java: package org.springframework.web.bind.annotation does not exist
These external dependencies jars are under my Maven local repositories (C:\Users\sudi.m2)and I can see in IntelliJ under Maven->Repositories that repo location is indeed there. I also tried "Invalidate Cache and restart" but that does not help. My M2_HOME is set correctly to C:\apache-maven-3.2.2. If I try to run mvn install from command line, I get:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40.845 s
[INFO] Finished at: 2014-09-25T19:03:21+05:30
[INFO] Final Memory: 9M/93M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project basic-web-app: Error assembling WAR: webxml attribute is required (or preexisting WEB-INF/web.xml if executing in update mode) -> [Help 1]
Any suggestions are appreciated.
If the project doesn't have a web.xml file (IE: Entirely java config based). The build war plugin will fail unless you specify the "failOnMissingWebXml" attribute to false.
Delete you local .m2 repository and let it re-download all needed jars. Maybe, there were issues while downloading one of the dependencies.

Maven error: "You don't have a SNAPSHOT project in the reactor projects list."

What on earth does this mean? Cant find any help via google.
> mvn release:prepare
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Base 1.0.5
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.3.2:prepare (default-cli) # base ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.386s
[INFO] Finished at: Tue Oct 08 08:22:46 EST 2013
[INFO] Final Memory: 9M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare (default-cli) on project base: You don't have a SNAPSHOT project in the reactor projects list. -> [Help 1]
release:prepare command is supposed to prepare your snapshot project for the release. It sounds like you don't have such a snapshot project.
Here's the full details what it'll do: http://maven.apache.org/maven-release/maven-release-plugin/examples/prepare-release.html
If you're sure you should be releasing, you should be working on a maven module that has version ending with -SNAPSHOT.
Update: like noted by #khmarbaise in the comments, if your release has failed, you should do release:rollback to go back to previous state. Note though that it is not supported if you release through jenkins (jenkins issue), and it won't rollback the tags.
Don't needed manually edit pom.xml.
You can use "mvn versions:set" for batch update, something like this:
mvn versions:set -DnewVersion=1.0.3-SNAPSHOT
I've had the same error with Jenkins. In a previous release, Jenkins updated the version of the POM to a non-snapshot version, but the build failed before Jenkins could set the version to a -SNAPSHOT version again. Afterwards, making a release resulted in the error described above.
Fixing this is easy: just manually change the version of your app in pom.xml to a -SNAPSHOT version.
I know this is an old question but I had this issue recently and I found 2 solutions that others may find useful. I am using bamboo as my CI tool. The issue was that there was an error in the bamboo build leaving bamboo in an incorrect state. It had locally updated my project pom.xml with the new release version but had not checked this into SVN. The two solution that worked for me were:
Either
Delete the bamboo build-dir directory for the project and run the release again: rm -rf /opt/bamboo-home/xml-data/build-dir/PROJECT_NAME-RELEASE-JOB1
OR
Run the maven release from the command line using the following commands:
mvn release:prepare -DignoreSnapshots -Dresume=false
mvn release:perform
No need to update versions manually as that is time consuming, if version change is all you need, there is a different command that only updates the pom versions, just like updating them manually:
mvn versions:set -DgenerateBackupPoms=false -DnewVersion=1.0.XX-SNAPSHOT

Failed build in Jenkins: cannot resolve sqljdbc4 jar

I have started configuring Jenkins with my project. I made sure to install the sqljdbc driver in my local repository first:
$>mvn install:install-file -Dfile=sqljdbc4-4.0.jar
-DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar
I can see the jar has apparently been installed successfully at:
C:\Users\ me \.m2\repository\com\microsoft\sqlserver\sqljdbc4\4.0
This is what the pom relevant parts looks like:
<sqljdbc4.version>4.0</sqljdbc4.version>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>${sqljdbc4.version}</version>
</dependency>
However when I try to build the project from jenkins I get:
Executing Maven: -B -f C:\Program Files (x86)\Jenkins\jobs\Build Solutions Project\workspace\pom.xml install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building CommonFrontPage 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/com/microsoft/sqlserver/sqljdbc4/4.0/sqljdbc4-4.0.pom
[WARNING] The POM for com.microsoft.sqlserver:sqljdbc4:jar:4.0 is missing, no dependency information available
I'm not sure why it's not looking in my local repository first.
I also set under "configure" > "Maven Project Configuration":
Local Maven Repository Default (~/.m2/repository)
I restarted the Jenkins service too.
I am not sure how to proceed from here.
I know I could use nexus, but I don't really need it at this stage.
Maven version: 3.0.5
I managed to solve it. Since it was building correctly checking out the repository and using maven from the command line, I figured Jenkins was using a different configuration to resolve the repository, so I explicitly added:
C:/Users/me/.m2/repository
into maven's "setting.xml".
Not sure if it's the most elegant solution but at least it works now.

Problems after Maven installation - mvn install tries to download unreachable files

After installing maven (mvn -v works fine), I tried to do mvn install in a directory having a good pom.xml at the root of a Maven project that I know works.
I get the output shown at the bottom which basically states that it tried to download a file from an online maven repository and failed. The file appears to be maven-oriented and I don't think it's related to my project.
In addition, if I run mvn install in a directory without a pom.xml, which should just fail as I understand it, I get the same problems. I'm guessing my Maven just hasn't been fully set up yet and its configuring itself maybe?
Can anyone tell me why it wants these files, and why it might be failing?
I seem to have access to the URL in chrome and the file being targeted is there, so even if it does need it, I'm baffled about why the download is failing.
C:\>mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.3/maven-resources-plugin-2.3.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-resources-plugin:pom:2.3' from repository central (http://repo1.maven.org/maven2): Error transferring file: Connection timed out: conne
ct
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.3/maven-resources-plugin-2.3.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-resources-plugin:pom:2.3' from repository central (http://repo1.maven.org/maven2): Error transferring file: Connection timed out: conne
ct
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.apache.maven.plugins:maven-resources-plugin
Reason: POM 'org.apache.maven.plugins:maven-resources-plugin' not found in repository: Unable to download the artifact from any repository
org.apache.maven.plugins:maven-resources-plugin:pom:2.3
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
for project org.apache.maven.plugins:maven-resources-plugin
Your gateway is blocking maven from downloading the dependencies.
Try and check whether you are able to download this pom file manually.
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.3/maven-resources-plugin-2.3.pom
if you are open the above URL from your browser, then check your firewall settings(Sometimes firewall settings also block maven from downloading the dependencies, especially if you are in an enterprise environment).
if that is the case, you need to use a proxy to bypass your gateway and download the dependencies
OR
Download the plugins manually from maven central or nexus repository and install it using maven install command in your local .m2 directory.
maven install -DartifactId="your dependency" -DgroupId="groupID of the
dependency" -DFile="your file location"
As you mentioned in the comments that you are able to open the site from chrome, you can install the dependency using the above command.
Unable to download the artifact from any repository maven:
Check for proxy :if you have some customized jar file related to your company project ,it needs your firewall and if you are using any proxy in setting.xml file then block it to get it downloaded.

Categories