Understanding the OSGi uses Directive

Engineering | Glyn Normington | October 20, 2008 | ...

If you build an application for the SpringSource dm Server, or any other OSGi platform, you'll probably encounter the uses directive before long. Unless you have a clear understanding of the purpose of the directive, you won't know when to code it and you'll be left guessing when a bundle fails to resolve because of a uses conflict. This article should give you a thorough understanding of the uses directive, when to use it, and how to debug uses conflicts.

Bundle Resolution

OSGi is designed so that once bundles are 'resolved', you shouldn't typically hit class cast exceptions and similar problems due to type…

Optimising and Tuning Apache Tomcat - Part 2

Engineering | Mark Thomas | October 14, 2008 | ...

A few weeks ago Filip Hanik and I gave the second in a series of webinars on Optimising and Tuning Apache Tomcat. A recording of the webinar and a copy of the slides can be obtained from the webinars section of the SpringSource website. The same page has links for all the previous SpringSource webinars, as well as the Covalent webinar archive.

We weren't able to get to all of the questions during the Q&A session so, as promised, here are the remaining questions and our answers.

  • How do you identify memory leaks in a Tomcat application?

    You will almost certainly need to use a profiler to identify the root cause of a memory leak. The latest Sun JDKs include tools like jhat and jmap. There are also many other profilers available, both free and commercial. Filip and I use YourKit when investigating Tomcat memory leaks as YourKit provide free licences to open source developers.

  • How can redeployment cause a memory leak?

    This usually occurs when a class loaded by Tomcat retains a reference to a class loaded by the web application. When the web application is stopped, the Tomcat class loader continues to retain the reference to the class loaded by the web application. This class retains a reference to the web application's class loader which in turn, retains references to all the classes it loaded. Therefore, the web application class loader and all the classes it loaded are not eligible for garbage collection. This causes a memory leak. The typical root causes of this are JDBC drivers and logging frameworks.

  • What is the best way to change the JVM Tomcat uses?

    The JVM to use is set using the JAVA_HOME (full JDK) or JRE_HOME (JRE only) environment variable. The correct place to set this will depend on your environment, particularly if Tomcat is configured to start automatically at system start. If you have a free choice on where to set this then use setenv.bat or setenv.sh as appropriate for your operating system.

  • Do you recommend a particular JVM?

    No, we do not. The JVM vendor you choose depends on your OS.

  • Which connector should I use to connect Apache httpd to Tomcat?

    We recommend mod_proxy_http with mod_jk a close second. Generally, mod_proxy_ajp is less stable than either mod_proxy_http or mod_jk. Note that mod_jk2 has been deprecated and should no longer be used.

  • What is the correct setting for maxKeepAliveRequests when using SSL?

    When using SSL HTTP keep alive should be enabled as the SSL handshake is a relatively expensive operation to perform for every request.

  • If we run Tomcat on Solaris, do you recommend against using the native APR connector?

    Yes, we do. The feedback we have received from clients is that the APR connector is not stable on Solaris.

  • We previously tried moving to mod_proxy_http on Solaris but we encountered several bugs. Have these bugs been resolved?

    Without knowing the exact bugs or version you were using, it is difficult to comment. All known Apache httpd issues and the current status can be found in the ASF Bugzilla Database. Tomcat issues can also be found in Bugzilla.

  • What value should I use for maxKeepAliveRequests with the default blocking IO HTTP connector?

    For high concurrency environments, set it to 1. Otherwise, set it to the average number of objects you have on a page, anywhere between 10 and 100.

  • How do I configure JkOptions +DisableReuse?

    JkOptions +DisableReuse should be placed in your httpd.conf file with your other mod_jk settings.

  • When is it best to use the bon-blocking IO HTTP connector?

    When you need to support high concurrency with keep alive and APR is not an option, e.g. because it is unstable on your platform.

  • Will I see better performance if I use Apache httpd in front of Apache Tomcat?

    It depends. If you proxy all of the requests to Tomcat then performance will decrease slightly. If httpd handles some requests (eg all the static content) then you will probably see some benefit. There are a number of benchmarks that attempt to demonstrate that one connector is better than another. However, it is very unlikely that any of these benchmarks will be representative of your application. The only way to know for sure is to test it in your environment with realistic load and usage patterns.

  • Can Tomcat be used in production without a web server in front of it?

    Yes. Whether this offers the best performance for your environment will depend on that environment and your application. As with the previous question, the only way to know for sure is to test it in your environment with realistic load and usage patterns.

  • Will using Apache httpd in front of Tomcat increase security?

    The security of your installation will depend on many factors. The use, or not, of Apache httpd is unlikely to significantly change the security of your installation. Other factors such as keep up to date with patches and using a firewall usually have a much greater impact on your overall level of security.

  • Which Apache httpd MPM provides the best performance?

    As always, it will depend on your environment but the httpd performance tuning documentation offers some useful general guidance.

  • What is the performance difference between SpringSource ERS and Apache Tomcat?

    SpringSource ERS is much more than just Apache Tomcat. From a pure Tomcat perspective, performance isn't the differentiating factor. The benefits of ERS are the simple installation, the easy to manage upgrades and patching, support for multiple instances and the integration of all of the components.

  • My company uses Tomcat and XYZ application server. How does Tomcat compare to XYZ application server and are there benefits in consolidating?

    There will be lots of differences and the differences that matter will vary from organisation to organisation. Start by working out what you want from an application server and then compare that list to the market. There are benefits in consolidating. Greater consistency means simpler maintenance, less training and so on. However, there are also costs. You would need to look at your organisation and how it planned to consolidate (new projects only, all projects for next major release, everything now, etc) to compare the costs with the associated benefit.

  • Do you have performance comparisons available for Tomcat and XYZ application server?

    Various reports have been published in this area. How useful the results are depends on how well matches the test is to your load. As always, the only way to know for sure is to test in your environment with realistic load and usage patterns.

  • What is a good method for load testing a Tomcat server?

    There are several options available with tools that drive load, both free and commercial. The free tools include ab and JMeter.

  • For high availability and performance, can Tomcat be configured to launch multiple JVMs for the same web application?

    Tomcat does not provide this as a configuration option. You can, of course, create multiple Tomcat instances, install your application on each instance and then load-balance across the instances.

  • Is there a generic health-check script for Tomcat?

    The Manager status page is probably a good place to start. You can use the code for that Servlet as the basis for your own, more specific/extensive checks if required. If you do enhance it, consider contributing your enhancements back to the Apache Tomcat community.

  • Where is the logging.properties file located?

    The default location is in $CATALINA_BASE/conf.

