maven deploy goal failing - java

I am using eclipse with maven2 plugin.
When doing a Run-As -> build with a goal of 'deploy' I am getting this error:
Error message:org.codehaus.plexus.component.configurator.ComponentConfigurationException: Class 'org.apache.maven.artifact.repository.ArtifactRepository' cannot be instantiated
I'm not sure I even need to do a 'deploy', I have another build that does a 'compile' goal, and from what I have learned doing a Run-As -> Run on Server (tomcat) is enough to deploy my application locally to tomcat.
Do I need run this build 'deploy' goal to run locally, should I just delete it and use 'run on server'?

Running mvn deploy won't "deploy your application on Tomcat", deploy is something different here, deploy is a phase done in an integration or release environment and copies the final package to the remote repository for sharing with other developers and projects.
In other words, unless you are dealing with a remote repository to distribute your application (and this requires to configure a valid <distributionManagement/> section in your POM), just forget about deploy for now, this is not what you think it is :)
So, to run your application and "deploy it on Tomcat" from Eclipse, use Run As > Run on Server. If you want to run it from outside Eclipse, you can use mvn tomcat:run but this isn't really appropriate here (this goal is an handy way to run a webapp without importing it in a IDE). And if really you want to deploy your application on Tomcat from the command line, the Maven Tomcat plugin supports many methods for Deployment. But again, I don't think that this is what you're looking for for now.

Related

Jenkins Build and Deploy

I am learning Jenkins. Can someone tell me if my understanding is correct?
To build the app:
I commit my code and push my branch to my remote repository.
Jenkins sees my commit and triggers off a build (possibly using maven install).
Jenkins runs all the tests and if all pass, a war/ear is created. This artefact is pushed to nexus.
To deploy to an environment:
A deploy script in my branch contains steps to deploy the app to, say, Tomcat.
Jenkins goes to Nexus, retrieves the latest artefact (built above), and deploys this app to Tomcat.
Other steps in the deploy file shutdown and restart Tomcat as necessary, possibly testing to make sure the app started and is ready to serve requests.
Am I right in saying that a deploy doesn't need to build the latest artefact, that it uses that last one pushed to Nexus, or is a fresh one built every deploy?
It's all according to how you set up your build on Jenkins and/or git.
Jenkins can be configured to monitor your repository (repo, for short) and to kick off a build when it detects a change.
Jenkins can be configured to run a build. You provide the Maven command-line arguments; Jenkins just orchestrates the commands you give it.
Some of the steps you provide Jenkins will be shell code. This is how you can run custom shell scripts, say to access Nexus. Things don't happen by themselves; if you tell Jenkins to deploy an artifact, say by using Maven, then Jenkins will invoke the deployment command as you told it to.
It is highly irregular for an app deployment to arrogate responsibility to start, restart, or shut down your server (Tomcat). That could be done via Jenkins, sure, but it's at a higher "pay grade" than an app deployment should have. Keep it simple; if your Jenkins build is managing an app for testing and deployment, keep its focus on the app and not on the server.
Jenkins is magical, but it's not a mind reader. It will do none of the things you said unless you tell it to. That said, the process you outlined is a reasonable one, whatever tool you use to enact it. Jenkins certainly can do those things, if you set it up accordingly.

Run Automation Scripts after Deployment on Tomcat Server using Jenkins

I've deployed a servlet based web application(War file) in Tomcat server using Jankins and Maven. Now I want to run some selenium automation scripts on same application, Can it be achieved by Jenkins.
Its like Deploy web application on Sever and once deployment is successful run automation scripts using jenkins..
Please Help..
Two possible ways :
1) Add post build step to your current task and run the scripts there.
2) Add another task ex. "app-automation-scripts" that runs every time that your current task is builded correctly.
Yep,
you can add maven plugin to jenkins, (installed by default most of times)
then declare your project as war in pom.xml
then add a post processing "maven" to your maven build config and configure it with options "war:war"
-- options you can add for a maven build is: clean install build and etc. war option is for creating war files.
Or:
simply run a bash command using your jenkins build configuration.
Former needs installation of maven plug-in and configuring it,
Later needs configuring your maven to be run on the jenkins server by user named "jenkins".

