I have a Maven, Java project with Eclipse and Jboss 4. Currently, after doing clean, install goals I am moving EAR and WAR files into Jboss Deploy folder manually. But every time this process hard to do. Are there any plug-ins or tools to do this job? I tried the "org.codehaus.mojo" plug-in but it did't work. Are there any other goals in Maven to deploy automatically to Server from Eclipse?
For such purposes you can use cargo which is intended for functional tests but supports the deployment of artifacts like ear, war into appropriate container.
may maven-war-plugin can help you
Related
I know about maven war overlays, but they assume that the original war file is a maven project.
What if I only have access to the packaged war file and I need to modify it by adding new resources or updating few values in properties file using maven and push the new overplayed packaged war file to tomcat on a server?
Is it too complex to do this in maven?
If I install the war file in my repository does the maven build process automatically use it?
It doesn't assume that the WAR is a Maven project, whatever that means, just that the WAR is a Maven artifact. You can install any WAR as an artifact, it does not matter how it was built. If you then declare a dependency to this artifact, you'll be able to overlay it. While it is easy to add and replace files (just create a normal web project structure containing the new files and the WAR plugin will do the rest), it is not easy to modify them. If you really wanted that, you'd have to run something like the replacer plugin after the original WAR is extracted but before the package phase of your project. It is also possible to download a (WAR) file instead of getting it from a repo by using some exotic plugins, but this is probably not something you should be doing as it blows away half the benefits of Maven.
As for deploying the newly-built application to a remote Tomcat, while doable using the Tomcat plugin, it is not something I would be doing from Maven. It is usually a job for a build server, like e.g. Jenkins, while the Tomcat plugin is more for local development and testing.
I have a project with maven, this a multimodule project
Mainproject
project1 - jar
project2 - jar
project3 - web
Now that I finished the project I want to test it on the server but don't know how to upload them, on my computer I have added a plug for tomcat which deploys the war file to tomcat automatically, but the server doesn't have maven.
What is the way for moving to production with this kind of projects?
Should I just upload the target directories for each module?
Thanks
You're asking a few questions here. There is the "how do I test on a server" one, and there is "what is the way for moving to production" one. And they can be quite different.
I have assumed that the JAR files in the project are used by the WAR file and packaged within its WEB-INF/lib directory. If I'm wrong, that's cool. Just this sort of information is handy to know.
Maven is a build tool. It is not a deployment tool. What you have at the end of this, is a WAR file. If you run mvn install (or mvn deploy) you have a SNAPSHOT version of the WAR file. This would be suitable for quick, ad-hoc testing to other machines. But you would most likely use methods approriate for the hosting container for making them available. Note: a Maven DEPLOY is a different thing from a DEPLOY a war file to tomcat.
To my mind, if you're putting anything into production, or in front of a customer, or in front of a testing group, you should use Maven to make a Release of the product. That is, using the release plugin (via the release:prepare and release:plugin goals) to create a non-SNAPSHOT release of your artifact (in this case, a official version of the WAR file). Once you have that WAR file, you can migrate it to your production server in whatever way is easiest (copy, deploy into tomcat in the best way). You haven't mentioned if there are database requirements for this web application, and that would need to be considered before you change any production application.
But, once you have official versions, you have tags of source code, and you can accurately know what code is being run.
What I don't think you're going to get is being able to automatically copy the WAR file into a production server from your development environment. Here be dragons.
I've run non-Maven applications on an Eclipse embedded Tomcat server before and I found the instantaneous deployment upon saving invaluable. However after starting a Maven project I didn't find any easy way to continue doing this.
Using WTP and the Dynamic Web Module Project Facet seems to wreck the project's Maven nature. Using JRebel is not possible in our company. Googling didn't provide any results that would work without again removing the project's Maven support. Is there any other way or am I doing it wrong?
Install m2elipse with WTP extension. Import your Maven WAR project. m2eclipse will configure Eclipse for and your can continue using your Tomcat in WTP.
I have a maven war module which run eclipse WTP tomcat server like normal. Now i want to reuse that module artifact by using maven war overlay: i just create a new war project and include that module in project dependencies. The problem is now i cannot use eclipse "Run on server" anymore because i don't have any resource or config file (like web.xml) in the new project, everything is in the war dependencies but eclipse cannot resolve it.
Is there anyway to use a maven war overlay project run with eclipse ?
Thank you.
If you're trying to have a war dependency on a war project, in other words doing a "war overlay", then it's not currently supported by m2eclipse
Jer developped a plugin to implement this feature, you can give it a try : http://code.google.com/p/m2eclipse-wtp-ext/
I've test this(to debug my first JASIG CAS server), and found it works in eclipse:
Using Jetty Maven Plugin to run/debug war overlayed web apps.
Hope helpful~
I am having the same issue here. I agree with you that it's not supported yet (and has not been for almost 2 years!). There seems to be an alternative using q4e version 0.11.0+: http://wiki.eclipse.org/IAM_WTP_support which you can download from https://code.google.com/p/q4e/ or using the update site http://q4e.googlecode.com/svn/trunk/updatesite-iam/ . I'll give it a try and see whether and how it works (with m2eclipse at the same time active).
I am updating an existing project from GWT 1.5.2 to GWT 2.0.0. We use maven 2 to manage our dependencies and do all of our development in Eclipse 3.5.
Because we use maven to manage our dependencies, I do not have all of those jars in the war\web-inf\lib directory as GWT specifies. Instead, they are in the maven repository, just where maven likes them. I have the project set up so that maven can successfully build and launch in either dev or web mode and the application runs correctly.
The problem is that when I launch from Eclipse, I get a java.lang.NoClassDefFoundError. If I manually copy of my dependencies into war\web-inf\lib before launching, everything runs fine, but that doesn't lend itself to a long-term solution. First, if I check all of those jars into our version control, that will subvert much of the value we get from maven. As annoying as maven can be, ditching it is not the answer. Second, having developers manually copy them over every time they want to debug something is ridiculous.
So can I get Eclipse to copy the dependencies into war\web-inf\lib before launching? Is there an alternate solution that I'm missing?
Thanks,
Tony
Running the gwt:eclipse goal will copy the maven dependencies into war/WEB-INF/lib. See the Eclipse Configuration section of the Eclipse IDE Integration documentation of the Maven GWT plugin for more details. Also have a look at this answer about Maven GWT 2.0 and Eclipse.
You should install the m2eclipse plugin and use that to build your project within eclipse. This will invoke maven as an external tool from within eclipse.
Your maven project artifact type should be set to war, which will let maven discover the dependencies and bundle them.
See these links:
force Maven2 to copy dependencies into target/lib
http://maven.apache.org/plugins/maven-war-plugin/
http://maven.apache.org/plugins/maven-war-plugin/examples/rapid-testing-jetty6-plugin.html
a maven aware IDE (idea, eclipse, netbeans) should do this packaging automatically. maybe you:
forgot to enable maven import inside IDE?
did not add these dependencies to the pom.xml (so they aren't included in the 'mvn package' phase)
added wrong scope to dependency declaration (e.g. scope 'provided' or 'tested'), so they are ignored for runtime
If you have the packaging method in your pom.xml set to war it should copy runtime depdencies into target/war/WEB-INF/lib.
Or is your project to build something larger like an ear? If so you should probably split your pom.xml into multi-project format.
As for Eclipse, I'm not terribly familiar with it so I can't really help you there. Are you (or can you) run a maven target (like "install") when you do a run or debug?
This is not supposed to be a problem. If you are using Eclipse+WTP then WTP lets you declare jars listed under 'J2EE module dependency' in the project's properties. Those jars are automatically published to tomcat (see note at the end of this comment)
You need to declare an M2_REPO variable in your eclipse environment (search eclipse help for 'classpath variables'), it should point to your local maven repository, and just add external jars from there to your project and mark them as 'J2EE dependencies'.
I did that with tons of projects, Maven and Eclipse live side-by-side :) (without m2eclipse)
A second option is to try to integrate Eclipse and Maven with m2eclipse plugin, as crowne mentioned, but I found this unnecessary.
There is a third option, if you don't use WTP (but you should). Assuming that you use tomcat, then you can copy those jars to $(tomcat.home)/common/lib. If you can do it just for your private instance of tomcat (on each developer's machine) then you are good to go.
This is supposed to be a low-impact solution that will get those jars into the classpath at runtime, but it doesn't scale well.
note: unfortunately the classpath of Eclipse web projects can be confusing. When you add jars to the regular build path of the project, they are not deployed (copied over) to tomcat. To solve this, WTP defines a special library called Webapp Library - this library contains all the jars in the project's WEB-INF/lib folder, as well as all the external jars that are marked as J2EE Module Dependencies. All those jars find their way appropriately to WEB-INF/lib when published to tomcat.
Quite simple:
1. Create a "lib" folder under your project like this:
"\src\main\webapp\WEB-INF\lib"
2. Copy needed "jars" etc that you want included inside your WAR bundle folder.
3. Invoke your maven build as you normally do. I use "mvn install", which creates builds the war file.
If you examine the WAR file, your jars that you included in step-1 and step-2 will be there.
Cheers.