I have a problem deploying my springboot application to Heroku. After running git push heroku master, I am encountering the error below:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.350 s
[INFO] Finished at: 2020-12-22T06:33:14Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project audit: Fatal error compiling: invalid target release: 11 -> [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/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :audit
remote: ! Push rejected, failed to compile Java app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 31199a7acec03a3cb614ebaaf6c7720cee6684bd
remote: !
remote: ! We have detected that you have triggered a build from source code with version 31199a7acec03a3cb614ebaaf6c7720cee6684bd
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to tesda8app.
I am clueless into why this error occurred. I have two remote repositories on which I push my code, one from Heroku and one in Github. I have tried the command below based from the answer from this question, Heroku: If you are developing on a branch and deploying via git you must run:
git push heroku master:main
But still the error persists. Is there any command that I could try on the Heroku CLI to solve this problem?
After some few tries, I was thinking that the cause of the problem was maybe an interrupted git push heroku master command, which was then proceeded by a re-execution of the same command, causing the error below:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 31199a7acec03a3cb614ebaaf6c7720cee6684bd
remote: !
remote: ! We have detected that you have triggered a build from source code with version 31199a7acec03a3cb614ebaaf6c7720cee6684bd
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
So what I did was, I pushed another commit, then retried the same command git push heroku master, which resulted to a successful deployment.
Also, shoutout to RainXCat's answer and insights, now I know Heroku does not allow two git repositories on the same directory/folder.
I was having the same error on the same day as you, I don't know if it's the answer you are looking for but I somehow solved the issue. I was making a Django-Rest-Api.
REASON
you have created two git repositories in the same folder/directory and pushed the same code into their head and somehow Heroku doesn't want you to do that.
remember no two git repo on the same level.
about the git push heroku master:main thing
Heroku only deploy your code from the main/master branch
so if you are pushing from other than master, you have to use it like git push heroku <new branch>:main, using :main with master is meaningless(same).
SOLUTION
option 1 (not working for me)
I don't remember exactly where I get this but you have to make a new git branch,
do
git branch <new branch>
git checkout <new branch>
git add .
git commit -am "commit message"
git push heroku <new branch>:main
but it's giving the same error because you still have two git repo in your directory.
you can remove the repo like this.
rm -rf .git
I suggest you to do the experiment on a temporary copy.
option 2 (working for me)
All I did was copy all the files inside, made a new folder with a different name, pasted all files, deleted the old, and rename the new to the old one. by doing this you will have a git free directory then you can use the git init method to simply make a new repo.
here is how you should create
git init
heroku create
git add .
git commit -am "initial commit"
git push heroku master
This should resolve the error, It's solved for me so it's unlikely that I am going to work on it anymore but if my answer is not right in any manner please do tell me.
this worked for me!
git branch <new branch>
git checkout <new branch>
git add .
git commit -am "commit message"
git push heroku <new branch>:main
git push --set-upstream heroku <new branch>
this worked for me.
I deleted my package-lock.json file and do the following again
git init
git add .
git commit -m ""
git push heroku main
the purpose is to clear your build cache
I just made an empty commit and push again.
It worked for me.
git commit --allow-empty -m 'empty commit for pushing staging environment'
git push staging master
Install the Heroku CLI
Download and install the Heroku CLI.
If you haven't already, log in to your Heroku account and follow the prompts to create a new SSH public key.
$ heroku login
Clone the repository
Use Git to clone projects' source code to your local machine.
$ heroku git:clone -a project
$ cd project
Deploy your changes
Make some changes to the code you just cloned and deploy them to Heroku using Git.
$ git add .
$ git commit -am "make it better"
$ git push heroku master
I'm following Spring Boot Docker Tutorial from here.
I got the exact result while having an internet connection. Now I need to produce the same result in an environment without an internet connection. I copied maven repositories and docker image into the new environment. I'm quite sure maven and docker is up and running.
When I tried to run following command com.google.cloud.tools:jib-maven-plugin:dockerBuild -Dimage=eureka I'm getting error messages. I guess there are some files plugin cannot locate but not sure which ones.
I'm adding the error message
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------------< com.ays:eureka >---------------------------
[INFO] Building eureka 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- jib-maven-plugin:2.1.0:dockerBuild (default-cli) # eureka ---
[INFO]
[INFO] Containerizing application to Docker daemon as eureka...
[WARNING] Base image 'gcr.io/distroless/java:8' does not use a specific image digest - build may not be reproducible
[ERROR] I/O error for image [gcr.io/distroless/java]:
[ERROR] org.apache.http.conn.ConnectTimeoutException
[ERROR] Connect to gcr.io:443 [gcr.io/64.233.184.82] failed: connect timed out
[INFO] Executing tasks:
[INFO] [============ ] 40,0% complete
[INFO] > building image to Docker daemon
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.409 s
[INFO] Finished at: 2020-04-13T16:37:23+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:2.1.0:dockerBuild (default-cli) on project eureka: Connect to gcr.io:443 [gcr.io/64.233.184.82] failed: connect timed out -> [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/MojoExecutionException
Can somebody point me where should I look or is there anything I'm missing at this point?
Here is my DockerFile
FROM openjdk:8-jdk-alpine
RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring
ARG DEPENDENCY=target/dependency
COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY ${DEPENDENCY}/META-INF /app/META-INF
COPY ${DEPENDENCY}/BOOT-INF/classes /app
ENTRYPOINT ["java","-cp","app:app/lib/*","hello.Application"]`
I didn't change anything in DockerFile.
If you do not specify a base image, Jib 3.0+ by default uses adoptopenjdk:8-jre as a base image for Java 8 apps. (Prior to 3.0, Jib used gcr.io/distroless/java:8 as the default.)
When you are not using a specific image digest (such as gcr.io/distroless/java#sha256:...) but instead use a tag (:8 in your case with Jib < 3.0) for a base image, the tag can point to different images over time. That is, if you build an image sometime later on a different machine, Jib may pick up a slightly different base image than you used before. Hence the following warning:
[WARNING] Base image 'gcr.io/distroless/java:8' does not use a specific image digest - build may not be reproducible
For this reason, when you are not using a digest, Jib reaches out to the registry (gcr.io) and checks if the locally cached image (not in the local Docker engine cache but Jib's own cache) is up to date. If not, Jib will download the updated image. This is why you are getting the error when you're offline.
You have two options.
Pass --offline to Maven on the command-line. Then, Jib will use the cached base image; there will be no online connection. Of course, for this to work, Jib should have cached the base image before; you need to run Jib at least once online beforehand.
Use a digest to pin down a specific base image. For example, in your pom.xml,
<configuration>
<from><image>adoptopenjdk#sha256:9cb8bc7356ec2d9de56f3be3d8204a846ca0a3220af059aa67c35d53c7138e17</image></from>
</configuration>
If you prefer, you can specify both tag and digest. However, the tag will have no effect and only serve as a comment in this case.
<from><image>adoptopenjdk:8-jre#sha256:9cb8bc7356ec2d9de56f3be3d8204a846ca0a3220af059aa67c35d53c7138e17</image></from>
To find out what digest to use, check the adoptopenjdk Docker Hub repository. Another way is to run Jib once online. After the warning, you will see a message reporting the current digest for the tag.
[WARNING] Base image 'adoptopenjdk:8-jre' does not use a specific image digest - build may not be reproducible
[INFO] Using base image with digest: sha256:9cb8bc7356ec2d9de56f3be3d8204a846ca0a3220af059aa67c35d53c7138e17
Another option when you're running a local Docker daemon is to make Jib use an image from the daemon by prefixing docker:// to the base image (for example, <image>docker://openjdk:11-jre-slim</image>). However, depending on circumstances, this can be a little be slower than using a remote base image (but probably not so much even in that case).
Lastly, you can delete your Dockerfile. Jib does not use Dockerfile, Docker CLI, or Docker daemon.
I use STS(spring tool suite) + maven plugin.
Every time when I run my application using maven-clean I see following error:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hhsystem ui 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # ui ---
[INFO] Deleting C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.471s
[INFO] Finished at: Mon Oct 21 12:34:33 MSK 2013
[INFO] Final Memory: 2M/90M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean (default-clean) on project ui: Failed to clean project: Failed to delete C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\target\org.ow2.util.asm-asm-tree-3.1.jar -> [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/MojoExecutionException
I have to close STS and go to C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\target and delete org.ow2.util.asm-asm-tree-3.1.jar
After starting STS again it works, but this is a hassle.
Can you help me with this problem?
UPDATE
for Kalathoki L.
I run maven-clean from this state:
I see same behaviour from the command line as from the eclipse plugin
If I watch unlocker when STS is running I see
:
Stop your server before you start to clean.
Stopping a server
You can stop the server from the Servers view.
To stop the server:
In the Servers view ( Window > Show View > Other > Server >
Servers > OK), select the server that you want to stop.
Click the Stop the server icon
in the toolbar. In the Servers view, the status of the server
changes to Stopped.
If for some reason the server fails to stop, you can terminate the
process as follows:
a. Switch to the Debug perspective.
b. In the Process view, select the server process that you want to stop.
c. Click the Terminate
icon in the toolbar.
Note: When terminating a server, the server process will end and the server will not go through the normal routine of stopping, for example calling the destroy() method on a servlet.
Source: Eclipse Help
You may also try try -Dmaven.clean.failOnError=false
(from Maven FAQ)
Delete the java.exe process in Task Manager and run mvn clean install.It worked for me.
Your problem is that a running process within STS is using files located in your target directory while you execute a mvn clean command. Maven will be unable to delete these files (since other processes are still accessing them) and thus fail with that error.
Try to stop all processes (tests, servers, applications) from within STS before running Maven console commands. Look out: This behaviour might also appear if STS is cleaning up the projects and thus re-compiles the sources, and not running a process.
Close the target folder and its file you have opened before mvn clean
Probably there are many processes that use sources compiled, could be a server, an old maven instruction or IDE. Sure terminate all processes, stop the server and then execute maven again. If the problem persists, you should close java.exe process.
Regards!
Try disabling Project->Build Automatically.
As Scorpio suggested, there's a process running that's got a lock on a file somewhere.
I have a large multi-module maven project that regularly fails on clean and this resolves it for me.
I re-enable Build Automatically when I'm done.
I have same problem and this
mvn clean install -U
command fixed the error.
Summary : Use an external script (batch file) that a) stops the server and b) Unlocks the .jar file before running maven-clean.
Steps:
Bind the maven-antrun-plugin:run goal to the pre-clean phase of mvn clean. See how to do this here
See how to use the antrun plugin to run an external batch file in Windows here : sblundy's answer to "Starting external process". Let's call this file unlock_handles.bat
Use the Sysinternals handle utility download link in the pre_clean.bat to a) stop the Tomcat server and b) unlock the .jar file. handle -c and handle -p would be useful here.
Whew! That's a bit of work, but it will reliably automate the process for you so that you do need to do it manually yourself each time!
OK, here's a rough, proof-of-concept version of unlock_handles.bat for you to try out:
REM "Use handle.exe to figure out the process id and handle ids, parse the output, then close the handle (again using handle.exe)"
cd "C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\target"
"c:/Program Files/Process Explorer/handle.exe" -p java.exe "C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\target" > handles.txt
#echo "O====== Going to unlock all the below file handles! =======O"
FOR /F "tokens=1-26 delims=: " %a in (handles.txt) DO #echo %h
FOR /F "tokens=1-26 delims=: " %a in (handles.txt) DO handle -p %c -c %f -y
Of course, you have to change the path to Sysinternals' handle.exe before giving this a try.
If all steps (in existing answers) dont work , Just close eclipse and again open eclipse .
For linux users: possible solution.
Build error due to "Failed to delete < any-file-or-folder >" will occur if there is by chance of only delete access provided to root user rather to normal-user.
Fix : type ll command to list file that cannot be deleted, if the file is given root access, change to normal user by :
sudo chown -R user-name:user-name filename
Later try for maven clean and build.
solved by deleting the target folder manually.
I had similar issue. Earlier I was using Maven 3 to build the project. After switching to maven 2 , I had the above error.
Solved it by switching to Maven 3.
Maven complains if you do not have admin permissions on the target folder.Check if you have admin right to delete that folder.
I solved mine by doing:
mvn clean
mvn install
mvn clean install
For some reasons it worked for me . Good luck !!
If you lock org.ow2.util.asm-asm-tree-3.1.jar and start eclipse, the logging shows who was unable to lock the file. The same codeline who cant lock the file will not release the lock.
In pre-clean phase I execute with Maven Unlocker program. This program unlock all files and directory for anyone program.
I execute this with maven-antrun-plugin and only in windows systems
<profile>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>pre-clean</phase>
<configuration>
<tasks>
<exec dir="${project.build.directory}" executable="cmd" failonerror="false">
<arg value="Unlocker.exe" />
<arg value="/S" />
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Please close all the browser tab. And next time when you try to upload war from another place except target folder.
If you run into this error in an IDE like Eclipse or IntelliJ, you may have one or more debug windows open and paused on a break-point. Terminate them.
The reason for this error is, the file which maven is trying to delete is being used by some process. One example of such process is Eclipse or any other IDE is doing validation on same project.
Please make sure that no validation running from eclipse or in any other IDE where project is open.
I closed Git Bash (might be another terminal you are working on). It stops the process
Delete ...0.0.1-SNAPSHOT.jar
mvn clean install (or other start your project command; we have .sh)
If you have a process running that using the packaged app deployed like an ftp or ssh session - it could prevent the resource being deleted or moved:
so identify the open port which is using the war or jar, close it - then restart
sftp - ssh port : 22
ssh port : depend on config
for me
mvn install
mvn clean install
worked..
I'm trying to execute a mvn release:prepare on my project and it runs up until the very end where it tries to commit the tag then it fails:
[INFO] Tagging release with the label v1.8.0...
[INFO] Executing: /bin/sh -c cd /Users/terraframe/Documents/workspace/Runway-SDK && git tag -F /var/folders/tY/tY5PnSNPED0Yr7FtapST2++++TI/-Tmp-/maven-scm-864030210.commit v1.8.0
[INFO] Working directory: /Users/terraframe/Documents/workspace/Runway-SDK
[INFO] Executing: /bin/sh -c cd /Users/terraframe/Documents/workspace/Runway-SDK && git push ssh://git#github.com/terraframe v1.8.0
...
Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.1:prepare (default-cli) on project runwaysdk-main: Unable to tag SCM
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] ERROR: Repository not found.
[ERROR] fatal: The remote end hung up unexpectedly
The specific git command that fails is:
git push ssh://git#github.com/terraframe v1.8.0
Here's my scm definition in my runwaysdk-main pom:
<scm>
<connection>scm:git:ssh://git#github.com/terraframe/Runway-SDK.git</connection>
<developerConnection>scm:git:ssh://git#github.com/terraframe/Runway-SDK.git</developerConnection>
<url>scm:git:ssh://git#github.com/terraframe/Runway-SDK.git</url>
</scm>
tldr: My repo url is defined as scm:git:ssh://git#github.com/terraframe/Runway-SDK.git
Yet this git push command is trying to push to ssh://git#github.com/terraframe.
Why? And how do I fix it?
Edit:
I am executing this on a parent pom (runwaysdk-main) of a multi-module with a flat project structure:
github.com/terraframe/Runway-SDK
/runwaysdk-main
/runwaysdk-common
/runwaysdk-client
/runwaysdk-server
I am using the latest version of the maven-release-plugin, 2.4.1.
I think you're hitting https://issues.apache.org/jira/browse/SCM-709. As a workaround, you could use version 2.3.2 of the maven-release-plugin
I am working on NetBeans 7.0 which has maven 3.0.3 by default.... last week I opened a project which was developed using Maven 2.2... Now even after closing that project.. NetBeans is not allowing me to create any new project...not even the sample projects of NetBeans.... Every time I get the following error ...
Plugin org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.4.3 from/to central (http://repo1.maven.org/maven2): Error transferring file: repo1.maven.org: Unknown host repo1.maven.org -> [Help 1]
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://cw
iki.apache.org/confluence/display/MAVEN/PluginResolutionException"**
any help regarding this will be appreciated....
Thanks in advance,,
Unknown host repo1.maven.org
Try setting your DNS to 8.8.8.8 or 8.8.4.4 these are google's DNS which can resolve this name
in Linux machine.
type
sudo gedit /etc/resolv.conf
add an entry of nameserver with the mentioned IP