What is the Difference Between IIS and Tomcat?

Tomcat is known most popular open-source Java server, you can easily deploy in any server or a Linux machine. While  we need to pay for licensing for IIS to deploy on a windows machine.

Deploying an internet server isn’t a one step deal. You would need to install a couple of servers that handle different aspects of a web server. The first one that you would need to install is the HTTP server. IIS (Internet Information Services) is a web server developed by Microsoft and a good choice for most people who are already comfortable with using Windows. Tomcat is another server, but it isn’t meant to process HTML documents, it is intended to run Java and JSP applications. The tomcat was developed by Apache as a Java/JSP server. It is developed primarily to communicate with Apache’s own web server but it is also compatible with IIS or any other web server available.

How to Set Up a Hot Code Replacement with Tomcat and Eclipse

This blog post will guide you through setting up Tomcat hot code replacement (also called hotswap debugging) in Eclipse.

  • What Is “Hot Code Replace”?
  • What’s the Catch?
  • What About JavaRebel?
  • Configuring Your Web Application in Eclipse
    1. Download Eclipse “JEE” Edition
    2. Switch to the “Java EE” Perspective
    3. Configure Your WAR Project
    4. Create a New Server
    5. Magic Setting: Disable “Auto Reloading” on Each Project in the Server
    6. Performance Tip: Adjust Memory Settings
    7. Start Your Tomcat Server in Debug Mode
  • Why Disable Auto Reloading?
  • Disable Auto Reloading but Enable Auto Publishing
  • Finding the tmp0 Fake Tomcat Directory
  • Exorcising the tmp0 Directory
  • Troubleshooting: What Do I Do If I Still Can’t Get It to Work?

What Is “Hot Code Replace”?

Hot Code Replace” (HCR) lets you make modifications to a Java class and see the effect immediately in a running JVM, without restarting your application. HCR is part of the Java Platform Debugger Architecture (JPDA) and is available on all modern JVMs.

Consider this ordinary application:

