Fail to deploy WAR in Jenkins - java

I'm using Jenkins for the first time and I wanna try it in local before deploy in my company.
So I have a app.war generated from eclipse : it's a maven project.
I wanna to build it in Jenkins and then deploy it in Tomcat 6.
So I set the "right" configuration I think in Jenkins, but when I have launch the build, I got a successful build in my project but it's not deploying in tomcat .
I'll put my console Output of Jenkins and the configuration
Console Output Jenkins :
Configuration Jenkins
So what's wrong with that ? Thnx

Solution to your question -Edited
You have to select the appropriate container to deploy, from your question it is clear that you should choose Tomcat 7.X as a container.
Please use Jenkins Deploy Plugin which is configured with the following options as seen in the below link. Also this link will be your solution.
Also you can embed the Tomcat Maven Plugin in your pom.xml like below
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>TomcatServer</server>
<path>/YourPath</path>
</configuration>
</plugin>
Give the goals as clean install tomcat7:deploy -e

Related

IntelliJ IDE 2017.3.2 Maven Project packagingexcludes

I have a maven project that is going out to tomcat using a exploded war build in development. I have the following entry in my pom to exclude certain files for any non development environments:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>web</warSourceDirectory>
<failOnMissingWebXml>true</failOnMissingWebXml>
<webXml>web/WEB-INF/web.xml</webXml>
<packagingExcludes>
WEB-INF/classes/application.properties,
WEB-INF/classes/proxool.xml,
WEB-INF/classes/log4j.properties,
WEB-INF/classes/wetemplates/**
</packagingExcludes>
</configuration>
</plugin>
The packaging excludes are being used by intellij and excluded from my local development build and breaking it. I have been having to comment this block out in development for the environment to function correctly. How can I resolve this so that these are not excluded in my development environment?
You can use maven profiles to configure the build in such way that the Intellij build will use one given profile and the Maven/external build will use another profile.
Take a look at here: http://maven.apache.org/guides/introduction/introduction-to-profiles.html

How to configure MuleSoft with Maven?

I am trying to create my first MuleSoft application using Maven. I have used CMD to confirm that both Java and Maven are installed. I've also configured my environment variables.
I then open the MuleSoft Anypoint Studio, and create my first named "mulesoft-sample" I select to use Maven, and leave all default settings as they are.
Once I click finish, the Console begins to download a number of files
These continue to be downloaded until after it would seem the near end of the files, it throws an error:
There was an error running the studio:studio goal on project mulesoft-sample
In Console, I see the errors listed below.
I was originally trying to use the latest version of Maven (3.5.0). However, I found a video tutorial that said 3.3.9 was a verified version for MuleSoft. So I thought perhaps the newest version wasn't supported and instead used 3.3.9. However, it is still failing. I've also tried changing the environment variable to other options, such as going straight to \bin, rather than the complete directory (taking shots in the dark here). Unfortunately, nothing has worked and I'm running out of option.
Can anyone tell me why I'm getting these errors, and my build will not succeed? How to correct the error?
In anypoint studio go on windows>prefernces.then click on java>installed JREs. and add your Java JDK folder and note that only JDK, not JRE. then you can test your maven
This error occurs when the right java is not pointing with Anypoint Studio . In the studio navigate to windows > preferences the search java. Make sure jdk is selected and not jre . If still problem continues try updating your java and reinstalling maven .
Download the latest maven on your local machine, then goto anypoint
studio windows->preferences->anypoint studio->maven
provide the maven path and click Test Maven configuration(green
check mark obtained if the URL is properly provided)
Mule Maven Plugin configuration.
1.1. Use mule mule-app-maven-plugin to build the application.
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-app-maven-plugin</artifactId>
<version>${mule.tools.version}</version>
<extensions>true</extensions>
<configuration>
<copyToAppsDirectory>false</copyToAppsDirectory>
</configuration>
</plugin>
No need for additional Mule Maven plugins.
This is the default mule plugin set when creating your Mule project on AnyPoint (AP) Studio.
1.2. Make sure you set flag copyToAppsDirectory to false.
This flag is set to true by default so you must change it manually.
Maven Dependency Plugin Configuration.
2.1. Now we need to add a plugin to copy the generated artifact to the MULE_HOME/apps directory, i.e. to deploy the application to the standalone local mule server.
We will use the maven-dependency-plugin.
Just add these plugin after the mule maven plugin section in your application pom.xml.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>deploy</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.mule.support.ba</groupId>
<artifactId>bonmarche-case-00145615</artifactId>
<version>1.0.0</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>C:/mule-home/apps</outputDirectory>
<destFileName>bonmarche-case.zip</destFileName>
</artifactItem>
</artifactItems>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
2.2. Update the attributes within the tag (in grey) with the corresponding values on your environment.
2.3. As you see in 2.1, we are configuring the deployment to apps folder on Maven 'deploy' phase. You may choose a different phase to copy the artifact, but it must be bound to any phase after the package phase, so that the artifact exists in the repository.
Disable the default execution of Maven Deploy Plugin to prevent deploying the generated artifact to an external repository. This may be changed depending on your project needs.
Add this plugin after maven-dependency-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
Build your application and verify the generated ZIP file is copied to MULE_HOME/apps directory.
$> mvn clean deploy
I have faced same issue and got resolved by changing the JRE to JDK in preferences==>java==>Installed JRE's there change to JDK and restarted the any point studio. This resolved the issue to me.

maven adds version number to war - won't deploy

I'm using maven to build a war file for JBOSS AS 7. After a maven deploy, there is 'test.war' in the local repository, and a 'test-2.war' in the remote repository. This is all as expected (2 is the version in the POM).
If I manually deploy the 'test.war', everything works fine. If I deploy 'test-2.war' the deployment fails. If I rename 'test-2.war' to be 'test.war', the deployment works but trying to access it in a browser fails with error:
type Status report
message /test/Test
description The requested resource (/test/Test) is not available.
Since both war files are the result of the same maven build and deploy, why doesn't renaming the -2 version work the same as the first?
Is there a way I can deploy the -2 version without renaming, or what can I do to force the build so that I can rename the -2 version and have it deploy?
I know I can use maven's jboss deploy, but that's not an option in my case. I need the war file from the remote repository for manual deployments.
EDIT: The basic question here is why can't I rename the file {artifactId}-{version}.war to just {artifactId}.war and have it deploy in JBoss AS 7 properly?
You can rename the war like this:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>bird.war</warName>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
OR
<build>
<finalName>bird.war</finalName>
. . .
</build>
Take a look here

how to run a web service maven project on jetty 8 from eclipse?

I have a REST web service which I created previously and deployed in Tomcat7. I wanted to deploy it on Jetty, as advised in a previous question, I made a Maven project and copied my files there and configured the dependencies and I can run Maven install from eclipse successfully.
This is my build part in POM.xml:
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<dependentWarExcludes></dependentWarExcludes>
<webappDirectory>
WebContent
</webappDirectory>
</configuration>
</plugin>
</plugins>
</build>
I followed instructions here to use maven jetty plug-in (I am not sure if this is required). The question here is how can I deploy my maven project in jetty from eclipse so that i can go to http:localhost:8080/myproject for example and see my project working?
EDIT:
The way I used to run the service on Tomcat was by right click on the project and click on Run As -> Run on server (which is configured in eclipse servers)
I am using eclipse Indigo, Maven 3 and jetty 8. Also I used jersey for the web service.
Here, you are mixing two different things:
Run your Web application using a Eclipse server plugin as Tomcat plugin for Eclipse.
Run your Web application using a Maven plugin as Jetty Maven plugin. There are also Maven plugins for Tomcat.
Having said that, take a look to this answer where it is described how to configure Eclipse to run Maven plugins (it could change depending on Eclipse version but idea would be similar)
Edited:
If you just want to run jetty from Maven, just use the following command line:
mvn jetty:run
But, in any case, I recommend that you indicate the Maven jetty plugin version in the pom file (Maven will warn you if you don't).
Edited 2
First, update your jetty maven plugin version:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.0.0.M2</version>
</plugin>
Second. You are working with two plugins, one for building the war file (maven-war-plugin) and another one for running your application on jetty (jetty-maven-plugin). Take in mind that jetty thinks your project has a standard maven project structure, it means, it will look for your web app content in /src/main/webapp but it looks like is not here. In your war plugin configuration, you specify that your web content is in WebContent, so tell jetty plugin that directory is there, as well as you are telling it to war plugin:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.0.0.M2</version>
<configuration>
<webAppSourceDirectory>/WebContent</webAppSourceDirectory>
<webXml>/over/here/web.xml</webXml>
<jettyEnvXml>/src/over/here/jetty-env.xml</jettyEnvXml>
<classesDirectory>/somewhere/else</classesDirectory>
<configuration>
</plugin>
See documentation. Of course, it is better to work with a standard maven project structure so you do not need to tell jetty where things are.

Not able to start Tomcat for MAven Project inside Eclipse

Not able to start Tomcat for maven project in Eclipse I am getting:
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.FilterDispatcher
while starting tomcat.
the same is working outside eclipse(making the war and deploying in Tomcat)
Can any one suggest what to do?
My answer will be slightly off-topic but If I dare, I really recommend using jetty and using hot deployment in a separate process, not to launch it from within maven, but as a real server in /etc/init.d. Then you could deploy your app easily with an external script, activable from within eclipse, that will do a hot deploy of context in jetty.
It takes time to get this config but it's the fastest I have found and uses much less memory than using jetty within eclipse, and much much less than using tomcat. Hot deploy is also quite interesting in jetty.
You build cycle will look like
edit / save from eclipse
build / package through maven from eclipse (eclipse indigo is a charm for that)
deploy your app in jetty through a external tool script from eclipse.
Regards,
Stéphane
It has to do with tomcat looking for those classes in src/main/webapp/WEB-INF/lib, You can add the dependency plugin to your pom.xml like this.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>src/main/webapp/WEB-INF/lib</outputDirectory>
</configuration>
</plugin>
This plugin will copy all the pom dependencies to WEB-INF/lib and tomcat can find all the jars when you it out of workspace

Categories