Sunday, November 4, 2012

Sysdeo Eclipse Tomcat Launcher plugin

It support start and stop tomcat in eclipse and also serve up convenience to change tomcat configure file all in eclipse.

Sysdeo Eclipse Tomcat Launcher plugin

1. Install eclipse plugin by .link

Unzip it and put into your eclipse's plugins folder. Restart your eclipse.
But if you want to manage the plugins installed by yourself clearly you can adopt another way. Link plugin to you eclipse.
Take my own eclipse as an example.

a. Get eclipse install directory: C:\JavaIDE\eclipse-jee-juno

b. Create a folder for sysdeo: C:\JavaIDE\eclipse-plugins\sysdeo\eclipse\plugins

c. Put decompressed result into this folder

d. Create sysdeo.link file

    Content of this file:
     path=C:/JavaIDE/eclipse-plugins/sysdeo  

e. Put .link file into C:\JavaIDE\eclipse-jee-juno\links

f. Launch your eclipse

    Seeing these icons on tool bar proves you have been success.

If you want to remove this plugin just remove corresponding .link file. 
In fact, .link file can contain multiple plugins' path like below
path=C:/JavaIDE/eclipse-plugins/sysdeo path=C:/JavaIDE/eclipse-plugins/plugin2 ......
If you remove plugin instead of removing .link file remove the right line.

2. Set tomcat server

Access eclipse's Window --> References, you can find a new item "Tomcat" in left panel.


There are 5 places to change:
  • Tomcat version, which version is your tomcat?
  • Tomcat home, where is your tomcat installed?
  • Context declaration mode, server.xml or context files? The former means configuration will be stored in <Tomcat home>\conf\server.xml file, but if several applications share this tomcat there may be problem because they share this configuration file.Context files means plugin will create a special context xml for each web project. I choose the latter.
  • Tomcat base, where all tomcat configuration files are saved. This fold need to be created. Its location is without restriction. Usually there is a Servers folder under your eclipse workspace if you alreadt have set certain kind of application server in your eclipse. If you have not it doesn't matter just create a new one. Under Servers folder I created a new folder named Tomcat v7.0 Server for my tomcat 7.0. Then I copied conf folder of my tomcat 7.0 into Tomcat v7.0 Server folder. So now Tomcat base is <workspace_dir>\Servers\Tomcat v7.0 Server.
  • Context directory, where the context files are stored? In the current case context directory should be <workspace>\Servers\Tomcat v7.0 Server\conf\Catalina\localhost.
In order to faster future editing server config you can import the Tomcat base as File System in eclipse. Or just refresh Servers folder in Project Explorer if you put Tomcat base inside it.

3. Set web maven project

I will take a maven project as an example to illustrate.

a. Right click your web project --> Properties --> Tomcat


First figure out a few things:
  • Is a Tomcat Project, of course yes unless you don't want tomcat to launch this project.
  • Context name, what name do you want to use to access this project? If you name it gwtmavenapp latter you can access this project by http://localhost:8080/gwtmavenapp. After you do all the settings you can find a new file named gwtmavenapp.xml under <workspace>\Servers\Tomcat v7.0 Server\conf\Catalina\localhost
  • Subdirectory to set as web application root (optional), set as the directory which holds the build result of a java web application. To a standard maven layout there's a folder named <artifactId>-<version> in target folder after build. In this case this is the web application root.

b. Set it as a Tomcat 

c. Apply and OK

d. Click little pussy

No comments:

Post a Comment