A Question of Balance: Tuning the Maintenance Policy

Engineering | Rod Johnson | October 07, 2008 | ...

Running a business is like writing code in at least one respect: You don't always get it right the first time, even if you know what you want to achieve—but you do get a better result in the end if you are prepared to rework things when necessary. At SpringSource, we had a clear vision for our recently announced maintenance policy: balancing the needs of the open source community with those of enterprise users and the creators of Spring, for the benefit of all. However, we didn't get the balance quite right first time, and it's time for some refactoring.

Over the last couple of weeks, I've…

The Common Service Locator library

Engineering | Mark Pollack | October 03, 2008 | ...

The CommonServiceLocator project was released this week on CodePlex with the general idea of providing an IoC container agnostic API for resolving dependencies using Service Location. Erich Eichinger from SpringSource contributed the Spring.NET implementation, thanks Erich!

Here is the API so you get the basic idea public interface IServiceLocator : System.IServiceProvider {

object GetInstance(Type serviceType); object GetInstance(Type serviceType, string key); IEnumerable GetAllInstances(Type serviceType); TService GetInstance(); TService GetInstance(string key); IEnumerable GetAllInstances(); } …

SpringSource dm Server 1.0.0 reaches GA

Engineering | Peter Cooper-Ellis | September 30, 2008 | ...

You may have noticed that SpringSource announced the general availability of the SpringSource dm Server™ today. The dm Server is part of the SpringSource Application Platform. Since this is the first time out for the dm Server, I want to make a couple of short comments about the product.

We believe that the dm Server overall will change the way enterprise Java software is developed and deployed. In particular, the dm Server is designed from the ground up, to be lightweight (the dm Kernel has a footprint of about 3 megabytes), flexible, and fast. It is also designed to facilitate modular…

SpringSource Seminar Day Linz in Review

Engineering | Juergen Hoeller | September 23, 2008 | ...

A brief pictorial review of the SpringSource Seminar Day in Linz, having happened on September 8th, 2008, at the Bergschloessl Linz... More than 150 people were listening to a six-pack of presentations about what's new and upcoming at SpringSource. The "Story of Spring" keynote by Rod Johnson and Adrian Colyer was a great start into a day full of information: about the SpringSource Application Platform, the SpringSource Tool Suite, Spring 3.0, etc. (See the original blog announcement for details on the agenda.)

It was a pleasure to see so many people attending: from Austria as well as from Germany and Eastern Europe - and even from Norway! I hope you enjoyed the seminar and your stay in Upper Austria. Looking forward to seeing you again at the SpringOne Europe 2009 conference in Amsterdam, April 27-29... as well as at upcoming EJUG Austria

SpringSource (and other top vendors) leading the OSGi charge

Engineering | Adrian Colyer | September 17, 2008 | ...

In a press release made available by the OSGi Alliance yesterday, several leading vendors including SpringSource, IBM, Oracle, RedHat, Sun, SAP, ProSyst, and Paremus joined forces in their support of OSGi as the foundation for next generation server platforms.

To highlight some of the key points:

Craig Hayman, VP IBM WebSphere said

