Unable to Deploy to Tomcat using Maven3 with Mail API - maven-2

I am working on an application where we need to use java mail functionality. We have started using maven 3.x as out build tool.
Everything was working fine till Java Mail API has not been introduced. We are using Eclipse with M2Eclipse plugin but most of our deployment work is being done by maven Command line.
We have introduced following dependency in our pom.xml and I have verify that both mail.jar and activation.jar are in there respected folder structure.
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
We tried the following command
> mvn clean
and then
>mvn tomcat:deploy
Though maven is showing that it has successfully deployed war on the tomcat but tomcat console showing that it is failing to deploy application and in other successful cases we are facing a strange issue, as we are using hibernate for persistance layer so on examing the folder structure it came out that the mapping file .hbm files are missing due to which Session factory is not creating and server is not able to startup.
Here is the snap shot of plugin entry
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
<url>http://localhost:8080/manager/html</url>
<server>localhost</server>
<path>/blood_donor</path>
</configuration>
</plugin>

From you procedure I see:
mvn clean - that deletes target directory with your build
mvn tomcat:deploy - should take the build (which was deleted with mvn clean) and deploy it on tomcat
There is no build phase. So use instead mvn clean package tomcat:deploy. If your application is already deployed in tomcat try mvn clean package tomcat:redeploy. For details check plugin documentation.
Which Tomcat version do you use?
According to http://repo1.maven.org/maven2/org/codehaus/mojo/tomcat-maven-plugin/ you use the version 1.1. In the plugin documentation you can find there that Tomcat 7 is not supported in this version. For that you must upgrade to version 2.0. See http://tomcat.apache.org/maven-plugin-2.0-SNAPSHOT/
Probably yo

Related

Apache ServiceMix 5.x full version

