I am trying to deploy my Java app into Heroku server with maven heroku plugin. But i am getting such error:
Failed to execute goal com.heroku.sdk:heroku-maven-plugin:3.0.4:deploy (default-cli) on project endlessblow-server: Execution default-cli of goal com.heroku.sdk:heroku-maven-plugin:3.0.4:deploy failed: Failed to create source statuscode:401 responseBody:{"id":"unauthorized","message":"Invalid credentials provided."}
my pom.xml looks like this:
(...)
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>3.0.4</version>
<configuration>
<appName>MY_APP</appName>
<processTypes>
<web>java $JAVA_OPTS -cp target/classes:target/dependency/* pl.jawegiel.Main</web>
</processTypes>
</configuration>
</plugin>
(...)
How to solve that? A few weeks earlier everything was working fine.
Thank you in advance!
From the Maven plugin's doc: https://github.com/heroku/heroku-maven-plugin#heroku-api-key
This plugin uses Heroku's Platform API and thus requires an API key to function. If you have the Heroku CLI installed and logged in with heroku login, the plugin will automatically pick up your API key. Alternatively, you can use the HEROKU_API_KEY environment variable to set your API key
I guess you were previously logged in with Heroku CLI, so running mvn heroku:deploy was working just fine...
Related
I'm running mvn build and using fabric8 maven plugin for dockerizing the application. Every time I run the build it fails as it uses a docker command that fails docker-credential-secretservice version. [ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.28.0:build (docker-build) on project useradmin-server-war: Error getting the version of the configured credential helper: Process 'docker-credential-secretservice version' exited with status 1 -> [Help 1]
I tried the command manually in the terminal but it fails and outputted: unknown credential action version
Any ideas how to solve this, I can't find something useful when I searched.
It was a bug and resolved in later versions of the plugin. I changed the plugin version from 0.28.0 to 0.33.0.
Here's the plugin from the pom.xml (after updating the version):
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.33.0</version>
</plugin>
I need to set a active profiles to the jars while compile the maven spring boot project
Following are my two Approaches tried to activate the profiles.
First Approach - Not Activating the Profiles
mvn clean package -Dspring-boot.run.profiles=dev help:active-profiles
-s settings.xml
*
Above command not setting the active profiles while executing jars
java -jar package.jar
I have using maven plugin dependencies for activating the first approach
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions> </plugin> </plugins></build>
Second Approach - Working as expected.
mvn clean package -Dspring.profiles.active=dev help:active-profiles -s
settings.xml
java -jar -Dspring.profiles.active=dev package.jar
I'm using multi-module parent pom structure for the project. Any one pls advise to work the first approach?
Maven is a build system. Its responsible for building your artifact.
Maven's profiles are basically a tool that allows to slightly change the build process depending on various factors (operating systems, version of java and so forth).
These are defined in maven's files (pom.xml)
Spring (and Spring boot of course) as opposed to maven is a runtime framework.
Spring profiles is something totally different - they allow to load different beans, resolve different configurations in runtime (read after you call java -jar app.jar) depending on profile definitions.
So don't be confused with the same name, its only an "accidental coincidence"
Now as for your question.
Maven builds the artifact and packages it for that use spring boot maven plugin. If you want to customize this building process - use maven profiles (and as a consequence help:effective-profiles can be sometimes handy).
When the artifact is built - you can run it. For that you can use spring profiles to define runtime in-variants:
- Addresses of databases
- Credentials
- Some subsystems of your product that won't be run locally
and so forth, this list really depends on the application itself.
There is an option to run the spring boot application right from maven and for that you can really use -Dspring.profiles.active=dev but if you don't run it (and you don't in any of suggested approaches, read about mvn spring-boot:run to understand what does it really mean to run a spring boot application during the build), then:
First approach:
mvn clean package -Dspring-boot.run.profiles=dev help:active-profiles
-s settings.xml
-Dspring-boot.run.profiles is irrelevant here - you do nothing with it (again you don't run the project during the build) so it does nothing
java -jar package.jar
Here you can really specify spring profiles with --spring.profiles.active=dev,whatever
The Second approach:
mvn clean package -Dspring.profiles.active=dev help:active-profiles -s
settings.xml
Again, -Dspring.profiles.active=dev is irrelevant, it does nothing.
java -jar -Dspring.profiles.active=dev package.jar
Here you do specify the list of active profiles (just like --spring.profiles.active, from spring boot's standpoint its the same) That's why the application works in runtime as expected
I'm trying to learn how to use maven, spring-boot and docker to create a web-application. I'm following this guide:
https://spring.io/guides/gs/spring-boot-docker/
I managed to build the maven project as such that localhost, says "Hello Docker World".
Then I copied the Dockerfile and added the extra property and plugin.
<properties>
<java.version>1.8</java.version>
<docker.image.prefix>springio</docker.image.prefix>
</properties>
...
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.3.6</version>
<configuration>
<repository>${docker.image.prefix}/${project.artifactId}</repository>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
When executing mvn -N io.takeri:maven:wrapper to add the maven wrapper I received an error:
Error resolving version for plugin 'io.takeri:maven from the repositories[...]: Plugin not found in any plugin repository -> [Help 1]
As the command above has already worked on a different attempt (without docker) I checked the Help 1-link
https://cwiki.apache.org//confluence/display/maven/pluginresolutionexception
and added the same plugin-repository to the pom.xml as in the other project were it worked.
This proved to be ineffetive.
Executing the Project without the wrapper (mvn install dockerfile:build)
gives a MojoExecutionException followed by a long Error-Trace
and the
error: Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.6:build
(default.cli) on project ...: Could not build image:
java.util.concurrent.ExecutionException:
com.spotify.docker.client.shader.javax.ws.rs.ProcessingException:
org.apache.http.conn.HttpHostConnectException: Connect to localhost:2375
[localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused:
connect
How can I resolve this issue?
Note1: I'm new to Maven AND Spring-Boot AND Docker AND Stackoverflow, please let me know how I can improve this post or learn more about them.
Note2: I'm running Windows 10, and was planning on using Virtual Toolbox for Windows and successfully executed this guide https://docs.docker.com/get-started/part2/
I wonder what repositories you refer to? Both the takari plugin and spotify plugin are available in maven central, so no repositories should need to be configured in your pom. Or did you add them to your settings.xml? Could you try to simply remove repositories from your project?
Maven distinguishes dependencies and plugins. So you have sources (repositories to download them from) for both, meaning repositories and pluginRepositories. Nowadays companies will use a mirror/proxy like nexus or artifactory, so the difference is not directly visible - you only configure the mirror and point all repositories there.
So to use plugins there must be a pluginRepository configured that contains that plugin. See settings.xml docs.
Since all you need is in maven central the default config should just work without any more to do. So just remove all repositories from your pom.xml or settings.xml
The docker error you get seems not to be related to maven or the plugin, it simply cannot communicate with your docker host. Maybe to port is wrong or you are running a docker version not compatible with the plugin or it was not running? Docker for Windows might require you to expose the daemon without TLS.
Hope any of this is of some help :)
I had same issue. HttpHostConnectException You must run docker deamon on your machine.
Maybe you could configure environment variables.
I have created a RESTful API using jersey that serves some GET endpoints. The thing though is that now I have to ship this project as github link and provide instructions to open and run the project from the command line. I completely build the project using Eclipse and have scoured the web for resources but have no clue as to how to get this done. Could someone care to download the project into their machines and help with instructions to run it from the command line. The README has the links to the public endpoints.
Without needing to actually deploy it your Tomcat instance, you can use the tomcat maven plugin (which is meant for development). It starts an embedded tomcat instance, so you can test your webapps. Just add the following to your pom.xml file
<build>
<finalName>SimpleRestApi</finalName>
<plugins>
...
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
Then from the command line you can just run
mvn tomcat7:run
And a server instance will start. You can then access
http://localhost:8080/api/courses
If you want to change the context path, just use <path>/SimpleRestApi</path>. Then you can access
http://localhost:8080/SimpleRestApi/api/courses
I'm working on a web service locally, built using maven and deploying to tomcat. I'm using the maven plugin to run locally, using mvn tomcat:run as my run configuration.
Right now, my service is being deployed using the default project name as a context path:
http://localhost:8080/myArtifactId/servletPath
I would instead like to deploy to remove the context path, and deploy to this url through configuring the tomcat maven plugin:
http://localhost:8080/servletPath
Per this documentation: http://tomcat.apache.org/maven-plugin-2.1/tomcat7-maven-plugin/usage.html
I am trying this:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<!-- Why isn't this working??? -->
<path>/</path>
</configuration>
</plugin>
Any ideas on why what I'm trying isn't working, or a different way I can go about this? As I've stated, I'm trying to do this through the maven plugin.
Alternatively, does anyone know how to pass this in as an argument to the run configuration? Maybe passing it in explicitly at the command line will override the default.
UPDATE: Running mvn tomcat7:run or mvn clean tomcat7:run from the command line appears to make this work as intended. But when I run using a Maven Build run configuration in Eclipse, the service is started using the default artifact ID, regardless of what I put in the path variable in my pom.xml.
UPDATE: This appears to be a problem with the Eclipse Maven plugin. When I run the command from the command line, everything works as expected but when trying to add an Eclipse/Maven run configuration with a Tomcat7:run goal, the project keeps running using the default artifact id context path.
When experiencing problems with maven they mostly get solved by using the clean plugin (mvn clean) which cleans out your project's working directory.
http://maven.apache.org/plugins/maven-clean-plugin/