When building the Java web application through the maven build tool we get the war file as the artifact which is an executable file. So I have a basic doubt which is if we can execute the war file directly then why do we need an Apache tomcat webserver to host this war artifact?
Related
I have a Maven Dynamic web project in Spring - I can run this in eclipse with a tomcat server and serve all my code a web page via localhost.
I am looking to create an executable which can be ran locally on a machine with no internet connection and when ran will serve the web project to a specified localhost URL.
If you have included an embedded server (like tomcat) as a dependency in you POM.xml file, then you have to Right Click on your Project -> Run as -> Maven Install. This will build a Maven Executable Jar file in the target folder of your Maven Application.
Take the Jar file and Run it from command line using
java -jar <jarfilename>.jar
After building project you will have <project_name>.war file created in target folder inside the project.
You should deploy it to a J2EE application server, like: Glassfish, JBoss Wildfly, etc.
I am building a war file from eclipse it is working fine but when I tried a build a war file in Jenkins by using Maven plugin it is building a war file but it is not working. where exactly I am doing wrong..
i installed ubuntu 16.04
installed java 1.7
installed maven 3.3
installed jenkins
configured jenkins and with java and maven installation path. Given maven cmd
clean install.
the build is successful and war file is deployed to tomcat 8 container but I am getting an error like
HTTP Status 500 - No WebApplicationContext found: no ContextLoaderListener registered?
But when I export war file from my eclipse and copy it to tomcat container it is working fine and I followed https://www.youtube.com/watch?v=eIldJE4tSlA to configure maven project in jenkins.
I followed this tutorial http://www.mastertheboss.com/jboss-maven/jboss-maven-example-building-a-java-ee-6-application/ in order to have a simple web application to better understand Java EE and JBOSS. I set up the example project (by archetype) and compiled it.
However, I am stuck after running mvn compile. I want to deploy my application as a war file to my JBOSS webroot directory (in my case /usr/share/jboss-as/standalone/deployments/).
I think mvn package and mvn install must be executed. Where can I specify that I want a war file and that it should be copied to my deployment location on JBOSS?
Obviously, I can use the jboss maven plugin http://docs.jboss.org/jbossas/7/plugins/maven/latest/, which is addressed via console
jboss-as:deploy
Configuration is read from the POM file.
Hi recently i heard that we can use jetty-runner to deploy a war file.But my question is can we use this to deploy a war file which uses no maven.Can we use jetty-runner to deploy any war files.
jetty-runner is separate from maven, you just need to point at a war file
http://blogs.webtide.com/janb/entry/jetty_runner
cheers
Here is want I want to do. I created a maven project and configured the jetty plugin for it in eclipse...
So from Eclipse if I do run and set the maven goal there to be jetty:run it runs my project in jetty on the port specified in web.xml. Now I want to build the jar file and when I do java -jar myapp.jar it will automatically call jetty:run.
How can I do this?
If you want to package your application so that you can hand it to someone and have them run it as a standalone application without having to go through deploying a war file into a web container, then that is a different concern from doing mvn jetty:run at development time, I will call that deployment time to avoid any confusion
At deployment time, we can't assume there will be maven on the machine, thus no mvn jetty:run, and even if there was, this would not work, unless we deliver the source code to run the build as in the development environment!
A standalone web application can be packaged by bundling the jetty jars in the application war along with a Main class to start jetty programmatically, and get it to run the application war. This relies on the fact that the file and directory structure of the WAR and JAR are different, and thus there is no significant overlap between the two, which is what makes this workaround possible, and it also leaves the option of deploying the war file in a web container possible
There is a maven plugin that embeds winstone which is another lightweight servlet container
For jetty, you may start by reading Embedded Jetty 7 webapp executable with Maven