Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse on-click deploy to remote Tomcat

Tags:

I've been looking for this all-over the internet and somehow I can't find a easy way to do it.

What I need is really simple and I believe that many of you probably do it already: - I develop Java Web Apps in Eclipse and so does my team; - we have a tomcat7 server running on a Ubuntu machine which works as a centralized Dev environment; - I would like to click a deploy button and send the new data to the server and deploy it (reload it), instead of exporting a war every time and manually upload it to server.

Up till now seems like the only way to do it is with Maven plugin for eclipse, which uses the manager/HTML interface of tomcat.

Problem: I just can't get it to work. But somehow I can't find a simple walk through that explains how to do it. I'm not too experienced with eclipse or Linux but the configuration of local tomcat servers seems pretty straightforward. I don't understand why is so hard to install a remote one.

Could you please help me out by explaining in detail how to do it? Thank you in advance for you patience.

like image 383
dev.pt Avatar asked Jun 22 '13 20:06

dev.pt


People also ask

How do I change Tomcat deploy path in eclipse?

In the opening window, you should see your tomcat installation. double click on that an a new setting page will open. You will see the Server Locations title, you can set it from that place.

Where is Eclipse Tomcat webapps directory?

The location of the web app will be in the . metadata folder inside eclipse workspace (chk server path) and the converted jsp files can be found in location as given below. Thanks.

How do I know if war is deployed in Tomcat?

The definitive way to determine if a war has finished deploying and the webapp has started is to look in the catalina. out log. A message will be logged. In operational terms, Tomcat will respond to a request made to that webapp in various ways depending on how far along it is.


Video Answer


1 Answers

Yes, you can use Tomcat7 Maven Plugin. Here is the steps:

1) Install Maven Integration for Eclipse (m2eclipse) to your eclipse from Eclipse Marketplace etc.

1.1) Navigate to Help -> Eclipse Marketplace and search "Maven Integration for Eclipse".

2) From eclipse, create a maven project.

2.1) Navigate to File -> New -> Project... -> Maven -> Maven Project.

2.2) Click Next (Leave all fields with default).

2.3) Select "maven-archetype-webapp" and click Next.

2.4) Enter arbitrary value on Group Id and Artifact Id. (e.g. "org.myorg" for Groupd Id and "myapp" for Artifact Id) and click Finish. (You will see pom.xml in your project's root.)

3) Edit pom.xml like this: (Replace yourhost below with your hostname or ip address.)

<project ...>   ...   <build>     <plugins>       <plugin>         <groupId>org.apache.tomcat.maven</groupId>         <artifactId>tomcat7-maven-plugin</artifactId>         <version>2.1</version>         <configuration>           <url>http://yourhost:8080/manager/text</url>         </configuration>       </plugin>     </plugins>   </build> </project> 

4) Add following lines to your CATALINA_BASE/conf/tomcat-users.xml and restart your tomcat.

<tomcat-users>   ...   <role rolename="manager-script"/>   <user username="admin" password="" roles="manager-script"/> </tomcat-users> 

5) From eclipse, run tomcat7:redeploy goal.

5.1) Right click your project and navigate to Run As -> "Maven build...".

5.2) Enter tomcat7:redeploy to Goals and click Run.

6) Once you create the run configuration setting above, you can run tomcat7:redeploy goal from Run -> Run Configurations.

Please refer to the following documents for details:

http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Configuring_Manager_Application_Access

http://tomcat.apache.org/maven-plugin-2.1/index.html

http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/plugin-info.html

If you use another user instead of admin with empty password (which is plug-in's default), you need to create %USERPROFILE%.m2\settings.xml and edit pom.xml like below:

%USERPROFILE%.m2\settings.xml:

<settings>   <servers>     <server>       <id>tomcat7</id>       <username>tomcat</username>       <password>tomcat</password>     </server>   </servers> </settings> 

%USERPROFILE% is your home folder. (e.g. C:\Users\yourusername)

pom.xml:

<configuration>   <server>tomcat7</server>   <url>http://localhost:8080/manager/text</url> </configuration> 

Add server tag.

like image 66
Shinichi Kai Avatar answered Oct 13 '22 09:10

Shinichi Kai