I spended a few hours to resolve my problem with deploying jar file on tomcat but I lost all fights, and I must ask one question:
Is it possible to run the jar file via tomcat in intelliJ?
Best regards
It's not possible deploy a jar in Tomcat anywhere. You can only deploy war files.
Normally when you distribute a web application in a jar (like a spring boot app) you don't deploy it in a server, it's a standalone application you run from the command line.
Related
I have two applications with two separate WAR artifacts. One is a WAR exploded directory for my front-end Angular app, and one is a WAR archive file for my back-end Spring REST api. I'm currently using IntelliJ IDEA to deploy my front-end to a local Tomcat server and was wondering how, if at all possible, I could configure IntelliJ to run my two artifacts on Tomcat simultaneously. I know I can do this by putting both under Tomcat webapps directory manually, but I was wondering if it was configurable in IntelliJ, and if so, how?
Yes, you should be able to do that.
If you are using Ultimate, you can create a "Local Tomcat" run
configuration in Project1, and go to the "Deployment" tab and drop in
the WAR file for your Project1. Then drop in the WAR file from your
other project (call it Project2) as an External Source. You would
then have both WARs in one run configuration.
This is the answer I found out under this link.
I am planning to deploy a web application built on spring boot in windows server.
I want to use tomcat container.
Can I deploy the spring boot fat jar directly or is it recommended to deploy the war file.
please suggest how to deploy and the preferred method?
As Josh Long likes to say "Make Jar not War!" It really allows an application to have flexibility on where it can be run and allows for everything to be packaged as one artifact. Windows has no issue running the embedded Tomcat that is part of Spring Boot and that is exactly what it is doing when running it in your IDE. The one edge case to this is keeping the process running on the server. Normally in Windows you would do that by setting up a service and having that service run java -jar myapp.jar. I haven't personally seen it done so might take some playing around but it is possible.
A simple way to run a spring application in Windows Server is to run it as a service. You can do it using the winsw, that you download its .bin file here
winws download
Then, rename it to something like my-app.exe and create a XML file like this:
<service>
<id>my-app-service</id>
<name>my-app-service</name>
<description>Back end service for app</description>
<env name="HOME" value="YOUR_JAR_FILE_PATH"/>
<executable>java</executable>
<arguments>-Xrs -Xmx256m -jar "YOUR_JAR_FILE_PATH\YOUR_JAR_FILE.jar"</arguments>
<logmode>rotate</logmode>
</service>
Then, using the terminal, run:
my-app.exe install service
Your application is now a windows service and you can start\stop it in the tasks manager on the services tab.
Starting from the latest Windows versions, you could also deploy your Spring Boot app inside a Docker Windows Container. I wrote a complete guide: https://blog.codecentric.de/en/2017/04/ansible-docker-windows-containers-spring-boot/ (as already mentioned, Tomcat is already embedded in Spring Boot).
Spring boot internally has a tomcat server.
If you want to deploy it on tomcat then while building with maven build it as war.
If you want to deploy it has inependent application then build has jar and then place it in some folder and run it using below commands java -jar yourjarname.
Apache tomcat is a web container you cannot deploy a jar in tomcat server. If you created a web application then export your application as war file and put it in tomcat webapp directory, start the server and your war will be deployed.
How to deploy created .jar file in Apache Tomcat server in Eclipse IDE?
I have a Java web project in Eclipse which I run through Eclipse on Apache Tomcat.
Is there a way for me to permanently deploy the project on Tomcat such that it runs without having to open Eclipse and rather just starting Tomcat?
If yes, then what steps do I need to follow?
*UPDATE*
If I take the .war file and deploy it on another system will it work? Note that I am using a MySql database in this project. So will transferring the .war file also transfer the database?
You package the project into a war file (since it is a web project) and put that one into the Tomcat's webapps folder. The deployment should then happen automatically, when Tomcat is started.
Generate a WAR file within Eclipse. (Properties->Export->WAR File)
Place this file in the {installation}/webapps folder of Tomcat.
It should deploy now.
I have a Java application using Spring, Hibernate and JMX.
Now i wanna deploy it on JBoss. I exported it to a Jar file and copy to the deploy folder of JBoss. But when i start JBoss, that app isn't deployed.
The error I saw that JBoss can't find out library files of Spring and Hibernate.So guys how to deploy a file Jar on JBoss ?
Java enterprise applications are not deployed as jar files, but as .war files (for web application) or .ear files (for complete enterprise applications, including EJB).
You would probably be looking at packaging your app as a .war file. Even if it's not a "web application", it needs to be packaged as one to be deployed to a Java enterprise/web container like JBOSS.
I would suggest browsing the tutorial available from Oracle to learn more.
Is it possible to deploy a jar in tomcat?
i have created a jar using maven. Now can i deploy it in tomcat? i have scheduled some job and packaged it.
Tomcat deploying a jar
Thanks!
You could start JAR directly by using
java -jar /path/to/yourJar.jar
Tomcat is a web container, it deploys webapplication, it reads web.xml and starts the web application as instructed