Why using Tomcat and not "java -jar"? - java

I'm creating a job in jenkins to deploy a springboot application to Tomcat.
I'm trying to understand why should I deploy an application to Tomcat? Why not just run the application on the server by "java -jar" command?
In my previous workplace we deployed the springboot application by creating a war file and "java -jar" command. We used "kill" to shut down the application and "java -jar" again to deploy a new version...
I understand that Tomcat has a big advantage here and I would like to understand what is it?
Google says me how to work with tomcat but I couldn't find a real explanation why need it except this that says:
It provides a management dashboard from which you can deploy a new web application, or undeploy an existing one without having to restart the container. This is especially useful in production environments.
But what do I have to manage here?

Related

What are the drawbacks of deploying a website using the Eclipse IDE?

I started my journey into web applications about three years ago and I'm happy to say that I've finally deployed a working website. My concern is that to deploy the website I use the Eclipse IDE and a Tomcat webserver. So basically I right click the project in Eclipse and then choose "Run As > Run on Server" and then select the Tomcat server I downloaded - from that point on the console spits out some startup messages and my website is online and ready for use. What are are some of the drawbacks of deploying a project this way. I've read just briefly about WAR files and adding them to Tomcats Webapps folder but I could neither get that working nor did I understand completely the process...so is it acceptable to just deploy the project the way I have been doing thus far by running it in Eclipse?
Generally Development machine and deployment server is different.
On Deployment server one may not have eclipse always.
WAR file is just a webarchive which includes all the necessary files. WAR makes your project portable.
Export WAR from eclipse place it in tomcat webapps in any machine and restart tomcat.
You should have your webapp successfully running on that machine.
That's a fine way for deploying a server when you're learning, or always have the server (the only server!) running on your development machine.
If you need to push to a remote machine, it won't work, and you'll need to learn other methods then, but for now, what you're doing is fine.

Deploy compiled Rails app to Java server on Heroku

What are the steps I need to take to deploy my compiled jruby rails application(with warbler gem) to heroku Java servers?
I don't know Java so I hope you can help with the actions I need to take. For example, how I deal with the database connection? What configuration I need?
for deploying your Rails application as a war archive you should follow the Java web-app runner guide ... although it does require some Java domain knowledge - mostly around Maven.
probably the easiest thing is deployment using the toolbelt plugin heroku deploy:war --war <path_to_war_file> since it assumes you have packaged the .war on your own locally ...
NOTE: be advised that if you'd follow the migrating to JRuby guide than you'll end up deploying without any .war packaging being involved in the process (similar to how you deploy with MRI)

How to deploy Workflow engine on jBOSS AS 7

I have running jBOSS AS 7 and I want to deploy my Workflow engine on this server. How can I do it? I have files .bpmn and .java. In .bpmn file I have scenario and in .java file I have class with functions which I'm using in my .bpmn file.
Please help me.
Greetings
rizon
You basically have two options:
(1) write your own web application that embeds the jBPM jars and calls the process at some point in time, this requires you to write a web app, embed all the jbpm jars and create a war from this to deploy
(2) take advantage of the jBPM console to deploy and execute your process on the jBPM execution server, you should install the jbpm-console and use the authoring environment to build and deploy your process and the management UI to start and manage your process instances. You can use git to sync your process in Eclipse with the jbpm-console. Consider using the jbpm-installer to install and start the jbpm-console on as7
Note that for (1) you need to have sufficient web development capabilities before you can get started with this. In this case, it seems going for (2) seems to be recommended.

What happens behind the scenes of deploying a Spring MVC application to tomcat outside of eclipse?

I guess a drawback of using such an awesome IDE like eclipse is that you miss the point for what happens behind the scenes of an application. I'm a ruby developer so not a java veteran. So I've been coding a project in java and using the spring framework for IOC and MVC. Can someone explain to me what is going on when I select run on server in eclipse? Because eventually I will be deploying this masterpiece of an application to a Linux server. Here is my setup. I am using Spring MVC 3 and the maven plugin in eclipse. In the pom.xml file, I have stuff like latest spring release version, log4j, spring mvc, spring context etc.
I have been testing my application on localhost using the handy option of run on server in the eclipse IDE. The server configuration in eclipse is pointing to the tomcat directory location for where I have installed tomcat 7. Please demystify what happens behind the scenes and what I will need to do if I want to deploy this application on a production server. The more detail the better. Thanks a ton in advance.
Deploying a web application to Tomcat is as simple as this (assuming Tomcat is installed)
Bundle your application in a .war with the correct format.
Move the generated .war file to the /webapps directory of your Tomcat installation folder.
Run the /bin/startup.[sh|bat] script in the Tomcat installation folder.
Note that there are intermediate steps you can do to configure the deployment, like changing your context path. Go through the Tomcat documentation for details.
In step 3, Tomcat will extract the .war contents to a directory in the /webapps folder with the same name as your .war file. It will use this as the context path. The script itself launches a java process by putting the WEB-INF/[class|lib|...] onto the classpath along with some Tomcat libraries.
So Eclipse basically does all the steps above for you.
Ultimately you are deploying an web application that means you are deploying a war file to the server. Regardless of using frameworks like spring, struts anything.
SO a web application request starts from web.xml file. SO for spring mvc application, you are mapping all request coming from browser to DispatcherServlet and then this guy is responsible to manage whole life cycle of your application.
For more details of how MVC works please see
http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/mvc.html
So in order to deploy your application (a war) on server first of all you have to create a war from your source code. You can go to traditional approach to use java given utility like using jar from command prompt or you can use ANT, GRADLE, MAVEN and such build tool that creates war for you in automated way.
Spring is not doing anything extra for you. I believe you to research a bit more on how these tools works.
Once a war is ready for you, you can simply go to tomcat UI and there you will find options to deploy your war.
I hope it helps you.
All the majic happens in two places.
The first is your 'Servers' directory in the root of your Eclipse Package Explorer. These are your server configuration files that Eclipse will use (mostly) when it creates a new server instance.
The second is in the ./metadata/.plugins/org.eclipse.wst.server.core/ file system directory in your Eclipse workspace. This is where the tomcat application is actually deployed by eclipse.
The Tomcat Documentation is pretty good actually and helps explain how to do deployments. FYI, I do not know many people that use the Manager, from my experience most people deploy their applications by hand.

How to test web project from eclipse to jboss as7 without mvn jboss-as:deploy

My firm is change the development environment, looking for some tricks and tips on how to work in the new environment.
The current environment is Eclipse and Tomcat. We are developing web applications with Spring, Web Flow, and MySQL..
The new environment is going to be Eclipse, Jboss AS7 and Maven.
Question 1:
Now for the questions as the current time we run tomcat on the local workstations and I can use eclipse to write my code and then just click on “Run On Server” and eclipse will build the war file and start tomcat.
With the new environment it does not look like Eclipse can start and stop and depoy right to Jboss AS so we are running a command line: mvn jboss-as:deploy does anyone know a better way?
Question 2:
Debugging.. Does anyone know how to get debugging working with eclipse and jboss as7
1) You can use "Run On server" with JBoss As 7 just like you do it with Tomcat. Just add new server in Eclipse for JBoss As. One difference comparing to adding new server for Tomcat is that during new server definition you should also create new runtime Environment for JBoss (if you haven't done this before) but this is very easy and intuitive. And there is a lot of examples in internet.
2) Debug is working with JBoss As very good too. If you start server from eclipse, then you can use debugger like you have used it before for Tomcat. If you run your server from command line without Eclipse, you can use remote debug from eclipse (as I remember Dubug as.. -> Remote Java Application and then specify there project, host and port).

Categories