• Configuring JSW + embedded Jetty with JMX

    I thought I’d share this knowledge that I’ve learned while migrating our project to be distributed in a Jetty bundle JMX (see java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/)

    I’ve summarized this into the following steps:

    1. You must have a jetty-jmx.xml file with the following configuration:

    <?xml version="1.0"?>
    <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
    <Configure id="Server" class="org.mortbay.jetty.Server">
        <!– =========================================================== –>
        <!– Initialize an mbean server                                  –>
        <!– =========================================================== –>
        <!– Use the jdk 1.5 platformMBeanServer –>
        <Call id="MBeanServer" class="java.lang.management.ManagementFactory" name="getPlatformMBeanServer"/>
      
        <!– =========================================================== –>
        <!– Initialize the Jetty MBean container                        –>
        <!– =========================================================== –>
        <Get id="Container" name="container">
          <Call name="addEventListener">
            <Arg>
              <New class="org.mortbay.management.MBeanContainer">
                <Arg><Ref id="MBeanServer"/></Arg>
                <!– If using < jdk1.5 uncomment to start http adaptor –>
                <!– Set name="managementPort">8082</Set –>
                <Call name="start" />
              </New>
            </Arg>
          </Call>
        </Get>   
    </Configure> 

    2. In your wrapper.conf file, add the jetty-jmx.xml file in the Application Parameters section like the following:

    wrapper.app.parameter.1=org.mortbay.start.Main
    wrapper.app.parameter.2=[PATH_TO_JETTY_CONFIG]/jetty-jmx.xml
    wrapper.app.parameter.3=[PATH_TO_JETTY_CONFIG]/jetty.xml

    3. Add  also the following in the Java Additional Parameters section of the wrapper.conf:

    wrapper.java.additional.7=-Dcom.sun.management.jmxremote.ssl=false
    wrapper.java.additional.8=-Dcom.sun.management.jmxremote.authenticate=false
    wrapper.java.additional.9=-Dcom.sun.management.jmxremote.port=9999

    4. Start the Jetty bundle by invoking the startup script for the JSW.

    5. To see if JMX was enabled, use jconsole to connect. In jconsole, create a new connection and in the Advanced tab, provide the following JMX url then click Connect:

    service:jmx:rmi:///jndi/rmi://127.0.0.1:9999/jmxrmi

    After step 4, you should be able to see the Memory, Threads, Classes and MBeans info of your application.

     

    Specifics for the tools used above:

    • appassembler-maven-plugin 1.0-beta-2
    • java 1.5.0_11
    • jetty 6.1.11
    • jsw 3.2.3 

     

     

  • Continuum 1.3.1 (Alpha) now released!

    Continuum 1.3.1 (Alpha) has been officially released today! Although this is just an alpha release, there’s a vast amount of new features (in it’s initial implementation) to look out for as can be seen in the release notes below:

    Release Notes - Continuum - Version 1.3.1

    ** Sub-task
        * [CONTINUUM-2023] - Document usage of parallel builds

    ** Bug
        * [CONTINUUM-1513] - Release does not work when maven 2 executable is not on PATH
        * [CONTINUUM-1978] - regression from 1.1 to 1.2.2: Add Maven 2.0+ Project using https POM Url where the source server has self signed certificate
        * [CONTINUUM-1981] - Error while using Windows domain in username when adding a M2 project
        * [CONTINUUM-1984] - Dead link to data-management-cli-1.2-app.jar in upgrade documentation
        * [CONTINUUM-1988] - Cannot build project if triggered from Project Information page
        * [CONTINUUM-1998] - Unable to delete a user
        * [CONTINUUM-1999] - Missing validation error message for duplicate project group
        * [CONTINUUM-2008] - Creating or Editing  "build definition" and "build definition template" generates javascript error
        * [CONTINUUM-2017] - Unable to add build definitions to a template
        * [CONTINUUM-2021] - NullPointerException when sending mail notification
        * [CONTINUUM-2030] - Show Users in Role paging not working
        * [CONTINUUM-2035] - Unable to release when Distributed Build is enabled
        * [CONTINUUM-2040] - NPE encountered when building a project migrated from an old database

    ** Improvement
        * [CONTINUUM-1829] - separate transient errors from build failures in notification and display
        * [CONTINUUM-1864] - Transient State
        * [CONTINUUM-1884] - Clicking ‘Done’ after a successful release perform sends you all the way out to the list of groups
        * [CONTINUUM-1962] - Migrate to Struts 2
        * [CONTINUUM-1969] - Externalize all strings and make continuum fully localizable.
        * [CONTINUUM-2010] - Add group cancel build
        * [CONTINUUM-2013] - Database migration tool for migration from 1.2.x to 1.3.x

    ** New Feature
        * [CONTINUUM-265] - Concurrent builds
        * [CONTINUUM-1666] - Distributed Builds

    ** Task
        * [CONTINUUM-1990] - Unable to publish website from 1.3.0 tag
        * [CONTINUUM-2024] - Upgrade httpclient to 4.0beta2

    ** Wish
        * [CONTINUUM-1635] - Manage configurable number of parallel build queues

    BTW, the release can be obtained here: http://continuum.apache.org/download.html

    Enjoy!

     

  • BarCampApache @ApacheCon US 2008

    For the first time in Apache Con history, Apache will be hosting a bar camp! Visit http://barcamp.pbwiki.com/BarCampApache for more details :)

  • Archiva @ApacheCon US 2008

     

    I was given a chance to do a fast feather talk about Archiva at the ApacheCon US 2008 on Wednesday Nov. 5, 3pm at the Sheraton Hotel in New Orleans. See you there!

  • Generating RSS Feeds with Rome

    Want to have RSS feeds in your Java application? Try Rome..

    "Rome is an open source library for generating, parsing and manipulating RSS and Atom feeds. It supports different RSS and Atom feed formats such as Atom 0.3, and Atom 1.0, RSS 0.90, RSS 0.91 Netscape, RSS 0.91 Userland, RSS 0.92, RSS 0.93, RSS 0.94, RSS 1.0 and RSS 2.0."

    A couple months back, I got to use the Rome library to implement RSS in Archiva. What I liked about Rome is how it’s so easy to understand and use. To generate an RSS feed, you basically just need to be familiar with these three classes: SyndFeed, SyndEntry and SyndContent. These three are Java interfaces with the following concrete implementations: SyndFeedImpl, SyndEntryImpl and SyndContentImpl respectively. Here’s a short example on how you can generate a RSS 2.0 feed:

    SyndFeed feed = new SyndFeedImpl(); // create the feed
    Date publishDate = new Date( System.currentTimeMillis() );

    feed.setTitle( "Techblog.ph RSS Feeds" );
    feed.setDescription( "RSS feeds of blog entries from Techblog.ph" );
    feed.setLanguage( "en-us" );
    feed.setPublishedDate( publishDate );
    feed.setFeedType( "rss_2.0" ); // set the type of your feed

    List<SyndEntry> entries = new ArrayList<SyndEntry>();

    SyndEntry entry = new SyndEntryImpl(); // create a feed entry
    entry.setTitle( "Generating RSS Feeds with Rome" );
    entry.setPublishedDate( publishDate );

    SyndContent content = new SyndContentImpl(); // create the content of your entry
    content.setType( "text/plain" );
    content.setValue( "Want to have RSS feeds in your Java application? Try Rome….." );

    entry.setDescription( content );
    entries.add( entry );
    feed.setEntries( entries ); // you can add multiple entries in your feed

    For the published date, make sure that you update it whenever you have a new entry and publish the feed so that the reader knows there were changes/updates in your feed.

    Now, to publish your feed.. you can write it into a file (example, write it to rss.xml) which the feed reader checks for updates or you can generate the feed by request (like how it is done in Archiva). If you are publishing your feeds by writing it on a file, you might need to read the file into a SyndFeed before adding new entries as shown below:

    SyndFeedInput input = new SyndFeedInput();
    SyndFeed feed = input.build( new XmlReader( outputFile ) );

    To learn more about the Rome library, check out the Rome API.

  • Maven @ the POSS

     

     Last June 23-24, the Philippine Open Source Summit (POSS) was held in Cebu and I got to do a technical session about Maven. For those who didn’t get to attend, here’s a short summary of what was presented and discussed in the session =) 

     

    1. What is Maven?
      • It is a software project management and comprehension tool that can manage a project’s build, reporting and documentation from a central piece of information.
    2. Before Maven was around you need to..
      • Compile your project (dependencies, source classes)
      • Package your project
      • Test your project
      • Document your project
      • Deploy/publish your project
    3. Life with Maven.. Maven does it ALL!
      • Building a project with Maven is demonstrated (from compiling your project up to deployment), showing the Maven build life cycle.
      • A diagram of how Maven works
    4. Definition of Terms:
      • Repository (remote and local) - where artifacts are contained
      • Artifact - a jar, war, ear, zip, tar, etc. file
      • POM (Project Object Model) - the central piece of information; xml configuration file where all info (build, reporting, resources, etc.) regarding the project is located
      • Dependency - an artifact which is needed by your project in order to build or run it
      • Build - steps for preparing your project for deployment (compile, test, package, deploy, etc.)
    5. The Power of Maven (reference: maven.apache.org/maven-features.html)
      • Simple project setup that follows best practices
      • Consistent usage across all projects means no ramp up time for new developers coming onto a project
      • Superior dependency management
      • Support for multi-module projects
      • Extensible (you can create your own plugins!)
      • Coherent site of project information
      • Release management and distribution publication
    6. Related Tools:
      • Apache Archiva – Build Artifact Repository Manager
      • Apache Continuum – Continuous Integration Server
    7. Features of Archiva:
      • can be used as proxy cache of artifacts
      • manage repositories (deploy/upload artifacts, search, cleanup)
      • provides reports (repository health)
      • security (for your repositories)
    8. Features of Continuum:
      • scheduled builds (m2, m1, ant and shell projects)
      • build notification (mail, irc, IM clients)
      • has support for build environments
      • web UI for releasing a project
      • security (across project groups)
    9. Resources:

     

  • Interested in Open Source Software Development? Here’s How You Can Get Involved..

    Below are some pointers which I think can be a starting point for people who want to get involved or contribute in open source software development Smile These are just based on my personal experience and nothing formal.. 

    1. The usual jumping point here are those technologies that you’re already using. There might be a bug or a feature you want fixed or added, or you’re just basically interested in the project.

    2. Start reading the project documentation. This is available on the project’s site or wiki.

    3. Subscribe to the project’s mailing lists and start reading up on the discussions happening. You could also join the official IRC channel of the project and be able to see what’s happening there. Don’t be intimidated in participating in discussions, the community would value your opinion Smile

    3. Checkout the source code, browse through it and familiarize yourself.

    4. Take a look at the issues in the project’s bug tracking system and look for things which you’d like to work on. Don’t be afraid to ask for directions or help in the dev list if you’re working on a bug fix. And if you’re working on a new feature for the project, make sure to involve the community in your design. You could do this  by starting a thread in the developer’s mailing list. 

    5. Implement the fix or design of the feature that was agreed on between you and the community in #4 (Don’t forget to write unit tests!).

    6. After you’ve finished the fix, create a patch and submit it (may be by attaching it to the issue or mailing it to the dev list). 

    **Note: Be aware of the guidelines and conventions of the community regarding patches. These are usually listed on the project site.

    7. Notify the dev list that you have submitted a patch for the issue so that they could apply it.

    8. Get involved continuously. 

    That’s about it Smile Looking forward to seeing more contributors in the open source community!