I need to run Apache ServiceMix on servers with no direct connection to the internet. I am unable to find a "full" assembly for Apache ServiceMix 5.1.4. An older version of ServiceMix (4.5.3) has a full version available for download.
Is a full version of 5.1.4 is available and if so where?
http://servicemix.apache.org/downloads/servicemix-5.1.4.html
http://servicemix.apache.org/downloads/servicemix-4.5.3.html
Starting with ServiceMix 5.0.0 we have removed the full and minimal assemblies and we provide only the default assembly which only includes bundles used by default boot features (please see discussion under http://servicemix.396122.n5.nabble.com/DISCUSS-Which-assemblies-to-keep-around-td5719173.html)
If you have a project you want to deploy on the ServiceMix, you can add a new module to your project that runs the add-features-to-repo goal of the features-maven-plugin and zips everything up. Next you can deliver the zip file with all the bundles for
all the features you need to install on ServiceMix.
Thanks to KSobkowiak's answer which pointed me in the right direction. I am posting the steps I used to get a custom ServiceMix 5.x up and running in case anyone else needs to do the same. The instructions assume Linux, but windows steps should be similar.
1) Download and unzip ServiceMix and Maven
cd /opt
unzip apache-servicemix-5.1.4.zip
unzip apache-maven-3.0.3.zip
2) Configure maven proxy, if needed:
3) Create a maven project directory
mkdir serviceMix_features
cd serviceMix_features
4) Create a maven pom file with the following xml. I got the list of descriptors by running features:listurl command in the servicemix console. The features would be whatever you need in your custom servicemix distro, in this case I am adding the webconsole and several camel components.
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>my.group</groupId>
<artifactId>custom-servicemix</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>My custom service mix repository</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>features-maven-plugin</artifactId>
<version>2.3.9</version>
<executions>
<execution>
<id>add-features-to-repo</id>
<phase>generate-resources</phase>
<goals>
<goal>add-features-to-repo</goal>
</goals>
<configuration>
<descriptors>
<descriptor>mvn:org.apache.camel.karaf/apache-camel/2.13.3/xml/features</descriptor>
<descriptor>mvn:org.apache.servicemix/apache-servicemix/5.1.4/xml/internal</descriptor>
<descriptor>mvn:org.apache.activemq/activemq-karaf/5.10.0/xml/features</descriptor>
<descriptor>mvn:org.apache.karaf.assemblies.features/standard/2.3.9/xml/features</descriptor>
<descriptor>mvn:org.apache.karaf.assemblies.features/enterprise/2.3.9/xml/features</descriptor>
<descriptor>mvn:org.apache.jclouds.karaf/jclouds-karaf/1.7.2/xml/features</descriptor>
<descriptor>mvn:org.apache.cxf.karaf/apache-cxf/2.7.13/xml/features</descriptor>
<descriptor>mvn:org.apache.servicemix/apache-servicemix/5.1.4/xml/features</descriptor>
<descriptor>mvn:org.apache.servicemix/apache-servicemix/5.1.4/xml/examples</descriptor>
<descriptor>mvn:org.ops4j.pax.cdi/pax-cdi-features/0.8.0/xml/features</descriptor>
<descriptor>mvn:org.apache.activemq/activemq-karaf/5.10.0/xml/features-core</descriptor>
</descriptors>
<features>
<feature>webconsole</feature>
<feature>camel-restlet</feature>
<feature>camel-jackson</feature>
</features>
<repository>target/features-repo</repository>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
5) Execute the maven project. I noticed that sometimes maven would get part way through and fail. After retrying, I noticed that it pulled in additional jars each run, and finnally succeeded on the fourth try.
/opt/apache-maven-3.0.3/bin/mvn install
6) Overlay the maven files on the default service mix distro.
cp -Rvn target/features_repo/* /opt/apache-servicemix-5.1.4/system/
7) zip or tar your custom service mix distro and move it where you need to. If you were using a proxy, you can deconfigure the maven proxy and clear your maven repo to verify service mix was correctly updated from the service mix console.
features:install webconsole
You can find all releases from ASF from the Apache archive. For ServiceMix it is here: http://archive.apache.org/dist/servicemix/

Maven update jar before packaging in WAR

I have a project where I am packaging a WAR using simple maven-war-plugin. Along with all other dependencies one of the dependency say 'abc.jar' which is getting packaged in war contains a default spring configurations which I would like to update with the custom one before packaging. I have maven profile configured to be activated if following build command applied;
mvn clean install -DframeworkPacakging=XYZ
I am trying to use 'truezip-maven-plugin' to overwrite my custom spring configurations inside in 'abc.jar' present in 'target/aretfacts-id/WEB-INF/lib' but when maven-war-plugin finishes I loose my changes because war plugin takes the file from dependency definition. How can I solve this issue and what are my options?
P.S. Distributing configuration is not desirable as this setup would be used for Embedded Jetty Server running within Eclipse
to prevent inclusion of the original jar file, I would use go for approach suggested on: https://www.mail-archive.com/users#maven.apache.org/msg38537.html
Use <scope>provided</scope> for this dependency to keep it out of the
lib directory.
to include the repackaged one, I'd follow suggestion from: How to make Maven copy resource file into WEB-INF/lib directory?
Try changing the configuration of the maven war plugin to include a webResource:
<configuration>
<webResources>
<resource>
<directory>pathtorepackagedjar</directory>
<includes>
<include>**/abc.jar</include>
<includes>
<targetPath>WEB-INF/lib</targetPath>
</resource>
</webResources>
</configuration>

How to compile mule application through command lne