public class Sample {
  public static void main(String[] args) {
    String foo = "unchangeable";
    foo += blah();

  public static String blah() {
    String bar = "bar";
    bar += "blah";
    return bar;


If you debug this class in Eclipse, you can make changes to it, on the fly, without restarting the JVM. For example, try setting a breakpoint on the second line of blah(). Next, change the literal blah to quz. Save the file and the program will continue running with the new code.

You can do this with Tomcat web applications in Eclipse, but it’s a lot trickier.

What’s the Catch?

There are a few limitations when using hot code replace. You can’t use JPDA HCR to change the signature of a class (add/remove methods or fields) or to add new classes on the fly. Additionally, some method calls (”stack frames”) can’t be modified, including the main method or any method invoked via reflection, that is, by using java.lang.reflect.Method.invoke().

Here’s what happens if you try to replace the unchangeable variable in the main method of Sample.java above.

unchangeable 300x115 How to Set Up Hot Code Replacement with Tomcat and Eclipse

What About JavaRebel?

JavaRebel is a hot code replacement system that’s a little better than JPDA HCR. (Maybe a lot better.)

With JavaRebel you can add/remove methods and classes without restarting Tomcat. However, JavaRebel costs $149 per developer per year, so it may or may not be worthwhile for you.

Configuring Your Web Application in Eclipse

  1. Download Eclipse “JEE” editionMost developers already use this, since it’s the first option available on the Eclipse download page, but if you’re using “Eclipse IDE for Java Developers” (92MB), you’ll need to go back and download “Eclipse IDE for Jave EE Developers” (189MB). It’s worth it, I promise!

    download screenshot 300x188 How to Set Up Hot Code Replacement with Tomcat and Eclipse

    Note: The difference between the regular Java IDE and the Java EE IDE is that the JEE edition comes with the Eclipse “Web Tools Project” (WTP), which includes “Web Server Tools” (WST). The terms are sometimes used interchangeably; keep an eye out for this if you need to search for them.

  2. Switch to the “Java EE” PerspectiveMake sure you’re in the “Java EE” perspective, not the “Java” perspective. If it’s not in the upper-right corner of your Eclipse window, you might need to enable it manually (Window menu -> Open Perspective -> Other…). If “Java EE” doesn’t appear on this list, you’ve probably downloaded the wrong package of Eclipse; go back and download the Java EE version.

    jee screenshot How to Set Up Hot Code Replacement with Tomcat and Eclipse

  3. Configure Your WAR ProjectFrom scratch: From the New menu, select “Dynamic Web Project”. Configure your source and output folders, as well as your “Content directory”, which will contain your JSPs, your WEB-INF directory, etc.

    Via Maven: Use Maven to create a WAR project. For example:

    mvn archetype:create -DarchetypeArtifactId=maven-archetype-webapp -DartifactId=YOURNAMEHERE -DgroupId=YOURNAMEHERE

    Modify your pom.xml to include an explicit reference to maven-eclipse-plugin, like this:

    <!-- ... -->
        <!-- ... -->
            <!-- ... -->
    <!-- ... -->

    Now generate an Eclipse project from the command line, like this:

    mvn eclipse:eclipse

    Here’s an example Maven project you can use. Just download it, extract it, and run mvn eclipse:eclipse to generate your Eclipse project. (If this is your first time using Maven with Eclipse, you’ll also need to add an M2_REPO classpath variable in your Eclipse workspace preferences that points to your Maven repository, typically $HOME/.m2/repository or %USERPROFILE%\.m2\repository.)

  4. Create a New ServerFrom the New menu, select Other… -> Server -> Server. For your server type, expand the “Apache” folder and select the version of Tomcat you intend to use. Choose “Next” and then specify the path to your Tomcat installation directory, e.g. c:\tools\tomcat-6.0. Add your web project as a “resource” to this server.
  5. Magic Setting: Disable “Auto Reloading” on Each Project in the ServerYou now have a weird pseudo-project called “Servers” in your Project Explorer. In the explorer, your server looks like a folder called something like “Tomcat v6.0 Server at localhost-config” …but that’s not what you want. You need to interact with your server using the “Servers” tab. (Eclipse calls these tabs “Views,” but everybody else just calls them “tabs.”)

    The “Servers” tab should be exposed by default, but in case it isn’t, you can expose it via Window -> Show View -> Servers. From there you can double-click on your server to configure it.

    Note that the configuration panel for your server has two tabs, “Overview” and “Modules”, down at the bottom of the window. Click on the “Modules” tab to bring up the list of projects associated with the server.

    Select your project in the list and click on “Edit”. You’ll see the magic secret checkbox: “Auto reloading enabled”. It’s checked by default. For the love of Pete, uncheck it!

    (It’s interesting to note that JavaRebel also requires disabling auto reloading to work properly in Eclipse.)

    magic checkbox screenshot 300x216 How to Set Up Hot Code Replacement with Tomcat and Eclipse

  6. Performance Tip: Adjust Memory SettingsBefore you start up your server, I strongly recommend adjusting your server’s -Xmx memory settings; otherwise, it will constrain itself to the default value, 64 MB, which is just not enough!

    Double-click on your server in the “Servers” tab and switch to the “Overview” tab. Click on the “Open launch configuration” link. Switch to the Arguments tab; there you can add relevant memory settings to the “VM Arguments” section. For example, you might add -Xmx512m to the end of the existing arguments.

    memory screenshot 300x273 How to Set Up Hot Code Replacement with Tomcat and Eclipse

  7. Start Your Tomcat Server in Debug ModeNow you can right-click on the Server in your Servers tab and choose “Debug”. Changes you make to your JSPs or Java classes will be instantly hotswapped into your running WAR.

Why Disable Auto Reloading?

Auto reloading is a feature of Tomcat that allows you to replace Java classes at runtime without using JPDA. In this mode, Tomcat uses Java classloaders to try to unload classes and reload them; whenever it reloads, it also tries to reinitialize your application, re-launching any servlets that are marked load-on-startup in your web.xml file.

As a result, Tomcat auto reloading may not save you any time at all if your webapp has a lot of startup code. For example, if your load-on-startup code needs to warm up Hibernate database caches, Spring/Guice dependency injection configuration, etc., it may take almost as long to restart your webapp as it does to restart Tomcat.

Worse, an app that has been auto reloaded can behave strangely, and can quickly run out of PermGen memory due to frequent unloading/reloading of classes. When this happens, restarting Tomcat typically fixes the problem. If you spend even five minutes investigating a weird auto reloading problem, you’ve just wasted all the time you were hoping to save by avoiding a restart. (Not to mention your stress and frustration!)

By disabling auto reloading and using JPDA hot code replace instead, you get a more reliable code replacement system.

Disable Auto Reloading but Enable Auto Publishing

In the screenshot above you can see how to disable auto reloading on the “Modules” tab of the Tomcat server; auto reloading is bad for JPDA debugging. But there’s another setting called “Automatically publish when resources change” on the “Overview” tab of the Tomcat server. It’s hidden by default, collapsed under the “Publishing” section. You can see it if you expand that section; you want to make sure auto publishing is enabled while auto reloading is disabled.

autopublish screenshot 300x205 How to Set Up Hot Code Replacement with Tomcat and Eclipse

To understand the difference between auto publishing and auto reloading, we’ll have to go into how exactly Eclipse WTP works. When you create a “Server” in Eclipse, the IDE creates a fake Tomcat directory, complete with the conf, logs, temp, webapps and work directories. When you configured the server, you told Eclipse where to find Tomcat, but it doesn’t use any of your settings files or any data from your webapps directory. Instead, Eclipse launches Tomcat with special command-line arguments, indicating where to find the fake Tomcat directory.

“Publishing” means to populate the fake Tomcat directory with all of your code. It copies your JSPs, JARs up your Java, regenerates settings files, etc.

If you turn off auto publishing, then you have to right-click on your Server and “Publish” your changes manually every time you save your Java code. Additionally, auto publishing allows Tomcat to reload JSPs automatically, regardless of whether you use JPDA or not.

server menu screenshot 300x279 How to Set Up Hot Code Replacement with Tomcat and Eclipse

Finding the tmp0 Fake Tomcat Directory

Sometimes it can be helpful to look inside the fake Tomcat directory and see what’s going on in there. Eclipse tells you where it put the Tomcat directory in the “Server Locations” section of your “Tomcat” server configuration panel. (Double-click on your Server in the “Servers” tab to open the configuration panel.) Typically, Eclipse says that your server is in .metadata/.plugins/org.eclipse.wst.server.core/tmp0; for this reason I typically call it the tmp0 directory (pronounced “tempo”).

The .metadata folder is inside your Eclipse workspace directory. (You can find your Eclipse workspace directory by going to File -> Switch Workspace; the default value is your current workspace directory.) In the worst case, you can always just search your hard drive for tmp0. It’s there somewhere!

Inside, you can see all the folders Eclipse has created. Check out the generated server.xml file in tmp0/conf. Examine generated .java files in tmp0/work. Your tmp0/webapps directory is probably empty; Eclipse has probably generated your webapp in wtpwebapps.

Exorcising the tmp0 Directory

Unfortunately, sometimes Eclipse gets a little confused about what to put in your WAR file, and you need to perform various stages of exorcism depending on how badly your tmp0 directory is messed up.

  • Try republishing your tmp0 directory. Open the “Servers” tab, right-click on your server and select “Clean…” (not “Clean Tomcat Work Directory…”). Then select “Publish.” That should completely rebuild your tmp0 directory.
  • Try restarting Eclipse. This works more often than I’d like to admit.
  • Try completely deleting and recreating your server. Follow this ritual:
    1. Open the “Servers” tab, right-click on the server and select “Delete”.
    2. Make sure “Delete unused server configuration(s)” is checked, then click OK.
    3. Look at your “Servers” pseudo-project; make sure the folder for your server is gone. If it isn’t, right-click on it and Delete it.
    4. Quit Eclipse.
    5. Go find your tmp0 directory (if it’s still present) and delete it from your file system.
    6. Launch Eclipse and recreate your server from scratch.
  • Try creating a new workspace. File -> Switch Workspaces: specify an empty directory. Create your server from scratch.

Troubleshooting: What Do I Do If I Still Can’t Get It to Work?

  • My project works in regular Tomcat, but doesn’t work in Tomcat under EclipseTry using Eclipse to generate a WAR file for Tomcat. Right-click on your web project and select Export -> WAR file, and install it in Tomcat by dropping the exported WAR into your Tomcat webapps directory.

    If the exported WAR file doesn’t work, then you now have two WARs: one working WAR generated by your build script, and one non-working WAR generated by Eclipse. WAR files are just zips; extract them both, find the difference, and fix it! Right-click on your web project and select “Properties”. The problem is somewhere in here.

    On the other hand, if the exported WAR file does work, then you know that the problem has to do with the way Eclipse is launching Tomcat. Find your tmp0 directory (described above) and poke around. Does everything look OK in there? Be sure to check your server.xml file, as well as your webapp itself in wtpwebapps. Make sure to note your WEB-INF/lib directory, typically in tmp0/wtpwebapps/YOURAPP/WEB-INF/lib.

  • Tomcat is throwing NoClassDefFoundError or ClassNotFoundExceptionFirst, double-check whether this problem happens in regular Tomcat. See My project works in regular Tomcat, but doesn’t work in Tomcat under Eclipse above.

    If this problem occurs in the exported WAR file under regular Tomcat, then your webapp is probably missing JARs. See My exported WAR is missing JARs below.

    If the exported WAR works but your webapp is still broken under Tomcat, you may need to perform an exorcism. (See Exorcising the tmp0 Directory above.) If this happens to you often, double-check that you haven’t accidentally disabled auto publishing. (See Disable Auto Reloading but Enable Auto Publishing above.)

  • My exported WAR is missing JARsRight-click on your web project and select “Properties.” The problem is somewhere in here. Make sure you see your JAR listed under “Java Build Path” in the Properties dialog.

    Beware: not every JAR in “Java Build Path” gets exported to the WAR. The list of JARs for the WAR is under “Java EE Module Dependencies.” If a JAR/project is unchecked on that list, it won’t appear in your WAR file.

  • My tmp0 directory is missing an important configuration fileEclipse will publish files that it finds in the “Tomcat” folder of the “Servers” pseudo-project to your tmp0/conf directory; if you’re missing files, you can add them here.
  • My server.xml file is messed upThat file is copied from the “Tomcat” folder in your “Servers” pseudo-project to your tmp0/conf directory. But note that the server.xml file is at least partially autogenerated by Eclipse. If you make direct changes to the file, Eclipse will do its best to try to incorporate your changes, but it often gets confused and does the wrong thing. When possible, it’s better to find the appropriate Eclipse settings and change them there instead of modifying the server.xml file directly.

    Note that one of the most common problems with server.xml is an incorrect path attribute on your webapp’s <Context> element, causing your webapp to appear on a non-standard URL. See the following question about 404 errors for more details about this problem.

  • Tomcat is giving me strange 404 errorsFirst, double-check whether this problem happens in regular Tomcat. (See My project works in regular Tomcat, but doesn’t work in Tomcat under Eclipse) If it happens in regular Tomcat too, then it’s probably a bug in your code.

    If the problem only happens in Eclipse, then it’s probably a server.xml configuration problem. Check your tmp0/conf/server.xml file’s <Context> element; check the path attribute. The path attribute indicates the virtual directory of your webapp. For example, if your Context/path is “examplePath”, then your webapp will appear at http://localhost:8080/examplePath. If it’s misconfigured, your webapp may not be available at the URL you expect.

    The path attribute is auto-generated based on settings in the properties of your WAR project. Right-click on your web project, select “Properties” and go to the “Web Project Settings” section. There’s only one setting here; it’s called “Context root”. Specify the context you intend to use here. If you want your project to appear in the root directory, you’ll need to put / as your context root (since you aren’t allowed to leave it blank).

    context root screenshot 300x272 How to Set Up Hot Code Replacement with Tomcat and Eclipse

  • Tomcat times out when starting under Eclipse (”Server […] was unable to start within 45 seconds”)The Eclipse developers, in their infinite wisdom, have added a timeout to Tomcat startup. If Tomcat doesn’t declare a successful startup in 45 seconds, it kills Tomcat automatically. (Gee, thanks, guys!)

    You can increase that timeout. Open the “Servers” tab and double-clicking on your server to open the server configuration panel. Make sure the panel’s “Overview” tab is selected. Expand the “Timeouts” section and increase the Start timeout to something reasonable for your server.

  • I had Tomcat working under Eclipse, but now it’s broken and I can’t figure out whyYou may need to perform an exorcism. (See Exorcising the tmp0 Directory above.)
  • My web project starts up fine, but when I save .java files in Eclipse, it doesn’t take effect until I restart
    • Did you make sure to launch the server in Debug mode, as opposed to Run mode? JPDA only works when you Debug the server.
    • Is your server configured to auto publish? (See Disable auto reloading but Enable auto publishing above.)
    • Did you change something that broke JPDA? (See What’s the catch? above.) If you make large changes to your classes, JPDA may be unable to replace the code; if you choose to “Continue” past that point, further changes will have no effect.
  • My web project starts up fine, but when I save .jsp files in Eclipse, it doesn’t take effect until I restartThis is typically due to disabled auto publishing. Double-check that your server is configured to auto publish. (See Disable auto reloading but Enable auto publishing above.)

    If that doesn’t work, examine your tmp0 directory to make sure Tomcat is using the correct JSP. It should automatically begin consuming new JSPs as they are installed in the tmp0/wtpwebapps directory.

  • Whenever I save a .java file in Eclipse, Tomcat restartsThis is typically due to Tomcat auto reloading. Double-check that you correctly disabled auto reloading. (See Magic Setting above.)
  • Tomcat in Eclipse is much slower than regular TomcatTry increasing your memory settings as described above, if you haven’t already.

    Try running Tomcat in “Run” mode (as opposed to “Debug”) mode. If that fixes the problem, then there may be nothing you can do about it. JPDA does have some overhead; you can turn it off, but while you’ve turned it off you won’t have access to hot code replacement.

Installation and configuration of JAX-WS (Metro) on Tomcat 6

Well, it’s been a busy few days.  After getting my local copy of tomcat to run webservices deployed by IntelliJ I set about trying to get Tomcat 6 working on the server.  It took a lot longer than it should have; there are posts all over the web showing pieces of the configuration process but I wasn’t able to find anywhere with a detailed list of instructions that didn’t assume the user had already done this before.  Here’s the process I went through.

  1. Install Tomcat 6.  Basically this involves grabbing the latest tarball from http://tomcat.apache.org/ , unpacking it, and putting the resulting directory wherever you see fit.  I installed to /usr/share/tomcat
  2. Install Metro.  This can be obtained from https://metro.dev.java.net/ .  It’s only distributed in jar format, so you have to run ‘java -jar metrojarname.jar -console’ to unpack the files.  The -console flag is very important if you’re running a headless server; why it’s required for an unpack operation in the first place is beyond me.  I placed the resulting directory in /usr/share/metro
  3. Edit the conf/catalina.properties file in your tomcat installation.  The line saying ‘shared.loader=' should be changed to 'shared.loader=/usr/share/metro/lib/*.jar' , depending on wherever you installed Metro to.
  4. Set the CATALINA_HOME environment variable to match your tomcat installation.  This can be done with ‘export CATALINA_HOME=/usr/share/tomcat’
  5. Run the installation script in the metro directory.  This can be done by ‘ant -f metro-on-tomcat.xml’
  6. Done!  This seems really easy once you’ve gone through the process, but figuring it out in the first place was complicated.

Tomcat seems to start faster and is more responsive than our previous Glassfish installation.  Some of Glassfish’s management tools would have been nice, but all I really care is that TDZK Fleets is up and running again, and the Glassfish bugs that were slowing down development are no longer an issue.

Problems installing Liferay Source Code 5.2.3 + Tomcat


We are trying to install Liferay Source Code in order to execute it in Tomcat. After following several installation guides, we don’t have obtained any good results.

“ant build” and “ant deploy” commands always finish showing “build succesful” and Tomcat logs don’t show any error when we type ./startup

When we access to localhost:8080/web/guest/home, the browser shows a blank page (don’t show anything) and Tomcat logs show no errors. We have used an existing Tomcat, a new Tomcat into Liferay directory and a new Tomcat out of Liferay directory, and Tomcat versions 5 and 6, and the result is the explained below. So, we think that Liferay is not linked succesfully to Tomcat when we type “ant deploy” command

The only modification we make in Liferay configuration files are in app.server.properties y release.properties, and the copies of these files including the Linux username in the file name

In app. server.properties:
app.server.parent.dir= the folder where we unzipped tomcat (if tomcat is in /opt/tomcat, this property were /opt)
app.server.tomcat.dir=${app.server.parent.dir}/tomcat-5.5.26 (or the adecuate version)

In release.properties:
lp.source.dir=the folder where we unzipped liferay-source-code.zip
lp.ext.dir= ${lp.source.dir}/ext
lp.plugins.dir= the default value, because we don’t know what is the plugins sdk for or if they are needed

Our purpose is to get a Liferay SC installation in order to make some changes in the login portlet and then re-compile Liferay with the new changes. We need to know how to solution these problems or another development alternative

I hope this helps:


Setting Tomcat Heap Size (JVM Heap) in Eclipse. Heap Size Tomcat

Recently while running Tomcat under Eclipse for one of the web application I was getting Java Heap memory related error java.lang.OutOfMemoryError.
What needs to be done here basically is to increase the jvm heap size. So for increasing the JVM Heap Size of Tomcat in Eclipse we have to set few VM arguments of the tomcat.

Follow the simple steps to change the Heap Size of Tomcat under Eclipse.
1. Open the Server tab in Eclipse and double click the Tomcat server to open Server Configuration.

2. In Server Configuration, click on the Launch Configuration link under General Information.

3. Under Arguments tab, add following values in VM arguments.

1.-Xms64m -Xmx256m


Professional Apache Tomcat 6WROX Professional Guides Torrent

Torrent Name: Private torrent Professional Apache Tomcat 6 (WROX Professional Guides)

Alternative: may also Available on rapidshare for Direct download
Category: Categories > Books > Ebooks
Seeds: 0
Leechers: 0
Total Size: 15.35 MB
Downloaded: 26
Number of files: 1 (View Files)
Torrent added: 2008-08-27 16:06:21
Last Updated: 2009-10-10 03:03:49 (Update Now)
Tracker: http://www.ebookvortex.com/announce.php
More Torrents: Professional Apache Tomcat 6 (WROX Professional Guides)
Subtitles: Subtitle download

Torrent Description

With this comprehensive resource, you’ll uncover the ins-and-outs of installing, configuring, and running the Apache Tomcat server. This book not only provides a line-by-line analysis of configuration options, but also explores the features and capabilities of Tomcat. You’ll then gain the skills to solve the type of problems that arise during all phases of system administration, including shared hosting, security, system testing, and performance testing and tuning.

Focusing exclusively on Tomcat 6, the book takes you through all of the latest architectural and performance changes. You’ll progress from basic Tomcat and web application configuration to more advanced techniques for clustering, JDBC connectivity, logging, and much more. All of this will help you effectively manage and administer your Tomcat deployment.

What you will learn from this book

* How to install the JVM and Tomcat on Windows and Unix/Linux systems
* Steps for packaging and deploying web applications
* Configuring Tomcat’s internal HTTP protocol stack, including the new APR and NIO Connectors
* Deploying Tomcat with the Apache Web server or Microsoft IIS as the front-end Web servers
* Load balancing and clustering a farm of Tomcat servers
* Ways to install Tomcat in virtual hosting situations
* How to load test web applications deployed in Tomcat
* Monitoring Tomcat servers in real-time by tapping into internally maintained statistics
* Techniques for providing scalability and high availability to web applications
* Performance tips and best practices for Tomcat 6

ISBN: 0471753610
Publisher: Wrox
Date: 13 August, 2007
Author: Vivek Chopra, Sing Li, Jeff Genender

Upload attachment (document) using CXF ( MTOM ) and Tomcat

Upload attachment (document) using CXF ( MTOM ) and Tomcat
Let us now create a resume upload web service using Apache CXF, Spring and Tomcat and consume it. The web service will be used to upload an attachment [resume]. The scenario considered here is a candidate uploading his/her resume and the resume [word document] is retrieved and stored on the server.

Please download the zip file containing both the server and client Maven projects 

We have two Maven projects attached. The first project is the web application deployed on the JEE server with a context cxfupload and the second is the Java client which invokes the web service.

Let us start with the web service interface which is provided below.

01.package com.srack.service;
03.import javax.jws.WebParam;
04.import javax.jws.WebService;
06.import com.srack.dto.Resume;
09.public interface ResumeUploadService {
11. void uploadResume(@WebParam(name = "resume") Resume resume);

The implementation for the above interface is provided by ResumeUploadServiceImpl.java which is partly provided below (the complete source is in the zip attached).

01.package com.srack.service;
03.import java.io.File;
04.import java.io.FileOutputStream;
05.import java.io.IOException;
06.import java.io.InputStream;
07.import java.io.OutputStream;
09.import javax.activation.DataHandler;
10.import javax.jws.WebService;
12.import com.srack.dto.Resume;
14.@WebService(endpointInterface = "com.srack.service.ResumeUploadService",
15. serviceName = "ResumeService")
16.public class ResumeUploadServiceImpl implements ResumeUploadService {
18. public void uploadResume(Resume resume) {

Next comes the CXF configuration file cxf.xml which has the configuration which will be loaded by Spring and used by CXF about the web service. We have mentioned jaxws:properties which enables mtom capability of CXF where in the resume is sent as an attachment giving better performance [by avoiding base 64 encoding].

03. xmlns:jaxws="http://cxf.apache.org/jaxws"
09. <import resource="classpath:META-INF/cxf/cxf.xml" />
10. <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
11. <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
12. <jaxws:endpoint id="uploadresume"
13. implementor="com.srack.service.ResumeUploadServiceImpl"
14. address="/UploadResumeWS">
15. <jaxws:properties>
16. <entry key="mtom-enabled" value="true"/>
17. </jaxws:properties>
18. </jaxws:endpoint>

The web.xml configure the CXF servlet to listen at the desired URL pattern as below.

01.<?xml version="1.0"?>
02.<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
06. <display-name>ResumeUpload</display-name>
07. <context-param>
08. <param-name>contextConfigLocation</param-name>
09. <param-value>classpath:cxf.xml</param-value>
10. </context-param>
11. <listener>
12. <listener-class>
13. org.springframework.web.context.ContextLoaderListener
14. </listener-class>
15. </listener>
16. <servlet>
17. <servlet-name>CXFServlet</servlet-name>
18. <servlet-class>
19. org.apache.cxf.transport.servlet.CXFServlet
20. </servlet-class>
21. </servlet>
22. <servlet-mapping>
23. <servlet-name>CXFServlet</servlet-name>
24. <url-pattern>/services/*</url-pattern>
25. </servlet-mapping>

Client Application consuming the web services:

Client.java populates values for candidate name, file attachment type, and the resume [which is path to a file] and invokes the web service as below.

01.public static void main(String args[]) throws Exception {
03. JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
05. factory.getInInterceptors().add(new LoggingInInterceptor());
06. factory.getOutInterceptors().add(new LoggingOutInterceptor());
07. factory.setServiceClass(ResumeUploadService.class);
08. factory.setAddress
09. ("http://localhost:8080/cxfupload/services/UploadResumeWS");
10. ResumeUploadService client = (ResumeUploadService) factory.create();
12. Resume resume=new Resume();
13. resume.setCandidateName("CandidateNameXXX");
14. resume.setResumeFileType("doc");
16. DataSource source = new FileDataSource(new File("/home/pathtofile/resume.doc"));
17. resume.setResume(new DataHandler(source));
18. client.uploadResume(resume);
19. System.exit(0);
21. }

Fixing Eclipse Tomcat Timeout « Jump Start

To fix “Server Tomcat was unable to start within 10 seconds. If the server requires more time, try increasing the timeout in the server editor” double click you server in the Servers perspective and increase the timeout value to complete server operations like in the image below.

Picture 3