How to deploy Java project to Tomcat - java

I have downloaded a sample extjs+mysql+spring web project (link) with a java backend that I'd like to set up locally on my machine. I have installed Tomcat server, and MySQL DB but it's my first time ever with a java-based web application and I have troubles setting it up. Does it require any modifications ? I thought that .jsp files should be included there, but I can only see .java sources. Do I need to build it before it's ready for deployment ? Any help appreciated.

This is an Eclipse project so you'd need to run it from within Eclipse.
Download Eclipse
Open the project in it
Define a Tomcat container in your Servers tab
Drag and drop the project onto the newly defined Tomcat
Run it

if your are using eclipse IDE for development, create a project in eclipse,
run as "run on server" , and set the running server (eg TOMCAT 7).
and thats it,,
make sure, you correctly setup spring project in IDE with all needed jar files .

Related

Deploy java web application to Tomcat with Visual Studio Code

I'm trying to deploy a java web application to Tomcat using Visual Studio Code and I'm having some issues that I'd like to share.
After installing the extension Tomcat for Java, I've tried to deploy a Maven Java Web project. To do so, I've clicked over project's folder and selected "Run on Tomcat Server" option. The result is an error with this message: The folder is not a valid web app to run on Tomcat Server.
Then, I've realized that maybe I should create a war file before running it on Tomcat. Therefore, I've executed mvn clean package command and afterwards execute "Run on Tomcat Server" option over the war file. Doing this the project has been deployed correctly.
However, compared to Eclipse's way to work with Tomcat, it seems to me a bit tedious. Particularly if I'm working with static files, like css or js, because every time I modify a file I should execute mvn clean package and "Run on Tomcat Server". Whereas, in Eclipse, these files are deployed automatically on Tomcat without restarting.
I wonder if there is another way to work with VS Code and Tomcat for Java.
Thanks!
If you use Spring, there is an easy way.
The Spring Initializr extension comes with an embedded Tomcat installation, and hot reloading works out of the box.
Rely on the following guide to install it:
https://code.visualstudio.com/docs/java/java-spring-boot

How to deploy a Spring MVC Maven project from Eclipse to an existing Glassfish server

I've got a Spring MVC Maven project written in Eclipse that was verified as working with an Apache Tomcat 7 as the web container.
I am trying to transfer it to my "server" pc where I want to deploy it to the my existing glassfish (4.1) server as the web container.
I am having a very hard time finding a big enough partial answer to get the rest of the way.
I have tried to just export the .war file to the autodeploy folder which resulted in a "deployfailed" file.
I have tried to setup a "new server" using glassfish tools, but I realized that this is creating a new server and the existing server blocks the socket connection.
Eclipse doesn't see to have standard web commands like build, clean or deploy, but I would happily settle for advice on how to tell it to deploy to the existing glassfish server similar to how I was able to with tomcat at my training location.
Check this answer. Then follow the following steps.
Go to the project in the Project Explorer.
Select the web project.
Right click and select "Run As", you will see glashfish. Select it and click run.

Deploying Eclipse dynamic web app after changing java source

I have a eclipse dynamic web project with backend written in java. I have configured Eclipse to deploy and run this project using tomcat.
When I change my java source code, build project and run the server in tomcat, sometimes my changes get applied, but sometimes they do not get applied.
When changing java source code, what are the steps I need to follow when running the project, so that changes will be applied?
I am using eclipse jee neon.
When you changes to the code, follow following steps to test the changes.
Go to the servers tab in your IDE and remove the existing web module
related to your application.
Now right click on the project and build project. Then right click on
index.jsp file and select Run as → Run on Server

Run spring project in eclipse

I am new in spring.I imported one spring project in eclipse and try to run with apache tomcat but it is not running.There is no main method in project.It contains only controllers and models and one jsp page.When i tried to run as a java application is shows below dialog. Please help me.I tried all in google for how to run spring project but i can't understand.Please tell me how to do?
Assuming you have added tomcat to your eclipse.
If your project is pure java project then it will not show you the run on server option in eclipe. You need to change project facet and add dynamic web module to it then you can run it on tomcat server from eclipse.Basically project needs to be web project.
After doing above if it gives error or do not run properly, check your project deployment assembly and add projects webapps folder in eclipse.
you need to have a tomcat installed in your eclipse and run it on the server.
Here is a tutorial to do this
You need to install the Web Tools Platform, which has support for the usual Web-application tools.

How to remove reference of a jar file in a java based web application?

I have a java based web application, which has certain java files and due to some need, i have added some jar files with in the project and made it project specific.
Now, While deploying them in production, I see, that the web file server (tomcat6) already has those jar files in its global library. Now, How do i remove reference of that jar file it, with out disturbing my code(which is working fine).
I saw in other article saying we just have to change the build path to refer the global library instead of local library.
Finally I have 2 questions.
How to do this?
If i'm working on windows and using path while configuring the build path, will it not be a problem if i deploy it in Unix environment.?
Please suggest. Also, its the problem with servlet-api.jar.
I use eclipse IDE. So how to perform these changes in eclipse?
Open your web project in eclipse and right click on the project. click on Properties and then choose build path and remove the jars you want to remove under the tab 'Libraries' and then export the war and deploy it in your tomcat6 server. if you want to run your web application in eclipse, you have to configure the server libraries by clicking 'Add Library' button in build path and then choose server runtime and choose the tomcat6 server configured in eclipse. Hope this helps

Categories