How to run Maven on startup as a daemon or standalone

How to run Maven as soon as my server boots?
Is it OK to have a script executed using cron once the server run? or is this a bad practice?
I am using Jetty and Resteasy and running them on Maven to start my webserver.
What is the best solution for when my server starts, Maven automatically starts?
The command is use is:
mvn jetty:run -e
EDIT:
I am using Amazon EC2 to launch an instance and I would like to have the maven build to run as soon as an instance is launched.
Maven builds and runs Resteasy, Jetty and a bunch of other dependencies that are stated in the pom.xml file.
You can use your OS specific init scripts approach. A very good answer for Ubuntu OS can be found here.
Usually, you use Maven as a build tool, not a deployment tool.
What are you trying to accomplish? If you just want to boot Jetty, it comes with its own init scripts which will start it on boot if you enable them.
Unless there is a convincing reason to use Maven for this, I would have your Maven build process create an "executable unit" such as an executable JAR, a WAR, etc. and then boot that at startup instead.

Managing Maven project in Eclipse with git repository

we recently migrated to Maven Build manager & git hub repository for our Java web-app. Also i switched to eclipse as eclipse has good set of plugins.
As a new bie, i am simply running mvn clean package from terminal at the code root directory. And then moving the compiled code i.e., /target/SNAPSHOT/* to tomcat/webapps/ROOT location.
And then starting Tomcat7 server. The process is time taking especially when i do code changes in Java & configuration .xml files.
I want to do it completely in IDE environment as i did earlier in Netbeans, update code -> build and run in debug mode, -> do code changes and then commit.
Heard of egit & m2e in eclipse for maven & github integration, but not sure how to use it.
Please walk me through the steps required in doing so. I am completely new to eclipse.
--
Thanks
You might want to consider using maven-jetty-plugin http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin for running the webapp. You will not need to copy over stuff to tomcat. After configuring this plugin, you can simply run your application by doing mvn jetty:run
I generally do not like running webapps inside Eclipse. It's a personal prefrence, but it is always nice to have an IDE neutral way of building and running your applications. If you have m2e things should work simply fine. I have seen maven-jetty-plugin having hot pluggability where if you changed your web.xml, jetty would reload your application.
We use Git for version control and Maven for dependency management and build automation. Once your project has successfully imported into Eclipse and recognized as a valid java web project, you don't need either Git or Maven in order to build/run it inside IDE. Just creat a server using you existing tomcat installation, add the project to server, then select Run as > Run on Server.
The Complete Guide:
Creating a server
Adding projects to a server
Starting a server
For more details, check out Testing and publishing on your server.

Deploy Java EE project to WebSphere 7 WITHOUT Eclipse

I am getting tired of all the bugs in eclipse and m2eclipse, and would like to build with maven using the command prompt, plus afterwards start the server, and deploy the application to the server and publish it using the command prompt. Normally I do that within eclipse servers tab.
If I make a change to the code, then I should just rebuild with maven and republish.
I am aware that you can deploy an EAR in Wepshere admin web console, but it is not ear I am thinking of, at least I don't think so. I want to be able for example, once application is deployed, jRebel should be able to reload the clases in the jvm, but I believe the ear file is standalone so that wouldn't work.
So,
How can I start the server from the command prompt, plus deploy a project and publish it ?
Thanks!
You can automate the build so that it deploys the app as well, at least with Maven. Have a look at this post: Maven 2 and WebSphere:
WebSphere has (had?) a Rapid Deploy feature that you can use for "hot" deployments. Essentially it fired up a headless Eclipse for this, but it was much faster than a full EAR build and just as dynamic as going through WTP.
At the time, we had an Ant task that we used to copy the files over to the WRD directory. I'm not sure how that would work with Maven, but I imagine one could rig up something.

Categories

Resources