[IBM] has been shipping WebSphere Application Server built on OSGi since 2006. As a result, IBM clients benefit from a modular platform built with proven components and the ability to automatically use only the components required by their application.
Steven G. Harris, SVP of Development at Oracle said
Oracle WebLogic Server is a great example of the customer benefits of modularization, with its reduced footprint, improved startup time, and flexible configuration options. OSGi technology provides the standards based foundation...
Sacha Labourey, VP of Engineering for RedHat's middleware business said
Running OSGi technology in JBoss Enterprise Middleware Solutions enables our customers to deliver safer services and applications in a more dynamic runtime environment.
Tom Kincaid, Executive Director of Application Platforms at Sun Microsystems said
Sun has seen strong demand for OSGi technology within the GlassFish community. The GlassFish community will be able to take advantage of the modularity and dynamic extensibility implemented via an OSGi-technology based microkernel in the upcoming GlassFish v3 Prelude Release.
What all of the vendors quoted in the release have in common, including SpringSource, is that they build their server platforms on top of OSGi. This has the potential to deliver a set of benefits to users of those platforms including more modular server structures with the ability to run in a smaller footprint and to dynamically alter server characteristics and capabilities.

You need to look a bit harder at the various vendor offerings to determine to what extent they have been able to realize those benefits for you as a user. At SpringSource you could say we were "lucky" in this respect. We had the good fortune to be able to design…

SpringSource dm Server 1.0 RC2 Released

Engineering | Rob Harrop | September 11, 2008 | ...

I'm happy to announce the availability of RC2 of the SpringSource dm Server, previously known as the SpringSource Application Platform. This release is feature complete and barring any serious issues will become 1.0 GA in two weeks time.

This release fixes a few critical bugs, upgrades to Tomcat 6.0.18 and updates all code, documentation and supporting materials to reflect the new name.

Due to the renaming of the product, PlatformOsgiBundleXmlWebApplicationContext has been renamed to ServerOsgiBundleXmlWebApplicationContext and moved from the com.springsource.platform.web.dm package to the com.springsource.server.web.dm package. Thus, if you are setting the contextClass for Spring MVC's ContextLoaderListener or DispatcherServlet in web.xml in a Shared Services WAR, be sure to change the fully qualified path to com.springsource.server.web.dm.ServerOsgiBundleXmlWebApplicationContext

Early draft of OSGi Service Platform Release 4.2 specification now available

Engineering | Adrian Colyer | September 01, 2008 | ...

The OSGi Alliance have posted an early draft of release 4.2 of the Service Platform specification.  SpringSource employees are active members of both the Core Platform Expert Group (CPEG) and the Enterprise Expert Group (EEG) within the Alliance. My personal involvement has been largely with the EEG, and particularly with RFC 124 "A Component Model for OSGi".

RFC 124 is a standardization of the core ideas behind Spring Dynamic Modules. If you look at the configuration schema, you'll see that it very closely resembles the "osgi" namespace provided by Spring Dynamic Modules (DM).  RFC 124 takes…

Who is the Chief of the Apache projects?

Engineering | Mark Brewer | August 22, 2008 | ...

The answer is the Apache Software Foundation (ASF), a non-profit, meritocracy-based organization made up of individuals (not companies) who contribute code, bug fixes, answers to user questions, their time, and sometimes even their money to ensure that the software they are delivering addresses real-world requirements, along with being robust, secure, and widely adopted.

ZDNet’s Dana Blankenhorn’s response to Dave Rosenberg’s blog regarding companies selling support for technologies they don’t own or contribute to inspired me to set some things straight about Apache projects and companies that “support�? them. SpringSource which, through its acquisition of Covalent, is a significant contributor to a number of Apache projects. I agree with Dave that vendors who are attempting to monetize open source projects by merely selling “support�? around those technologies, while not contributing to the software, are little more than parasites. Not only do these companies not contribute to the projects, but their lack of involvement results in inferior support, which harms users and, ultimately, the reputation and acceptance of the projects.

In Dana’s post he noted that SpringSource was a “Third Party Support�? provider for Apache projects. SpringSource (and formerly Covalent) is a major ongoing contributor to a number of Apache projects both directly and indirectly. There have been other open source vendors that claimed they “owned�? or “ran�? an Apache project. I am not going to make that same mistake here, since such a claim clearly indicates that the speaker does not truly understand Apache and the way the organization works. The contributions and leadership of Apache projects by SpringSource employees clearly do not fit Dana’s third-party support provider definition, as is evidenced here:

  • SpringSource/Covalent has employed committers on the Apache HTTP server and Tomcat projects nearly from inception – 1998 and 2001, respectively.
  • Many of the Apache HTTP server modules were originally proprietary code developed by Covalent that was contributed to the ASF.
  • SpringSource employees have made more than 75% of the commits on the Apache Tomcat project in the past two years and had the most active committers on the Apache HTTP server project for four years running.
  • ASF Members who are SpringSource employees, are actively involved in leading and mentoring Incubator Projects.

SpringSource’s customers count on us because of our significant, long-standing involvement in the Apache projects and in the actual Foundation itself. We have also been a long-standing and charter sponsor of the ASF as well as its conference – ApacheCon – and even host its annual Members Reception at that conference to honor and thank the individuals who contribute so much to those projects.

SpringSource will never claim to own or run an Apache project, but we will proudly continue to contribute what the Apache Software Foundation values so highly – technical leadership, solid code, bug fixes and support.

Get the Spring newsletter

Thank you!

Get ahead

VMware offers training and certification to turbo-charge your progress.

Learn more

Get support

Spring Runtime offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.

Learn more

Upcoming events

Check out all the upcoming events in the Spring community.

View all