Sunday, December 27, 2009

Automating User Registrations with OpenID and Spring Security 3.0 - Part 1

Having a few days of vacation is nice. Besides spending some precious time with my family, it also gave me some time to work on jRecruiter. I upgraded Spring Security to the final 3.0.0 version, which was released just a few days ago.

The upgrade process was relatively painless, though it is not a simple Jar drop-in as the packages of many of the classes changed. But it was fairly straight-forward.

The biggest hassle, was upgrading Jasypt as the latest released version is not playing nice with Spring Security 3.0, yet. But the code is already committed to Jasypt's source code repository, and with minor modifications, I was able to compile a custom version.

But while I was looking through the changes of Spring Security 3, I started reading a little bit more about its support for OpenID.Which then let to the question, whether there is a good use case for OpenID in my home project.

Places where I saw the use of OpenID are:
Here is actually a pretty good blog post regarding OpenID:

http://www.codinghorror.com/blog/archives/001121.html


Security Concerns

Then of course, there are also a few security concerns regarding allowing for OpenID authentication:
 If that's not enough:
Thus, while I probably wouldn't use OpenID for a banking application, I feel it is a nice fit for my home project, it is used by local recruiters to post job postings. Up to this point every account holder had to provide her own username (email) and a password.

None of the information stored by jRecruiter is extremely sensitive and thus, OpenID might actually help improve the user experience of people posting jobs through the system.  Over the past few years I saw a common issue that account holder are unable to remember their password, or even their username (which made me to change over to more of a email-based username approach). Ultimately, there were quite a few duplicate registrations in the past.

An interesting question though is, is it advisable to restrict access to a limited amount of OpenID providers? (Such as myOpenID, Google or Yahoo)

Use Case

Well, this is were things are getting interesting, OpenID does not only define the notion of pure authentication but it can also gives you access to various pieces of your OpenID profile (e.g. first name, last name, email address etc.). This feature seems to vary, though, between providers (Have to see how that works out)

Thus, for jRecruiter I envision the following use case. When a user starts the login process:
  1. she or he has a choice of either loggin in the traditional way using a username/password combination or 
  2. by selecting the OpenID route. 
  3. If the user logs in via OpenID and the authentication succeeds, but the user account within jRecruiter does not exists, yet, then the potential user is redirected to the registration pages and the fields of the registration form shall be pre-populated (as much as possible) using inforamtion from the user's OpenID profile. 

In my next blog installment I would like to give you some insights of how I created a first draft implementation using Spring Security 3.0. Keep in mind that this is an ongoing (learning) process...Thus, if you see issues, let me know.

Continue with part 2.

Tuesday, December 8, 2009

Warbler and JRuby on Netbeans

Have been brushing up my Rails skills last night. I installed the latest Netbeans version (NetBeans IDE 6.8 Release Candidate 2)

Everything looked great but during project setup, I selected the option to use Warbler ('Add Rake Targets to Support App Server Deployment (.war)'). As it turns out, setting up Warbler during project setup just 'breaks'. I have been using the "Built-in JRuby 1.4.0". It seems to be a path issue on my Mac running Snow Leopard (there were some indications on the web).

Ultimately, I was able to solve that issue by installing a dedicated JRuby version that had a nice shorter path.


Before:

"/Applications/NetBeans/NetBeans 6.8 RC2.app/Contents/Resources/NetBeans/ruby2/jruby-1.4.0/bin/jruby" -S gem unpack warbler
rake aborted!
Command failed with status (127): ["/Applications/NetBeans/NetBeans 6.8 RC2.a...]
/Applications/NetBeans/NetBeans 6.8 RC2.app/Contents/Resources/NetBeans/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:995:in `sh'
(See full trace by running task with --trace)

After:

/Users/hillert/_APPS/jruby-1.4.0/bin/jruby -S gem unpack warbler
Unpacked gem: '/Users/hillert/NetBeansProjects/DX2010/vendor/plugins/warbler-0.9.14'

I haven been running into a few other issues to finally get a simple Rails deployment working on my Tomcat instance, but that is a new blog post to come...

Friday, December 4, 2009

Great Time at the Scala Meeting

I had a great time at the Scala meeting here in Atlanta, tonight. This was the first time for the Scala group to meet in a central location (Same place as the AJUG meetings) and the group was able to double their attendance to almost 20 attendees.

For me it was also very nice to meet Lex Spoon, co-author of 'the book' on Scala 'Programming in Scala'. Also, this is a small world - As a Java Posse fan, it was interesting to realize that John Weathers, the organizer for the Scala Meetup Group and Dick Wall worked together in Atlanta. Besides being a big advocate for Java, Dick is also very involved with the Scala scene in the Bay Area.

Anyway, seeing the potential of Scala combined with the talent we are having here in Atlanta, there is a great bright future for the Scala community, and with it the larger JVM community. These are exciting times!

Wednesday, November 25, 2009

Scala Meetup in Atlanta (3 Dec 2009)

Just updated the AJUG website. recognizing that various JVM languages are gaining popularity, we will be starting to sponsor the Atlanta Scala Meetup (With meeting space). The next meeting is on December 3rd, 2009 at the usual AJUG location (Holiday Inn Select)

For more details, please visit: http://www.ajug.org/ and http://www.meetup.com/atlanta-scala/.

¡Viva La JVM!

Friday, November 20, 2009

Oracle, Flex and MOS - a sign for Java FX?

Ok, while we are still waiting for the Oracla/Sun purchase to go through, there is also lots of speculating about what might happen with Sun's technology portfolio moving forward.

Since the world is moving towards richer UI interfaces for the browser, I am always in the struggle to assess which technology stacks are most appropriate to learn (GWT, Flex, plain HTML + your choice of JavaScript library such as JQuery, YUI etc.). Thus, particularly as a Java developer I am of course interested in the outlook of JavaFX - I certainly "wish" it be successful, but it still seems to be lacking in various areas (Component libraries, JVM modularization, 'community'). Furthermore, there has not been any Oracles/Sun statements about the future of JavaFX as far as I know (Please comment if I am wrong)

There was a higher-level article in InfoWorld yesterday discussing the future of Sun's technologies:
http://www.infoworld.com/d/developer-world/java-what-does-its-future-hold-978

Oracles involvmen into Flex

This brings me to the main trigger point that caused me to this blog entry. A few days back, I read a news article at Heise Online, a large German IT news portal, stating that Oracle has some major issues while switching over to their new support system 'My Oracle Support' (MOS):  


http://www.heise.de/ix/meldung/Oracles-neues-Support-Portal-aergert-Kunden-856450.html

You can read more the issues here:
The more interesting fact, though, is that their entire new support system is implemented in Adobe Flex. Unfortunately, I was unable to find more technical details via Google, but that is a fairly substantial deployment.

I found another interesting little piece of information on stackoverflow:

http://stackoverflow.com/questions/1601444/flex-oracle-open-world-2009

According to James Ward (Flex evangelist at Adobe), Oracle showed more Flex-based applications this year at Oracle OpenWorld 2009 including: My Oracle Support, Social CRM, Siebel Gadgets and Enterprise Manager.

Can you draw any conclusions out of this regarding the future of JavaFX? Probably (hopefully) not, but it shows that Oracle has already made a significant investment into Adobe Flex. 


Adobe Flex and JavaFX in Atlanta

To give you some idea of how the market looks like here in Atlanta, Ga:

At the last meeting of the Atlanta Java Users Group (November 2009), Burr Sutter our group's president asked the group (80+ attendees) whether they use Adobe Flex and a considerable amount of hands went up (I guess at least 1/3).  Nobody in the rooms did anything with JavaFX...

* * * *

PS: On a more frustrating side-note: While writing this blog post I visited http://www.javafx.com/ and my browsers froze (FF on Mac), causing me to re-type a good portion of my blog entry (Sigh). 

Sunday, November 8, 2009

Geeking out with Adobe Flex

Just some quick notes...I had some extra time this weekend and watched several excellent online presentations mostly about Adobe Flex. Adobe is doing a really good job of making their conference presentations freely available.

I worked my way through the following Adobe Max 2009 presentations:
Also, in the past I must have seriously overlooked Adobe TV. Seems to be a pretty neat educational resource. There I watched: Using the Flex Charting Components

Lastly, I ended the weekend by watching Data Visualization and Dashboards by Thomas Gonzales (from 360|Flex Conference). By the way you should also seriously check out his blog: http://www.twgonzalez.com/blog/. There is some good stuff there.

In his presentation, Thomas showed some need examples. This one causes some serious drooling: http://www.brightpointinc.com/flexdemos/googlefinance.html




And just in case you need a gauge on your dashboards: http://www.twgonzalez.com/blog/?p=34 Oh, yeah.

Saturday, November 7, 2009

Rich Charting Options for your RIA/Webapps

I started revisiting my charting solution in jRecruiter. For this fairly basic Java web application, I have been using JFreeChart to provide basic charts (E.g. to illustrate the number of posted jobs over time).

While JFreeChart works great, and it pretty much provides all the charting features you may ever want, it has one disadvantage: It is static. Compared to all the interactive goodness that is possible with RIAs such as Flex, JFreeChart lacks the sugary icing on the top (Mouse overs, AJAX interaction, dynamic drill-down etc.). Therefore, I was investigating my options to add some richness.

Additionally, at work, I am using Google Web Toolkit (GWT) and thus wanted to get an overview about the charting capabilities I have using GWT. One of the options there is gchart. It looks okay, alas not great. What's worse, the project owner abandoned his project; see: http://code.google.com/p/gchart/.

Another option is flot which comes along as a jQuery plugin and uses the HTML canvas tag to do charting.  There is a also a GWT wrapper for flot available called gflot.

The most interesting alternative for GWT, I came across is ofcgwt. It uses Open Flash Chart 2 under the hood and looks pretty good. You could argue that if you use Flash-based charting for your GWT app, why not just implement the entire app in Flex ;-).

On the pure Flash/Flex side, there are first of all the charting components that come with Flexbuilder. In contrast to the open-sourced Flex SDK, the charting components are not free, though. 

While, I was googling for some other options, I saw Axiis - Simply beautiful! Yet, another option is IBM ILOG Elixir, which is free for free sites. They have a very nice compilation of examples: http://www.ilog.com/products/ilogelixir/demos/.

On a low level, you also may want to look at Degrafa (Even if it is just for the gorgeous examples). You can find one interesting charting example at this blog: Nike+ graph using Degrafa/Flex 3.

Lastly, if you don't mind spending some money, you may also look at FusionCharts. At one of my prior engagements we used used in very successfully in a Struts2-based web application. Fusion Charts also comes along in a flavor for Flex - see the samples. There is also a Google Code hosted GWT wrapper available.

This, concludes my little 30k-feet overview/list of 'Rich' charting options. If I missed a good one, please leave a comment!

Sunday, October 25, 2009

NFJS Conference Atlanta 2010 - Day 3

The last day is over. It's been a great conference. Without a doubt, JVM language alternatives dominated the conference sessions. Since I won a book on Scala yesterday, I will checkout that language out next :-)

Today, I attended two sessions by Ken Sipe: "Architecture and Scaling" and "So you want to be an Architect". I particularly enjoyed the latter one, as Ken gave a very pragmatic overview of his view on what the qualifications of an architect ought to be. I had to smile when somebody from the audience asked Ken how as an architect you can possibly keep up with the constant technical innovations and the sheer breath of required knowledge and Ken responded that he doesn't watch any TV. Well, I catch myself weekly listening to the Java Posse, SE Engineering Radio, Parleys.com etc. while doing the dishes, cleaning up etc. And with planning for AJUG meetings, the next Devnexus conference etc. there is not much time left for TV either (Although I still leave some space for my weekly dose of Southpark ;-)

I guess you really have to like what you're doing in order to fulfill the requirements of an Architect.    

During the Birds of Feather (BOF) session I asked the panelists on their opinion about Python, which was never even mentioned at the conference but which at the same time is heavily used in computer science teaching at colleges in Georgia. Their opinion was, that it's white-space issue is just too much of a limiting factor for using it in HTML scripting, using it as a DSL etc. and also that there are some issues with the user community itself. And thus, they said, there were just better alternatives at this point.

During the afternoon I attended 2 sessions by Ted Neward
  • The Busy Java Developer's Guide to Advanced Collections
  • The Busy Java Developer's Guide to Hacking with the JDK 
Both sessions were interesting but I wish Ted had given some more real world examples for use cases of Apache Commons Collections and the Google Collections Library. In his latter talk he showed an example of how to add functionality to core JVM classes. Interesting, but talking about "experimental and highly hacky stuff".

Overall, this was an absolutely wonderful conference. Looking forward to the next one! As always: Jay keep up the good work!

Saturday, October 24, 2009

Don't use Java for New Projects - NFJS Day 2

Day 2 of the No Fluff Just Stuff (NFJS) conference here in Atlanta is over - It's been a good day. It has been another day of excellent speakers and topics. One thread you can see clearly throughout the presentations is:

Java's days are numbered as a language for new development - Viva la JVM!!

I got the sense that you should at least start thinking about an exit strategy. Stuart Halloway was even more outspoken: "Don't use Java for new greenfield development." (Saying that any of the talked about alternatives are better - Scala, Clojure, Ruby and Groovy).

After going to a few sessions that dealt with concurrency, I am certainly not inclined (border-lined scared) to do that kind of stuff in Java. The two languages most talked about at the conference were Scala and Clojure.

The nice thing is, that both language run on the JVM, so you can use the new language features, but are also able to use the vast power of Java libraries, if needed. Once drawback I saw is the fact that both Scala and Clojure can be fairly cryptic, which was an issue that was raised repeatatly by the audience and as well during conversations with fellow developers in between session breaks. Scala at least gives you the ability to write Java like code and then later on as you gain proficiency, you can make your code more concise . From a "power perspective", Scala looks awesome, though.

The sessions I atended to today were:
  1. Tackling Concurrency on the JVM (Venkat Venkat Subramaniam)
  2. Advanced Topics in JMS (Mark Richards)
  3. Java.next: Clojure, Groovy, JRuby, and Scala (Stuart Halloway)
  4. What's New in Spring 3 (Ken Sipe)
Onto the last day now...

NFJS Conference Atlanta 2010 - Day 1

Today was the first day of the NFJS conference here in Atlanta. It's my third time and it is always a great experience in terms of sessions but it is also a good opportunity to network.

First I went to two sessions of Venkat Subramaniam: "Effective Java" and "Programming Scala", both excellent sessions. I get the feeling, it is really time to look beyond Java, particularly if you do anything around concurrency. Not sure if Scala will be it, there seemed to be some contention in the crowd regarding Scala's more cryptic syntax. Although, it looked manageable in my opinion. Nevertheless, I need to check out the Clojure talk tomorrow.

The third session I attended was "Transaction Pitfalls and Strategies" by Mark Richards. At first I was a bit hesitant attending the session but I was glad I did. A related article can be found at IBM DeveloperWorks. The presentation contained some really good stuff.

The first day ended with a very good keynote by Ted Neward on Iconoclasm. Oh well, it is 1am already...better get some sleep for day two of the conference.

Friday, October 23, 2009

How to Teach CS to Children

At the Atlanta Java Users Group (AJUG) we had an awesome presentation by Barbara Ericson on how to inspire children to learn more about computer science (CS). It was a really informative session. As director of Computing Outreach at Georgia Tech University she helps prepare curricular materials for high schools.

As such, she gave us a detailed overview of the state of CS teaching in Georgia and the nation as a whole. Furthermore, she gave us an overview of all the cool software tools that help teach CS concepts including:
She also talked about some interesting robotic toys that help in her efforts:
I wish I had had the stuff when I grew up...

There is even a website out there that provides free information on activities that teach CS concepts without a computer: http://csunplugged.org/

Lastly, if you have children of your own, you should certainly check out Barbara Ericson's presentation and you can also find many more resources on her website: http://coweb.cc.gatech.edu/ice-gt

Saturday, October 17, 2009

Apache Camel Alternatives

In part one of my mini series I provided a quick introduction to Apache Camel and in part two, I continued with a simple example illustrating the very basics to get you started (which I extended a bit in part three)

In this posting, I would like to talk about some of the alternatives that I see might be interesting for you to investigate, when considering an open-source enterprise integration framework. Hereby however, things always get a bit fuzzy in my opinion, depending on your business requirements.

On one side, you want to have components which allow you to communicate with other services, but on the other side you also want to have some sort of workflow-capabilities in order to orchestrate your business processes. Furthermore, you may be interested in monitoring and reporting functionality.  From a different view-angle, you may desire a higher-level solution versus a solution that embeds easily into existing code using plain Java APIs. The list could probably be expanded considerably, but I hope you get the picture.

Ergo, depending on your specific business requirements, the following list of frameworks may or may not provide a better choice compared to Apache Camel:    
  • Spring Integration
  • Spring Batch
  • JBPM
  • nexusBPM
  • Drools
  • Hadoop/Cascading
  • Full ESBs such as Service Mix, Mule ESB, OpenESB, JBossESB
Actually, in my opinion the closest alternative to Apache Camel is Spring Integration.

Spring Integration

Before I was even aware of Apache Camel, I learned about Spring Integration at the No Fluff Just Stuff (NFJS) Java conference one year ago. Back then I thought that Spring Integration was the best thing since Nutella. Then a little later I learned about Apache Camel and tried to figure which one to take for a spin. As it turns out, comparative information on Google is rather sparse:
Interestingly, Apache Camel provides a component that allows you to integrate Apache Camel with Spring Integration.

To me a good argument for Apache Camel was the greater availability of components compared to Spring Integration, as well as its adoption by other frameworks such as ActiveMQ and ServiceMix


Spring Batch

If your business requirement is to process large amounts of data, you may also want to look at Spring Batch which is specifically designed for batch processing requirements. There are some pointers on the Spring Batch website for integrating it with Spring Integration. I considered it for one of my past projects, but unfortunately I do not have massively deep experience with it as we ultimately chose JBoss jBPM.

jBPM

In my opinion another option worth considering is jBPM from JBoss. I used it in one of my past projects. Integrating it back then with Spring was certainly a  bit tricky (especially asynchronous execution of Nodes), but it is doable. Interestingly, starting with version 4.0, JBPM provides native Spring integration. Unfortunately, I did not have any opportunity, yet, to try out JBPM 4.0.  JBPM is certainly much heavier compared to Apache Camel or Spring Integration. I would say that its focus is also slightly a different one. While it provides support for human task management during workflow executions, managing the state of your workflow nodes etc., it totally looses out compared to the available components, which are provided by Apache Camel.


nexusBPM

A little bit jBPM on steroids is nexusBPM (An older blog post of mine about it is here). Developed by Intercontinental Hotels Group here in Atlanta, it is open-sourced at Sourceforge and provides a set of useful components in addition to the original JBpm distribution.

Drools

You probably would not necessarily think of Drools being a Workflow solution but what originally started out as a rules engine seems to venture increasingly into other areas as well. In fact, at least from a 30k foot view, it pretty much provides similar functionality as JBPM (Workflow, human task management etc.) and also provides a few components such as FTP, mail, executing system commands, etc.

What kind of baffles me is the fact that JBoss is maintaining 2 very similar products...

Cascading and Hadoop

If you need to process large amounts of file-based data, then Cascading might also be an interesting alternative. Cascading uses MapReduce to handle chunks of data. Interestingly, you can also use it for creating workflows. Not too long ago I attended an interesting presentation on that subject at AJUG. The presentation can be found here.

ESB like ServiceMix, Mule, OpenESB

Last in my list of alternative frameworks to Apache Camel is an entire category of solutions: Enterprise Service Buses (ESB). Enterprise Service Buses are basically stand-alone products, and as such, have a much heavier foot-print than for example Apache Camel which is basically just a set of light-weight Java APIs. In fact Apache Service Mix 4.0 is using Apache Camel under the hood in order to provide message routing. Besides Apache ServiceMix, you may also look into these OSS products:
This concludes my VERY high-level overview of frameworks/products that allow you to implement worklow and/or enterprise integration-based solutions. This whole subject could easily be extended into a more comprehensive article. Nevertheless, I hope I was able (within the limits of a blog post) to provide you with some good starting points.

¡Hasta la próxima!

Sunday, October 4, 2009

Camellos III - Zipping Files with Apache Camel Example

I played a bit more with Apache Camel and I extended my little Camellos project (See this blogpost for details, including for directions to get to the source code) by another simple Example:
  1. poll directory zip-input for any type of files
  2. pack the files using the Zip data format
  3. output files to the zip-output directory
I thought this would be an easy example to get my feet a bit more wet with Camel. Apache Camel provides 2 data formats for zipping files:
Interestingly, using the marshaller for the Zip data format, you're unable to generate standard zip file. Looking through the source code of the Zip daa format, it turns out that Apache Camel is using a DeflaterOutputStream to created the compressed data versus using a ZipOutputStream. A bug??

Thus, what a great opportunity to create my fist customized Camel Data Format implementation :-) I basically just took the existing ZipDataFormat class and converted it to using a ZipOutputstream, and by adding a single ZipEntry for my file. This works quite well.

I also added a reverse route for unzipping a file. One limitation exists. The zipfile can contain only one file. I am not sure, yet, how to solve the issue when you have more than one file in your zip file...I guess this may be a task for the Splitter or Aggregator components.

Saturday, September 26, 2009

Proxying large Amounts of Data using UrlRewriteFilter

Finally, I found some time to submit a feature request with patch to the UrlRewriteFilter project.

http://code.google.com/p/urlrewritefilter/issues/detail?id=53

In one of my projects we needed to provide functionality to post (upload) and download data via a servlet container to/from another url/port - basically we needed to implement proxying.

A great library out there is UrlRewriteFilter, a Java library that provides Apache's mod_rewrite functionality. Not only can you use it to make complex urls more user-fiendly, or re-map old url to new ones but it also provides proxying capabilities.

UrlRewriteFilter uses Apache HttpClient for doing proxying. Unfortunately, I ran into memory issues when proxying large amounts of data.  The issue is that the current version of UrlRewriteFilter (3.2) is doing buffered requests while proxying. This probably works fine for 90% of all use-cases but for the project I am working on we need to basically support unlimited amounts of data to be proxied (multiple 100s of MB).

Thus I provided a patch, that worked really well in my project without increasing memory consumption.
In Apache HttpClient you can implement a custom class using the RequestEntity interface that allows you to stream the data directly.

Thursday, September 24, 2009

Camellos - Discovering Apache Camel II

As indicated in my last blog post, here is an example implementing a small Apache Camel example.

You can pick up the source code from:
Steps to get it running:
  1. Check out the source
  2. Using Maven run: mvn camel:run
  3. The Application should compile and start up correctly.
  4. You can now drop files into the camellos/inbox directory
  5. The files should get uploaded to its the FTP server running at localhost:3333
  6. The uploaded files should show up under camellos/ftp
Back to y example, for my little blog post example here I want to provide the following very simplistic functionality:
  1. pick up files from an directory
  2. make sure that you pick up no more than 3 files per 30 seconds
  3. store them into a JMS queue
  4. have a listener on that queue that picks up those files
  5. and upload files to a remote FTP site
What do you think, how many lines of Java code does it take?

With Apache Camel you can get this simple task done with ZERO lines of Java code. Well, I needed 1 Main class with a few lines of code to load the Spring context and and the embedded FTP server. Nevertheless, I think that is quite impressive. In a sense all the heavy lifting is done in the Spring Application Context file:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:ftpserver="http://mina.apache.org/ftpserver/spring/v1"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">


<amq:broker useJmx="false" persistent="false">
<amq:transportConnectors>
<amq:transportConnector uri="tcp://localhost:0" />
</amq:transportConnectors>
</amq:broker>

<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="vm://localhost"/>
</bean>

<ftpserver:server id="ftpServer" max-logins="10"
anon-enabled="true" max-anon-logins="5" max-login-failures="3"
login-failure-delay="20">
<ftpserver:listeners>
<ftpserver:nio-listener name="default" port="3333" local-address="localhost"/>
</ftpserver:listeners>
<ftpserver:file-user-manager file="users.properties" encrypt-passwords="clear" />
</ftpserver:server>

<camel:camelContext shouldStartContext="true" trace="true">
<camel:package>com.hillert.camellos</camel:package>
<camel:route id="route1">
<camel:from uri="file:camellos/inbox?move=.done" />
<camel:throttle maximumRequestsPerPeriod="1" timePeriodMillis="10000" >
<camel:to uri="activemq:queue:camellos"/>
</camel:throttle>
</camel:route>
<camel:route id="route2">
<camel:from uri="activemq:queue:camellos" />
<camel:to uri="ftp://admin@localhost:3333?password=secret"/>\
</camel:route>
</camel:camelContext>
</beans>


Apache Camel provides its own Maven plugin: http://camel.apache.org/camel-maven-plugin.html

Getting started with Apache Camel is simple. I recommend using m2Eclipse which is a Maven plugin for Eclipse. Basically Camel provides it's own Maven archetype which after running creates a simple project structure and which can be immediately run using mvn camel:run after project creation.


For my implementation I followed Camel's tutorial for creating a Spring based Camel route.
As my example uses a few more components for Apache Camel but also ActiveMQ for JMS and Apache Mina FTP Server, I needed some additional Maven dependencies.

Getting all the Maven dependencies right took actually longer than implementing the actual application logic. Anyway, I hope this gives you a quick overview of some basic Apache Camel features. As time permits I will blog about more about it soon. See you then!

PS: Apache Mina FtpServer, is itself a nice little nifty package. So if you for example have the need to boot-up dynamically FTP servers from within your application...check it out.

Wednesday, September 23, 2009

Camellos - Discovering Apache Camel I

Over the next couple of weeks or months (depending how much spare-time I am able to allocate), I will dive into the world of Apache Camel (Also take a look at my second blog post)


Apache Camel is somewhat like a Swiss-army knife. As an integration framework (Message Routing API, Mediation Router), it implements all the Enterprise Integration Patterns from the book with the same name.


Next, Apache Camel provides a quite extensive component library supporting an impressive amount of communication protocols. Also, it support an wide range of data formats as well as integration points in terms of other frameworks such as Spring, Guice, ServiceMix, ActiveMQ et cetera.

Well, that's all nice and dandy—However, what does this mean for me as a software developer?

When you develop typical Java enterprise applications, you will sooner or later come across the requirement to connect to other systems or to add other asynchronous services to your applications. Something like:

"Hey, we need to pick up this file that comes in every night, parse it, process it and then stuff its data into our database and, while we're at it, also make sure the original file is archived somewhere in the file system."

Or maybe you just have some requirements where your application needs to send data to another server but you have to make sure, that the flow of data is "throttled" in order not to overburden your destination server during peak-processing times.

In all those cases Apache Camel can greatly simplify the implementation effort. It is basically a mini ESB in the form of a simple Java API. But it is extremely modular so you can just bits and pieces from it. In my next blog post I will show you an example showing you how it is really dead simple to get started with Apache Camel.

See second Camel related blog post.

Saturday, September 19, 2009

GWT - Hosted Mode Gotcha in Windows

I ran into a small gotcha while running a GWT application I am working on in hosted mode. Usually I am developing my application in hosted mode but for quick stand-alone deployments I also need to deploy the application to a dedicated servlet-container. Since the default settings cause the application to compile rather slowly, I have been trying to speed up GWT compilation times (Using GWT 1.7) by compiling against Firefox only (My browser of choice).

To achieve this I set the following property in my GWT module's *.gwt.xml file:



Well, as it turns out, this caused me quite some pain in hosted mode. I did not realize that the aforementioned setting affects hosted mode. I new that under Windows Internet Explorer (IE) is the default browser but always assumed it only affects fully compiled GWT code - not code running in hosted mode. That was a painful lesson - It caused some rather obscure errors in hosted mode and nowhere were I able to find explicit information regarding this issue.

Sunday, August 30, 2009

jRecruiter is deployed and live

Finally...it took ways to long. Last Sunday I finally made a new production deployment (Version 2.0) of jRecruiter). jRecruiter is the job posting service of the Atlanta Java Users Group (AJUG). This version was a long time in the making. I hope that from now on I can make new feature deployments more swiftly. The new version is accessible at: http://www.ajug.org/jrecruiter/

Here is a list of changes:
  • (Almost) No more Struts XML-configuration files. jRecruiter uses the Struts 2.1 convention plugin for annotation based configuration.
  • Many Spring Beans dependencies are now configured using annotations (Spring 3.0)
  • Sophisticated data-grid support using jMesa
  • Google Maps integration (web (Javascript), Pdf (Image) and Flex (Flash))
  • Hibernate Search support
  • RSS feeds for the latest 20 jobs using ROME
  • Social bookmarks on the job posting list
  • Application is now Struts 2.1 based
  • Using jasypt for password digesting
  • Administrative pages are SSL encrypted
  • Improved charting (JFreeCharts)
  • Using reCAPTCHA for the registration page
  • Implemented email account verification
  • Now job postings and updates are send to Twitter (http://twitter.com/ajug_jobs/)
  • PDF Export of Job Posting Details (using iText)
  • Switched from username-based logins to an email-based system (usernames are still supported on the backend (e.g. administrative logins)
  • Some performance improvements --> CSS and JavaScript files are now merged, minified and GZipped using JAWR)
  • XML web services for providing job posting data to Indeed.com (Still need to do the actual integration but the XML feed is there)
  • Using jQuery for most Javascript needs
  • Maven project consists of multiple modules now (web, server, flex)
  • I18N: Added partial support for German
  • Extra bonus: Added a simple Adobe Flex front-end using Spring Blaze DS for server integration

Wednesday, July 29, 2009

Integrate Twitter and bit.ly into your Java App

I am in the final stage of developing towards the 2.0 release of jRecruiter. It is the job posting service of the Atlanta Java Users Group (AJUG) and as such I devote some of my spare-time towards it. It is a great way to explore all kinds of different technologies. Thus, last weekend I had the idea that it might be a cool idea to let the system "tweet" about job posting additions and updates. Here are my findings.

First I looked at available Twitter libraries for Java:
After some considerations, I chose Twitter4J. To me, it seemed to be the most active of the three projects. Even better, it has a BSD-style license. Using Twitter4J is super simple:

Twitter twitter = new Twitter("username", "password");

try {
twitter.updateStatus("My tweet");
} catch (TwitterException e) {

}

There is so much more you can with Twitter4J. Check out its documentation for further details.

Secondly, as each tweet contains a link back to the job detail page in the main application, I was looking into ways to shorten URLs. That way, I can store more job posting related data within the only 140 characters available for each Twitter status update.

The original service for this is TinyURL. However, it looks like bit.ly has more traction these days and is also used directly by Twitter itself. The nice thing about bit.ly is that they have developer accounts and are offering a web service API for doing URL shortening.

Even better, there is already a Java library available for using bit.ly called bitlyj. Using bitlyj is actually almost as equally simple to use as Twitter4j:

final Bitly bitly =
BitlyFactory.newInstance("username", "your_bitly_api_key");
try {
BitlyUrl bUrl = bitly.shorten("http://www.google.com/");
URL url = bUrl.getShortUrl();
} catch (IOException e) {

}

Unfortunately, you have to build bitlyj yourself, but thanks to Maven it is a piece of cake. One thing I noticed, is that the error handling of the library could be more robust. Accidentally, I was using my bit.ly password, initially. However, bit.ly provides an API Key. By the way if you ever wonder where you can get that API Key-It is right in your account page. Anyway, the library needs some attention but for my simple use-case it worked fine.

Thursday, July 23, 2009

MapReduce, Hadoop and Cascading at AJUG

Yesderday Chris Curtin, CTO at Silverpop, gave an awesome presentation on MapReduce, Hadoop and Cascading. I really enjoyed his wealth of real-world practical examples.

His presentation is available at: http://www.slideshare.net/chriscurtin
Thanks to John Willis, there is also a video recording available at: http://www.johnmwillis.com/ec2/hadoop-and-cascading-ajug-072109/

Sunday, June 7, 2009

Book Review: Spring Web Flow 2 Web Development

Spring Web Flow 2 Web Development by Sven Lüppken and Markus Stäuble is the currently only available book on Spring Web Flow 2.0. The book covers all the components that are part of the Spring Web Flow distribution such as:
  • Spring Web Flow
  • Spring Faces
  • Spring JavaScript
Additionally, the book also provides an overview of Spring Security. The book comes with example code for many of the chapters.

The provided examples, however, could have been a little more consistent. The main source example in this book is covered in chapter 5 (A simple bug tracker). I liked the given example, as it does not require a database. This makes it easy to understand the Spring Web Flow specific problem domain. However, considering the fact that the authors also talk about Spring Security in other chapters, it would have been nice, if they had used the bug tracker example throughout the book in order to create a “complete” application, that ties together Spring Web Flow, the persistence layer and Spring Security. Unfortunately, the code examples given in later chapters don't refer back to the bug tracker example. Instead, chapter 6, for example, uses a shopping cart example.

A further minor annoyance is that the source code for 2 of the chapters still contain the eclipse project files used by the authors. This may be confusing for some users as these project files still point to Microsoft SQL Server drivers on a windows D: drive. I, for instance, use a Mac...

In chapter 2 the book discusses on 4 pages Ant and Maven. I think it might have been simpler for the understanding of the book and the provided source code, if only one build system was used, e.g. Maven. Some of the code examples provide Ant and Maven build scripts but some other ones provide support for Maven, only.

Another anomaly was, that the book describes the installation of the Spring IDE plugins for Netbeans and Eclipse on 7 pages but then the authors mention in passing only that they are using Microsoft SQL Server as underlying persistence store for their example. As many Java developers may not have a MS SQL Server license, it may have been better to use open-source Databases such as MySQL or PostgreSQL.

The example in Chapter 3 uses HSQLDB for its database but earlier (Chapter 2) the authors use MS SQL Server. For consistency and simplicity reasons the book could have stuck with one database.

Chapter 4 deals with Spring Faces. The authors should have mentioned JBoss Seam, since Seam solves a similar problem as Spring Web Flow but having a default focus on JSF.

The book provides an entire chapter on JSF integration (Chapter 4). As JSF is a widely used framework and Spring Weblow provides native support for JSF. It would have been nice though, if support for other frameworks such as Struts 1 and 2 would have been illuminated.

As part of chapter 5, the book also provides information on Spring JavaScript. While it is part of the official Spring Web Flow distribution it is not necessarily essential for the working of Spring Web Flow and even its spec lead Keith Donald mentioned at the Atlanta Java Users Group (AJUG) meeting in November'08 that it maybe extracted into its own project in the future.

The section in chapter 5 which starts on page 165, the Web Flow Configuration, felt repetitive to parts of Chapter 3 (pages 53) and should have probably merged with that section. Chapter 5 also contains a larger section on Apache Tiles integration. One thing that I did not understand was how Tiles matters in terms of mastering Spring Web Flow. Generally I don't mind explaining additional pieces of information around the edges of your problem domain but if that happens on 5 percent of the book, it needs to matter within the context of the targeted subject. On a site-note: Take a look at SiteMesh for your templating needs. I strongly prefer it compared to Tiles.

In chapter 6 the testing of your Spring Web Flows is explained. This was an informative chapter and I particularly liked mentioning of EasyMock.

In chapter 7 the book primarily details Spring Security. In my opinion, it provides too much Spring Security centric information. For example, the chapter describes how to create and write your own AccessDecisionVoter. In my opinion it does not help and is unnecessary for the understanding of Spring Web Flow. At most I would have chosen an example that uses a DB-backed security implementation using default Spring Security functionality.

To me, chapter 7 was a bit strange. It provides 16 pages of information introducing Spring Security but the actual integration of Spring Web Flow with Spring Security is accomplished in merely 4 pages. Most interestingly, that's where the book simply ends. I missed something like a wrap-up, that summarizes what the book covered and where to continue on.

In Appendix B the authors provide an overview of Springsource's dm Server. Personally, I think that dm Server is an interesting offering. However, I don't understand why this appendix even exists in this book. It is neither important for the understanding of Spring Web Flow, nor do the authors explain why this appendix exists.

Here are some further thoughts: Throughout the book, I like the use of Maven for building the examples. It certainly makes it easy to understand the examples' structure.

I think for the understanding of Spring Web Flow, it unnecessarily complicates things, if you present examples that require JNDI for establishing database connectivity. Furthermore it binds you to a concrete application server, which in this case is Tomcat.

Except for a for a very brief mentioning on page 224, the book never talked about the applicability of Spring Web Flow in the context of RIA frameworks such as GWT, Flex etc. Is there a use case for Spring Web Flow e.g. for coarse grained server state for large, complex applications?

It would have been nice if the book provided an overview of other frameworks that handle conversational state such as JBoss Seam. Additionally, since the books was published in March 2009, it could have described some of the planned conversational state management support planned for Spring 3.0.

Furthermore, it would have been great if the book had also mentioned how Terracotta can be used to back Spring Web Flow conversations. Terracotta provides an interesting reference application detailing that possibility.

Anyway, the book follows generally the Spring Web Flow documentation. The question is how much more value does the book add compared to the reference documentation. Overall, I have a quite conflicted opinion about this book. I think, if you are interesting in JSF integration or the bulk of the additionally discussed technologies (E.g. Spring JavaScript), then this book may add enough information for you. It certainly provides some useful information regarding Spring Web Flow 2.0.

Unfortunately, it contains quite a few inconsistencies and it is overall not an easy read. However, it is the only currently available book dealing with Spring Webflow 2.0. On Amazon, I gave the book 2 out of 5 stars.

Wednesday, June 3, 2009

Book Review: Learning Flex 3

Learning Flex 3 by Alaric Cole is a great introductory book for Adobe Flex 3. If you have some basic experience with HTML, JavaScript and CSS, then you will learn the basics of Flex rapidly using this book as a guide. Some of the areas that are taught are:
However, if your professional background is in web-application development using Java or other OO languages, then you are probably more likely to skip or cross-read sections of the book. This is because the book starts out with practically no initial pre-requirements, and thus you might be familiar with some of the discussed areas.

The book gave me an excellent overview of Flex's capabilities, and they are all explained thoroughly and are easily understandable. Also, this may sound silly, but I particularly liked the refreshing fact that the book is in color, unlike most other IT books.

Furthermore, the book explained Data Binding (Chapter 7) very well. This is something I was not familiar with coming from the Java world. The chapter illustrates the concepts of one-way binding, two-way binding and making your own variables “bindable” using a metadata declaration, which is basically an annotation in Java parlance.

Another feature I liked a lot was View States (Chapter 12), which allows you to rearrange, group and reuse components within your application.

I wish the book provided more information for further reading. I understand that certain concepts are beyond the scope of this book, but it would have been nice if those had been mentioned and links or recommendations for further reading were provided.

For example, while AMF is mentioned on page 8 and on page 157 the book briefly talks about the Webservice and RemoteObject component, the book should have also mentioned BlazeDS as one of Flex's core technologies for communicating with back-end servers.

And for more complex applications, the book could have at least pointed out some of the available MVC frameworks for Flex and some pointers of where to read more about them (E.g. Cairngorm and PureMVC). Well, and then there is Degrafa, the declarative graphics framework…

While the author explains the aspects of using CSS in Flex applications very well, he could have further stressed that Flex uses a subset of CSS, which in certain areas behaves differently compared to CSS you more typically use in HTML pages. He should have enumerated some of those pitfalls.

Having said all this, these issues mentioned above are minor in nature. Overall, the book was a fun read! And particularly to Java web-developers, Flex may very well be THE contender for application user interfaces moving forward. One of the great things about Flex is that even the standard components look very good (and should be good enough to please your boss), and your application looks and behaves consistently across various browsers. Oh, and yes you can run the same application on the desktop as well (Chapter 15).

This book will definitely help you learn and master Flex, and you should be able to produce functional user interfaces quickly. In order to learn more about integrating Flex with your Spring powered back-end you may want to also consider looking at “Pro Flex on Spring”.

Thursday, May 14, 2009

JavaRebel + m2eclipse = Sweet Spot

One of the pain-points while developing Java-based web-applications is the issue of the bouncing server. Every time you change a class file, your web application context needs a restart. While this is mildly annoying for small applications, it is simply unbearable for anything more substantial.

As far as I now the best and cheapest solution so far has been to use MyEclipse. It worked great and I rarely had to restart web contexts.

I always wondered why the standard IDEs (E.g. plain Eclipse WTP, IntelliJ ) never solved that re-deployment issue. Well, at least I have not been able to get this sufficiently working in plain Eclipse+WTP or IDEA IntelliJ.

Unfortunately, with the advent of Maven, MyEclipse started to loose come of its charm. For years, they were not able to provide an acceptable Maven integration (There was an entry on their forum for years demanding that feature) and on the other side, WTP started to become usable (I have not really tested the Maven integration introduced with MyEclipse 7 but I have read, that it is still not perfect). But one thing, that MyEclipse had nonetheless going for it, were its hot deployment capabilities.

Enter ZeroTurnaround's JavaRebel. Four weeks ago I started looking at JavaRebel and have been using it for the development of my OSS project since then. My verdict: It is awesome.

I use it in conjunction with the m2eclipse plugin and it simply works. ZeroTurnaround provides guides regarding the Eclipse and Maven integration (here and here) that are fairly straigtforward. It also comes with support for Spring and Struts2 directly.

The nice thing about JavaRebel is that it is agnostic to the used IDE as it simply hooks into the JVM as a Java agent. Therefore, you probably could also easily use it from the command line (in case you like to code using VI :-).

One drawback is the price which makes JavaRebel more expensive than MyEclipse. On the other hand, there is not much in MyEclipse that you cannot have in plain Eclipse/WTP using free plugins. Thus, ultimately it may boil down to personal preference but to me JavaRebel with plain Eclipse WTP (or IntelliJ for that matter) is the much nicer package. And if you have a project with an OSS license you can get JavaRebel for free, and don't have to buy MyEclipse.

Friday, May 8, 2009

Vi on a fresh Ubuntu installation - issue

I am in the process of setting up Ubuntu 9.04 on my Linode instance. Looks like Vi was behaving screwy (Keys did not work as expected). Luckily there is Google and the following link helped.

I created a .vimrc file in my home directory:

vi ~/.vimrc

and added the following line to it:

set nocompatible

That worked for me.

Tuesday, April 28, 2009

Postfix relay messages to different port

A frequent occurrence in applications is to send out emails. In order to test that behavior sufficiently during development, I usually use one of two options. On Windows you can use Mailster (preferred) or you can use postfix etc. on Mac/Linux (Have not been able to get Mailster going on my Mac)

So far on my Mac until recently it was as easy as to simply do: sudo postfix start and I was good to go. Unfortunately, my domain hoster does not accept mail on port 25 anymore. And the simple relay stopped working.

As it turns out though, you can easily relay to a different port (My hoster accepts port 26):

sudo vi /etc/postfix/main.cf
I added a line (near # INTERNET OR INTRANET):

relayhost = myHost.com:26

And finally I reloaded my postfix configuration using sudo postfix reload and I was back in business once again.

Wednesday, April 1, 2009

Woes with Oracle's Jdbc Driver and BigDecimal

As other people before me noticed, Oracle seems to have issues with BigDecimals. Well, I hit one of those issues today:
  • BigDecimal.valueOf(0.000000548) became 0.000000538 in the database
  • new BigDecimal("0.000000548") became 0.000000538 in the database
  • persisting a plain String "0.000000548" worked fine however
  • new BigDecimal("0.000000458") became 0.000000448 in the database
The table column, to which the values were saved, had plenty of "scale'n'precision".
The issue occurred in Oracle's JDBC driver version 10.2.0.1.0. Luckily, after upgrading the drivers to version 10.2.0.4.0 the problems went away.

This is by itself an amazing issue - Just imagine, you were running a larger financial app. You may not even notice this subtle issue until your app is long in production. Oh well...

Saturday, March 28, 2009

DevNexus Report Part 2

In part one I provided an overview of attended DevNexus sessions. Here are some more details I took away from the presentations. The first days of the conference started out with Neil Ford, who always seems to provide those excellent but more high-level-off-the-beaten-path-type presentations (The presentation certainly contained an interesting Angelina Jolie picture). In his presentation he talked mainly about a quality work environment and how to be more productive as a developer. In his opinion giving developers their own office would be the best as it allows them to fully concentrate on the given development tasks. If that is not feasible and you're not working for Joel, then an open room configuration is the next-best compromise. And finally the worst solution: cubicles. Those suckers simply slurp your brain dry…



Well, afterward I headed over to Ari Zilka's talk about Terracotta. He gave an overview/introduction of Terracotta's capabilities. The presentation was quite similar to the talk we had at our monthly AJUG meeting last year but since then Terracotta published a new reference web application (Examinator) that really looks sharp and consist of a very good technology stack besides the fact that it uses Terracotta:
  • Spring MVC
  • Spring Webflow
  • Spring Security
  • JPA (Hibernate)
  • FreeMarker
  • SiteMesh
  • MySQL
One example he gave that stuck with me quite well, was the typical email registration process, when signing up for a new user account. You provide an email address, but before the account can be activated, you need to verify the email address using a verification email. However, using Terracotta, you're able to defer saving the email to the database until verification is complete and thus you can keep "state" information out of the database.

Afterward, I listened to Charlie Hubbard's talk on GridGain. This was an interesting talk in that GridGain is tackling distributed computing from a different angle than Terracotta. You are basically using it to farm out little chunks of data that are then processed by those nodes. It feels very reminiscent to using JMS with Publish/Subscribe with some processing logic bolted on.

After this talk I attended Bill Burke's talk on REST. It is interesting how various frameworks converge to a common point these days - RestEasy looked like Spring MVC 3.0 :-)

The last talk I visited was on Jared's Richardson's talk on 'using agile to optimize' which was a good talk. It reminds me that I still need to read his book Ship It!

At the end of the day we all headed down to the bar and had a few drinks. I met a former colleque of mine and chatted a while with Charlie Hubbard and Lance Gleason. A long good day…