I want to separate the deployment portion and the compilation portion of a mule application. Does anyone know how to do this? To be specific, if I want a script that can compile my mule application, what do I need to do? What are the libraries that will be required for this?
You need to use the maven-mule-plugin to have Maven build an application archive.
Here is a sample configuration:
<plugin>
<groupId>org.mule.tools</groupId>
<artifactId>maven-mule-plugin</artifactId>
<version>1.9</version>
<extensions>true</extensions>
<configuration>
<copyToAppsDirectory>true</copyToAppsDirectory>
<excludeMuleDependencies>true</excludeMuleDependencies>
<inclusions>
<inclusion>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-cache</artifactId>
</inclusion>
</inclusions>
</configuration>
</plugin>
Be sure to have this repository active at build time:
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Repository</name>
<url>https://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
Also be sure to have:
<pluginGroup>org.mule.tools</pluginGroup>
in your <pluginGroups> (typically in ~/.m2/settings.xml).
Building mule applications from command line is pretty straight forward.
As OOTB solutions MuleSoft provides support both for Maven and Ant
See... You don't need to get Mule installed.... Only you need to get Maven installed.....
After creating an application in your Mule ..... Add the above Plugin in the pom.xml file and it use the command mvn clean install in your command prompt ...... it will automatically build the application and deploy it to Mule standalone
It seems to me the question posted also asking for the command to acutally compile and create the deployment via the command line. As long as the pom is setup correctly just type the following (as long as maven is installed)
mvn clean package
The archived package ready for deployment will be in the target directory.

Cloudbees Lift ClickStart pom.xml jetty dependency?

CloudBees Lift template pom.xml specifies Jetty as a dependency, even though Jetty is not available for Cloudbees yet. Is that just leftover from a boilerplate pom.xml, or is it required for something?
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>6.1.26</version>
</dependency>
...
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.22</version>
<configuration>
<contextPath>/</contextPath>
<scanIntervalSeconds>5</scanIntervalSeconds>
</configuration>
</plugin>
I suggest you fork https://github.com/CloudBees-community/lift_template, try the clickstart without this dependency, and create a pull-request if you successfully got it deployed without this dependency
I think that is a left over from lift - we can run jetty now via plain JVM apps, if that is what is preferred (however a new clickstart will be needed).
http://developer.cloudbees.com/bin/view/RUN/Java+Container
It's not necessary when running your application on CloudBees, but it would allow you to run it locally, should you want to.

Maven2: Cargo plugin hot deployment & Jonas support

I am trying to get the Cargo plugin works on my maven project in order to benefit from war hot-deployment targetting the Jonas server.
The official documentation is not that clear on what is supported and what is not (for example you can find this: http://cargo.codehaus.org/Hot+Deployment but also this http://cargo.codehaus.org/JOnAS+4.x).
Anyway I have the following coniguration in for my war's POM:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0</version>
<configuration>
<container>
<containerId>jonas4x</containerId>
<home>C:\JOnAS-4.8.4\nt\bin</home>
</container>
<configuration>
<type>existing</type>
<home>C:\JOnAS-4.8.4</home>
</configuration>
</configuration>
</plugin>
And when I run
mvn cargo:deploy
on my project, the war is copied to the Jonas webapps folder but there is no hot deployment. The file is only copied but the hot deploy Jonas command is not called so that my modifications are not available immediatly.
EDIT: I also tried to add a deployer configuration as suggested on the answers but the behaviour is the same (ie: war is copied but the Jonas hot deploy command is not called so that the war is not reloaded in Jonas).
Am I missing something or am I right saying the Cargo Maven plugin does not support Jonas Hot Deployement?
Thanks in advance!
The cargo page on deploying to a running container links to a table listing the version where hot deployment was introduced for that container. According to the table, JOnAS 4.x is supported from version 1.0 (which you are using), so it should work.
On that page it also has some guidelines for configuring the plugin for deployment, I've attempted to interpret them below.
From the home element in your configuration I assume you are attempting a local deployment. The configuration in the running container page implies that the hot-deployment should be automatic in this line at the end:
Just type mvn cargo:deploy. Notice that we haven't specified a element nor a one. This is because the plugin is smart enough to create default instances for you. Cool, isn't it?
However the earlier configuration block indicates you should configure the deployer section to make the cargo plugin aware of the war to be deployed. The configuration for the deployer would be something like this:
<deployer>
<type>local</type>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
<properties>
<context>optional root context</context>
</properties>
<pingURL>optional url to ping to know if deployable is done or not</pingURL>
<pingTimeout>optional timeout to ping (default 20000 milliseconds)</pingTimeout>
</deployable>
</deployables>
</deployer>
If the automatic option isn't working for you, consider declaring the configuration for your war.