Problem with deploying IntelliJ war file build with tomcat - java

I am using the simple IntelliJ web project with the default configuration.
I don't see any servlet mapping in the web.xml file:
web.xml file
However, when I run the project in IntelliJ it just works fine:
Project
But when I build it as a war file and deploy it with my tomcat server I can't access the hello-servlet.
Why Local IntelliJ tomcat server works even without proper servlet-mapping on the web.xml file and why it does not work on the tomcat server when I copy the war file into webapps directory.

Related

IntelliJ IDEA Ultimate 2020.1.2 - Tomcat 8.5.55 - war file not in webapps dir

Am using IntellIJ IDEA Ultimate Edition 2020.1.2 and Tomcat 8.5.55 on macOS Catalina 10.15.5
Have setup a run configuration inside IntelliJ for Tomcat.
Am able to run Tomcat via IntelliJ IDEA and everything works (am able to run tomcat and see my webapp inside Google Chrome & see catalina.out via IntelliJ) but when I go to the webapps dir, I don't see the unpacked war file anywhere?
cd $CATALINA_HOME/webapps
ls
Directory listing:
ROOT docs examples host-manager manager
Question(s):
How can I setup / edit my Tomcat local run configuration to move the war file (whether exploded or not) inside $CATALINA_HOME/webapps?
Where is this IntelliJ generated war file located?
Configure the artifact output path to be under webapps directory.
In the artifact output directory.
Normally there is no need to change it, IntelliJ IDEA instructs Tomcat to deploy from the configured artifact output location.

SpringBoot with embedded Jetty does not unpack the war file

I am deploying a war with embedded jetty using SpringBoot. I start it using java -jar .war. The web app run fine, but the war file is not unpacked to any directory. I have tried setting -Djava.io.tmpdir, and even tried customizing JettyEmbeddedServletContainerFactory and setting the tempDir after extracting the WebAppContext out of the Server. My customizer runs and correctly sets the tempDir, but the war is not unpacked at all.
What do I have to do make it unpack the war file ?

Deploying Eclipse Java Dynamic web project on Apache Tomcat permanently

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.

Application deployment folder on JBoss

Is there any configuration to hot deploy war file AND extract it into a project folder besides the .deployed file so we can modify web.xml, persistence.xml, just like Tomcat and websphere?
Thank you

How to access a directory in maven web application (java)

I'm working in a Maven web application (Java), Glassfish as web server. I have a directory for example path = Application_name/src/main/webapp. But I need to access the directory as http:///localhost:8080/webapp. Do I need some configuration for this in my application or in Glassfish or some other configurations?
You configure the port in glassfish directly. 8080 is the default port. See here if you want to change: https://blogs.oracle.com/openroad/entry/changing_default_glassfish_port_numbers.
For the name (webapp), it happens in your web.xml. Add this:
> <context-param>
> <param-name>webAppRootKey</param-name>
> <param-value>webapp</param-value>
> </context-param>
I suspect you are using Maven, resources in the /src/main/ressources/ folder should be copied as such in the root of your web application.
It sounds like you are talking about how to deploy the application:
Make a web.xml and glassfish-web.xml
Put them in webapp/WEB-INF
Have maven build a war file using the war plugin
Deploy war to glassfish via maven, the command line (asadmin), or with the admin console web page (typically http://yourmachine:4848)
http://maven.apache.org/plugins/maven-war-plugin/usage.html
look up "context-root" in glassfish-web.xml (or older versions sun-web.xml) for example: http://docs.oracle.com/cd/E19798-01/821-1750/beasg/index.html
For faster development you can also deploy an "exploded" war file or use the auto-deploy directory. http://docs.oracle.com/cd/E18930_01/html/821-2417/gilfm.html#SJSASEEADGfvxze

Categories

Resources