Wednesday, July 1, 2009

JBoss Seam Archetype - now with ICEfaces

Last week I visited Jazoon - and had a great opportunity to see several impressive demos of ICEfaces! Of course I had to immediately get my hands on it, and started to integrate ICEfaces in the JBoss Seam Maven archetype (as described in my previous post).

You can give it a spin by starting a shell and running Maven with the Archetype plugin:

>mvn archetype:generate -DarchetypeCatalog=http://tinyurl.com/jbsarch -DajaxLibrary=icefaces
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
...
Choose archetype:
1: http://tinyurl.com/jbsarch -> jboss-seam-archetype (Archetype for JBoss Seam Projects)
Choose a number: (1): 1
Define value for serverDir: : [your JBoss 5 server location]
Define value for groupId: : [your groupId]
Define value for artifactId: : [your artifactId]
Define value for version: 1.0-SNAPSHOT: : [your version]
Define value for package: : [your package]
Confirm properties configuration:
serverType: jboss5
ajaxLibrary: icefaces
...
Y: : y
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
...


Make sure you don't misspell "icefaces", this will otherwise screw up the application. No input validation in Maven Archetype yet, but I started looking into it ;-)

Again, change to the project directory and build the project:

>mvn package

Now this also executes a sample unit test (fingers crossed it works this time ;-) - thanks to Oscar for the feedback!

Have fun with it! Anybody mind contributing a decent layout template?

Friday, June 19, 2009

Creating a JBoss Seam Maven Archetype

In case you're a regular reader of this blog, I guess you're aware that I'm a frequent user of both Maven and JBoss Seam - and that I'm regularly trying to combine working with both! My usual approach for setting up a new project was either to start with an empty Maven web application project and copying the missing files over, or to start with a seam-gen project and move it into a Maven structure. Both less than ideal...

Maven provides so called archetypes for a quick project setup. As there is not (yet?) an official archetype for Seam projects, I've been working on my own - and here's how you can use it as well!

All you need is
  • a recent version of Maven downloaded (I used 2.0.10)
  • and the Maven executable referenced in your path so you can use it on the console.
Open up a console, cd to your projects directory and type:

mvn archetype:generate -DarchetypeCatalog=http://tinyurl.com/jbsarch

This will start Maven and show the following command line output:

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: http://tinyurl.com/jbsarch -> jboss-seam-archetype (Archetype for JBoss Seam Projects)
Choose a number: (1):


The remote archetype catalog contains so far only one archetype (BTW: the jbsarch in tinyurl.com/jbsarch stands for JBoss Seam ARCHetype - hope you can remember this better than the full URL :-) Select the archetype by typing 1 and enter your Maven project properties as well as your JBoss Server directory:

[INFO] snapshot com.ctp.archetype:jboss-seam-archetype:1.0.0-SNAPSHOT: checking for updates from jboss-seam-archetype-repo
Define value for serverDir: : /Developer/Servers/JBoss/jboss-5.1.0.GA
Define value for groupId: : com.ctp
Define value for artifactId: : fluxcapacitor
Define value for version: 1.0-SNAPSHOT: :
Define value for package: com.ctp: : com.ctp.fluxcapacitor
Confirm properties configuration:
serverType: jboss5
serverDir: /Developer/Servers/JBoss/jboss-5.1.0.GA
groupId: com.ctp
artifactId: fluxcapacitor
version: 1.0-SNAPSHOT
package: com.ctp.fluxcapacitor
Y: : y
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 minutes 57 seconds
[INFO] Finished at: Fri Jun 19 19:12:19 CEST 2009
[INFO] Final Memory: 12M/79M
[INFO] ------------------------------------------------------------------------


Note that the serverType property defaults to jboss5. If you have a JBoss 4.2.x installation, quit with n and retype everything (hmm...) and use jboss4 instead.

In case anything fails here, make sure your archetype plugin is at least version 2.0-alpha-4 (I had to delete the local repo info file in the local repository once). Now with your project created, lets build and deploy it!

Aragorn:sandbox thug$ cd fluxcapacitor/
Aragorn:fluxcapacitor thug$ mvn package
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO] [fluxcapacitor]
[INFO] [fluxcapacitor :: JBoss Configuration]
[INFO] [fluxcapacitor :: Web Application]


The project currently features two modules: One with the actual web application, and the other one containing JBoss Server configuration files. With the basic archetype you only get a datasource there, but you can also use it to change server ports, define security realms, queues etc.

Environment specific properties are referenced in filter property files. You can find the development filter file in ${artifactId}/environment/filters/${artifactId}-development.properties. The filter file selection happens in the parent POM. It defines a development profile which sets the environment property. Setting this property to test will look for a ${artifactId}/environment/filters/${artifactId}-test.properties filter file.

Note that the parent POM contains your JBoss installation directory hard coded. You might want to factor this out into a developer specific profile when working in a team. Fire up your JBoss instance. Everything should start up well (fingers crossed...) and you can point your browser to the base URL of your application.


Done! Import the project in your favorite IDE and start prototyping!

Unfortunately this is still far away of what seam-gen provides up to now. Maven archetypes have improved over time but are currently still not as flexible to be useful in complex setups:
  • Entering project properties is not even close to be user friendly. At least a description, input validation (enumerations) and reasonable handling of default values might help.
  • Conditional installation of files. If you know how this works - let me know :-) This would be required to distinguish between WAR and EAR projects, and for targeting different applications servers (yeah, like GlassFish!).
In case I find some time to contribute something here, I'll report back. If you have feedback / contributions to the archetype, this is as usual very welcome (the code is available at our Google Code repository)!

Saturday, June 6, 2009

JavaOne 2009 Summary: Friday (Day 4)


Related Posts so far:
  • Day 0: CommunityOne, GlassFish
  • Day 1: JavaOne, Key Note
  • Day 2: JavaOne, Mobility
  • Day 3: JavaOne, Microsoft and IBM
=== The Toy Show hosted by James Gosling! ===
Welcome back, the final day has come and it's called "Toy Show Time" !

The whole show is not about standards or technical details, it is about Java, the Java ecosystem and how Java is used in its various situations driven by innovative people around the world:
  • The BlueJ team received a well-deserved special recognition for building tools that help millions of high school and college students get started with Java.
  • A fellow from RuneScape dev demoed their tools, and I learned how one animates a water troll, something that will surely come in handy one day.


  • JavaFX Demo with inversed Nintendo Wii Remote Control. See BOF descriptions in my last post. Instead of virtually painting on the wall, they used a piece of glass and it therefore looked like a scene of Minority Report :-)


  • Tor Norbye (a JavaPosse member) showed a very impressive JavaFX authoring tool whose release is planned in December. When JavaFX was presented the first time at JavaOne 2007 it looked good already but nothing really happened after that announcement. In 2008 it was pushed again but it did not kick off (again). Since the release of Java SE 6 Update 10 and this year's JavaOne, it is now really looking much much better! The demos of the upcoming JavaFX version by end of this year looked even better!! Together with Larry's indication to heavily push JavaFX forward, it might soon be a valid competitor of Flex and Silverlight.


  • There was a demo by the high school kids who won the FIRST robotics contest. Sun and the FIRST folks just ported the programming environment from C/C++ to Java.


  • The Grameen Foundation showed off an open source system for helping with microfinance in third world countries.
  • A fellow showed SIM cards running Java and a web server. The latest ones can interact with sensors and WiFi radios.
  • At the age of 14, James Gosling was working on some satellite ground station application running on a PDP-8... as of James, it had less compute power than a modern smart card :-) His mother took this photo by then:


    He was very excited to have on stage a guy showing a top-notch cutting-edge version of a satellite ground station management application used today and running fully on Java using over 1000 OSGi modules.

  • Two Hungarian university students showed off the project that won them first price in the Ricoh Printer Contest. Those printer/copiers are Java-powered and the students used them to grade multiple choice exams.
  • Atlassian wins Duke's Choice Award for Clover!


  • Another interesting guest was Visuvi: Not only can you upload (cell phone cam or hi-res) images to their search engine and have them analyzed (e.g. to answer the question "who painted that?"), but most importantly, the new image analysis technology is used for cancer research (e.g. you can search through a biopsy image database for visually similar cases). The database currently stores about 50 million images whereas a high-resolution image hold 3000 Mega Pixels and is about 60 GB !!!


  • A musician showed off a Java-powered juke box that allows independent artists to upload their creations to a web site and have it played in bars. As James put it: “Here's Manuel. He is a musician. He has a problem.”And with the help of a touch screen, a cash reader, and Java FX, he put together a solution. James had to insert a 1$ bill in order to run the demo :-) He said: "1$ for a starving musician"...


  • "Project Bixby" controls an Audi TT on a dirt rallye course going really fast (160 km/h) without a driver! This was very impressive...




  • And finally, the“LincVolt” project controls a 1959 Lincoln Continental with an electric motor, this time with a human driver: Neil Young! There is a Swing-based control panel in the car and while driving around, people can follow the data on the website. Fancy stuff... If I'm right, the car can produce 500 horse power !?
=== Technical Sessions ===
I'm still suffering from this week's firehose of information! It is again 2:35am... there will be only the titles of visited technical sessions without any comments. Sorry!
  • JCA 1.6 (by the two spec leads): most important take away: in addition to security context outflow there is now also security context inflow -> JCA 1.6 provides E2E security context propagation!
  • Google Guice (by Jesse Wilson)
  • Async with SCA (Apache Toscany)
  • JMS: Performance vs Reliability


=== Bye Bye San Francisco ===
After the last session (5.10pm) we had early dinner at the Chieftain Irish Pub. After that I headed back to hotel for writing the two posts (yesterday and today).

On the way to the pub we spotted these here...


Finally in the Pub: Anchor Steams... aaaah


At 9.30pm, we had a quick walk around block to take some photoshoots of SF by night:

Bye bye JavaOne, Hello WWDC!












This year's JavaOne was one of the best so far, not only due to the strong focus on Java EE 6 but also because of having talked to so many people, spec leads, experts and other visitors...
As said, time passed by so quickly, it's quite a shock realizing that all this is already over again...

Looking forward to bring back lots of infos, impressions and ... gadgets back to Switzerland!

CU soon
- Balz

Friday, June 5, 2009

JavaOne 2009 Summary: Thursday (Day 3)


Related Posts so far:
  • Day 0: CommunityOne, GlassFish
  • Day 1: JavaOne, Key Note
  • Day 2: JavaOne, Mobility
JavaOne Day 3 Summary

=== General Sessions ===
  • Microsoft in a general session!
    Corporate VP Dan'l Lewin started with the 5 year partnership with Sun and mentioned Microsoft's dedication to the interoperability topic between Java and .NET. As of a survey they did last year, 73% out of 5 million interviewed developers work in a mixed environment.
    At JavaOne 2006 Sun announced new workforces together with Microsoft to work on the interoperatbility topic. The demoed Apache Stonehenge is certainly an outcome of it, a prove also that Sun joined the project which serves as set of sample applications to demonstrate seamless interoperability across multiple underlying platform technologies (like Java and .NET). Key message here was that given the matured WS-* standards, interoperability was "possible" but the last mile on "how to correctly configure the products/framworks on each side" was still very hard to do. Now with Stonehenge the last mile gap is closed. The demo was presented by Greg Leake, a Senior Director at Microsoft, and Harold Carr, Sun's Lead Architect for the Metro Web Service Stack.

    Further resources: www.interoperabilitybridges.com



  • IBM: Extreme Transaction Processing and Elasticity
    Craig Hayman, IBM's vice president of WebSphere software, focused on the importance on open source and open standards development with Java. To demonstrate some of the work that IBM has been doing with open source to innovate in the middle tier, Hayman called to the stage Ted Ellison, vice president of the Apache Software Foundation and an IBM senior technical staff member, to give a demonstration of the Apache Harmony project. More details on the session see here.



    One particular slide in the presentation I found cool in particular: it showed again the evolution of architectures and their focus points:
    Mainframe based Architectures ->
    -> Client/Server Architectures ->
    -> Focus on Mobility Architectures ->
    -> Cloud Architectures
    ... what comes next? Unfortunately, I was not quick enough to take a photo of the slide... This one is good too:


=== Technical Sessions Highlights ===
  • Enterprise Integration Patterns in Practice
    by Andreas Egloff (Lead Architect GlassFish Fuji) and Bruce Snyder (Apache Camel)
    Besides the introduction of some integration patterns (like "Content Based Routing", "Pipeline Routing", "Spitter" and "Aggregator"), both presenters summarized two open source products that address this topic:
    - Fuji: The core of OpenESB v3, originating from Java CAPS, currently still beta (M6)
    - Apache Camel

    While both products surprised in their richness of functionality that certainly simplifies many application implementations, Fuji convinced us more and not only because it really cool web based UI (based on JavaScript!):



    In the Pavilion I talked to Andreas Egloff asking about clusterability: this will come next year with GlassFish AS v3.1 which by then will support clusters and Fuji will be built on top of that. Transaction Support: Fuji's focus is Ease of Development combined with strong focus on Enterprise implementations, so distributed transactions are fully supported as of the first release by end of this year.

  • Dealing with Asynchronicity in Java Web Services
    by Gerard Davison and Manoj Kumar (both Oracle)
    - nothing new, it was pure JAX-WS based async stuff

  • Bean Validation: Declare Once, Use Anywhere
    by Emmanuel Bernard
    Actually a very good presentation, Validation Cascadation, Groups (Subset of constraints), Partial Validation, Custom constraints, Metadata API!... Bean Validation is available across layers (JSF, EJBs, JPA): JSF2 requires zero config, JPA2: validate on entity change. In general, Bean Validators can be injected as Resources in Java EE 6.

  • eBay: Best Practices for Large-Scale Web Sites
    by Randy Shoup (Lead Architect of eBay)
    I expected a special large scale Java EE architecture but it was the contradiction of it:
    - no JDBC client transactions, no distributed transactions (2PC, XA)
    - no DB constraints in the DB schema
    - no HTTP session states (the state is kept in a combination of cookie/URL-params/DB)
    - no EJBs
    - everything is asynchronously processed

    I was surprised about the architecture very much, somehow I could not believe it but due to the success of eBay, it is obviously like that...

    Some backgrounds:
    No DB Constraints: The user profiles are kept in a DB RAC, the auction items are kept in another DB RAC. The 1:many relation between user and item was not based on constraints but was solved by treating it in a bottom-up approach...

    The best practices in a nut shell were:
    - Partition Everything (e.g. User Profile DB RAC, Item DB RAC, split data by load and usage pattern
    - Async Everywhere: Synchronous designs must address peak load whereas asnyc designs can flatten out peak loads and compensate at time of low loads
    - Automate Everything: Based on feedback loops the systems adapt their configuration automatically (sizing). This is achieved by defining SLA between consumer and producer components. If the consumer tends to violate an SLA, it starts to scale itself horizontally.
    - Everything can fail: all systems must be tolerant of failure
    - Embrace Inconsistency: He introduced the CAP theorem: Consistency, Availability, Partitioning. As of the theorem you can have only two of them. eBay selected availability (7x24) and partitioning according to its priorities. Consistency is seen as a spectrum and is therefore not comparable to "normal Java EE" designs.

    Some numbers:
    - 1.6 millions of transactions per second worldwide
    - 88.3 millions of user profiles
    - 160 millions of items
    - 2 Tera Bytes of logfiles per day
    - 2 billion page views per day (ebay.com)

  • Drizzle: A New Database for the Cloud

  • Various:
    - SpringSource Tool Suite (STS) is now for free!
=== BOFs ===
  • Enterprise Web 2.0 Architectures
    by Brazilian Consultancy Company Globalcode
    Goal of the session was to show how they compared different web application stacks and which stack suits best for which customer environment. Stacks considered were:

    1.) Pure Web: JSF 1.2, Facelets 1.1.x

    2.) Web + JMS + EJB: Compared to Pure Web: Business Logic in EJBs, not in JSF managed beans anymore
    3.) Spring: Pure Web + Spring components, Spring AOP and Spring Security
    4.) Seam: Pure Web + JSF/Ajax + Seam components and JBoss Rules
    5.) Seam + Spring: As of some customer they have in Brazil, a migration from large-scale Spring based applications was required to a Seam based model. In this very special case, they found out that both worlds can live together at the same time in the same application. They also found out that injecting a Seam component into the Spring container was possible and vice versa.


    It is definitly worth going through these slides and see the last table (criterias vs stacks): red cells indicate high risk, orange a potential risk.
    A big surprise was the public availability of a web based CRUD generator where you can enter the data model, select the stack and export a sample application as ZIP file containing the IDE project... Really nice!
    Check it out here: supercrud.com

  • JavaFX and the Nintendo Wiimote
    Take a Wii Remote Controller, mount it near the image source (TV, Beamer) and mount the infrared sensors (that are normally mounted near the image source) on your moving objects, in this BOF a normal glove. Write some JavaFX and off you go with a virtual paint panel wherever the beamer is projecting to :-)

    painting on the wall by using fancy JavaFX gadgets...




=== After Dark Bash ===
Back in 1999, I was in San Francisco in the very same hall at the ISSCC (International Solid State Circuit Conference) presenting the diploma thesis from ETH Zurich. In the very same hall, the official JavaOne After Dark Bash party took place... impressive!! Very loud live rock band performing on a huge stage accompanied by a food buffet and various drink bars.
While Dani was still at some JavaFX labs exercise, I spent some 45 minutes there and enjoyed the short break :-) After that, I went back to the last BOF (while Dani enjoyed the last hour of the bashing party :-)...



=== Bookstore ===
As usual, the book store always attracts each day again... this time:
- JSF 2 and JBoss Seam / WebBeans



Cu tomorrow, last day!

Thursday, June 4, 2009

JavaOne 2009 Summary: Wednesday (Day 2)


Back again... well I'm sorry to write this but I could not make it yesterday to publish the summary of Wednesday. It was 2:15am and I was very exhausted after having been up since 7am. So, I still hope you enjoy this summary as I try to include as much infos as a can within the given time from different sources in the net and myself.

Related Posts so far:


JavaOne Day 2 Summary

=== Mobility General Session ===
  • Christopher David, Head of Development and Partner Engagement at Sony Ericsson, was the main speaker for the talk. During his presentation, Erik Hullman (a Senior Java Developer with Sony Ericsson) was given the task to develop a JavaFX Twitter client from scratch that at the end of the presentation should be deployed to three different devices!
    As if the task would not have been complex enough: People in the audience could send questions or comments to his Twitter accound that he answered in parallel to his programming efforts... and at the end, the same deployable artefact worked fine on all three devices. Sounds promising!!

    Rikko Sakaguchi, Corporate VP of Creation and Development

=== Technical Sessions Highlights ===
  • Hudson: Continuous Integration in the Cloud with Hudson
    (by Kohsuke Kawaguchi --> Blog)
    - I very much like the automated distribution approach: You start the Master Instance with Hudson installed as well as with the Hudson PXE Plugin (Prebuilt Execution Environment). After that you start the Slave Instance (on another machine) and boot from the network. That's it!
    - The defined target machines can be flagged with so called "labels" and can be used to ensure that Test Units aimed for Windows machines are executed on Windows boxes (and same for Unix boxes).
    - The Hudson Master instance can run on Windows or Unix.
    - Cloud: The demo was about the creation of a CI environment in Amazon EC2. It was very impressive how quickly the setup was done and executed successfully.
    - Hadoop: Kohsuke also mentioned the rather new plugin for Hadoop which makes Hudson run on Hadoop.
    - Slides: PPT



  • "Effective Java": Still effective after all these years
    (by Joshua Bloch)
    As in his other presentations, Joshua presented his content in a very nice way accompanied by his typical kind of humour... As of the end of the day, his book was again "Number 1" in the Bookstore's Top Seller List.

  • JPA 2.0 (by Linda DeMichiel)
    The new Criteria API as well as the introduction of the pessimistic locking modes were interesting to follow. Overall, the session was a little bit too much on the theoretical side.

  • WebBeans! Sorry: JCDI, Java Contexts and Dependency Injection: JSR-299
    (by Gavin King)
    I just like the way Gavin presents, he has his unique style, very straight forward and nice to follow. JCDI targets to support stateful objects, builds the glue between JSF and EJB, allows loose coupling with strong typing and introduces very nice concepts like BindingTypes and DeploymentTypes.

    After the speech we asked Gavin about the other "DI" related JSR submitted by Bob Lee (Google) and Rod Johnson (SpringSource): JSR-330. It states "This JSR targets Java SE, and it will lay a foundation for dependency injection in Java EE." So it seems that this is a big discussion at the moment as the JSR-299 has started 3 years ago and is nearly finalized now and could make it easily into the final release of Java EE 6 by end of this year whereas the newly submitted JSR would take at least 1 year until its finalization and would eventually postpone the release of Java EE 6 as 299 would directly depend on 330. I'm very curious how this gets resolved. My personal hope is that they agree on a common dependency injection foundation for SE and EE and include that one with potential EE specifics in the nearly finalized 299 (During the Java EE 6 Panel Discussion BOF, William Shannon meant that the EG would never accept two different DI specs on the Java Platform, so a common sense must be found, and quickly).
    Links around this discusssion:
    --> Bob Lee's initial post (from May 5th, 2009)
    --> Gavin King's statement (from May 7th, 2009)
    --> Bob's comment on Gavin's statement
=== BOFs ===
  • JSF Platform and Ajax: State of the Union
    with Ted Goddard (Lead Architect of ICEfaces), Andy Schwartz (Oracle ADF Faces) and Alexandr Smirnov (RichFaces)
    This kind of panel discussion was very interesting as each of the presenters talked about the current status and the progress towards JSF 2.0. RichFaces and ICEfaces convinced most (RichFaces because of its seemless integration with Seam and ICEfaces because of its architecture and the unique feature of automatic Ajax Push based on server-side DOM-diffing (more here)).
    Woodstock was not represented. As of the presenters there are no plans for further releases. On ICEfaces there is a migration plan described from Woodstock to ICEfaces.

    Ted Goddard


  • Java EE 6 Experts Discussion Panel
    hosted by Roberto Chinnici and William Shannon
    Good discussions, questions and comments... I was surprised that JSR-299 was not mentioned at all in the presentation about Java EE 6. After having asked the question why it is missing, a big *sigh* from Roberto Chinnici :-) (as expected), then responding that they were not yet sure about the inclusion of JSR-299 in Java EE 6. I reformulated my question what the current trend would be, rather "in" or "out". After eye-contacting with William Shannon, William meant "give him the full story"... Then the story around "JSR-299 vs JSR-330" has been described (see WebBeans above for more details).


    William Shannon and Roberto Chinnici

=== Pavilion ===
  • At the ICEfaces booth we met Micha Kiener (also from Switzerland) who is working for Mimacom. We were introduced to the overall architecture of ICEfaces and that looked really cool (server-side DOM diffing, Ajax Push). The demo showed a very elegant way of doing Interportlet Communication (IPC) on Liferay Portal 5.2. Really nice!!

  • And some pictures from the Pavilion and its entrance area...




    Dani at the SpringSource booth
    where it says "Eliminating Enterprise Java Complexity"
    ...





Cheers

Wednesday, June 3, 2009

JavaOne 2009 Summary: Tuesday (Day 1)

Take a deep breath... Time is really rushing away, it is actually Wednesday night now (11pm), 50% already passed, but as promised in the previous post, there will be a summary of each day. So here it is!
Before kicking off, read the summary of Monday's ConferenceOne if you haven't done so already...

JavaOne Day 1 Summary

As every year, Day 1 started with the General Session, the key note by Sun itself and hosted this year by Sun's CGO (Chief Gaming Officer) Chris Melissinos.
Guests on stage were
  • James Barresse, VP of Architecture, Platforms and Systems with eBay
  • Alan Brunner, Senior VP for the Blackberry Platform
  • Dan Eklund, Executive VP of Advanced Technologies at Sony Pictures Home Entertainment
  • Lowell McAdam, President and CEO of Verizon
  • Diane Bryant, Executive VP at Intel
  • Ronan McBrien, JavaFX TV Architect (nice demo, video should be available here)
  • Nandini Ramani, Director for JavaFX
Some pictures:





Jonathan Schwarz about BDJ and BD Live


Java FX TV Demo:





=== Key Note Highlights ===
  • Oracle and the Future of Java:
    At the end of the key note, Scott McNealy called Oracle CEO Larry Ellison up on stage to address the $7.4 billion dollar question -- what will be the future of Java?
    My key notes from his answer are:
    - Oracle with a much greater R&D budget than Sun will be able to even more push Java forward. Quote: "I don't expect a lot of changes, just expanded investment and a lot of enthusiasm coming from Oracle."
    - He mentioned JavaFX many times, he wants OpenOffice to use JavaFX as UI. He also mentioned that it would be interesting to see Android based phones and netbooks from Sun running Java and JavaFX. Rumors say that pushing JavaFX will secure his seat in the UI battle between Silverlight and Flex.
    - "Look at the past to see the future": by this he most probably meant Oracle's dedication to Java since its birth, its commitment to support the community and to actively participate in Java's future.
    - Interesting Link about Larry's talk
    - Some pictures:
    Scott mentioning that Larry might have more luck
    to bring the JVM on the iPhone :-)


    "Mr. Oracle"


    - And enjoy the following video:



  • Java Store! presented by James Gosling: still in beta, community is asked to give feedback on how payments should be implemented.

  • Release of Java FX 1.2 !


  • "The classpath is dead": Chief Engineer of Java SE, Mark Reinhold, said this after having shown a nifty demo on how Java SE 7 manages modules.


  • "The web.xml is dead": CTO at Sun, Bob Brewin, said this while talking about the next enterprise release Java EE 6.

  • Announcement of JATAF ! The Java Application Terminal Alignment Framework is an open, collaborative community striving for a unified Java ME platform.

  • Project Dark Chat: Nice demo app for the JavaOne.
    --> Download this JNLP file (jre6u10 required)

  • DJ Anna: for me as a fan of electronic music, the opening sounds mixed live by DJ Anna, a local DJ of San Francisco, are always a pleasure to listen to...






  • and of course: Gosling's T-Shirt Tossing!!!


=== Technical Sessions Highlights ===
As it got already very late and I am still writing about yesterday!, more take aways from the technical sessions will follow (as CTP internal Knowledge Shares or in form of upcoming blog posts):
Interesting sessions were EJB 3.1, Servlet 3.0, Java EE 6 and GlassFish v3, Spring 3.0, JSF 2.0 and others...



=== BOFs ===
  • The most exciting BOF was of course the one of JavaPosse !
    Download the mp3 and listen yourself what happened!! :
    Episode 0x100 (#256)

    As last year, the beer got sponsored by Atlassian and started with some polls from the audience. After that, they talked about topics and news they picked up during the first day...
    After the show we joined them for some drinks at the Kate O'Briens pub near Moscone. I could finally tell Joe to accept my friend request on Xbox360 in order to see his hotlaps in Forza2 (he is actually a real race driver, watch this video if you don't believe me) and Carl told us some more details about his brand new Tesla (100% electric car)... A great moment in life indeed to finally get to know these dudes! :-) I could not talk much with Dick Wall unfortunately... One more reason to go again to JavaOne! ;-) At least one important thing I could tell him: Talk more about Enterprise stuff!












  • BOF about Lift: The Best Way to create RIAs with Scala
    (by David Pollak, Lead of the Lift Framework)

    to be honest, I can't comment on this content-wise... The way it was presented was cool (I like the humour of David Pollak), it was also interesting to see how he quickly implemented a fully functioning ajax based chat tool from scratch in less than 100 lines of code :-) but I could only take this one with me: Learn Scala first, then lift off with Lift.... ok! -> Scala book bought!!

Good night (oh no... in 5 hours the alarm kicks on :-),
Balz

Tuesday, June 2, 2009

JavaOne 2009 Summary: Monday (CommunityOne)


JavaOne has not officially started yet, it's Monday and not Tuesday, it's CommunityOne and not JavaOne, but the community spirit already caught us and punched us into the geeky experience of the world's biggest Java conference in the nice Moscone Center in San Francisco... main focus of today's sessions was on GlassFish stuff... In a nutshell: Niiice!!

So here is our summary of today's CommunityOne day (after having had some beers at the OpenSolaris & Sun Cloud Party in Hall A):

=== Sessions ===
  • Sun GlassFish Application Server Portfolio (by Eduardo Pelegri-Llopart from Sun): Where Sun's Platform Is Going:
    not much news for us actually... no infos regarding how Oracle want to proceed with GF
  • Running Seam on the GlassFish Application Server (by Dan Allen from Red Hat):
    - Seam best works with Hibernate as persistence provider (and looks for it in the classpath). GlassFish v2 comes with Toplink, Glassfish v3 with EclipseLink. Dan Allen from Red Hat made a nice summary of all the tweeks you have to apply in order to make Seam work with GF's default persistence provider.
    - Dan further went into differences of JBoss AS and GlassFish AS which also brought some steps to be done if Seam should run on GF.
    - But: from a developer perspective, such details are not necessarily required to be known as "seam-gen" supports both application servers out of the box. We asked Dan about support of Oracle WebLogic Application Server and he pointed us to a chapter in the Seam documentation. As that is not the whole story (as of my current status), we might come up with our additions soon...
  • Lightning Talks!
    This special type of talks runs throughout the day, split in multiple parts of 50 minutes each where every part again contains up to 8 very short speaches... I visited part 3 covering:
    - The Mural Project
    - Deep Dive Sneak Peek Sun Learning Services
    - Atmosphere (by JF Arcand!): good to know that Atmosphere is not only useful in containers not supporting Servlet 3.0: it autodetects Servlet 3.0 and still provides a nice abstraction of the rather complex Async API of Servlet 3.0
    - Adding AJAX Push (Ted Goddard from ICEsoft, focusing on ICEfaces of course)
    - Alice
    - BluJ
    - In a summary: Cool to listen to, nice to get an impression of the topic and good as decision maker whether to go to the full sessions on certain topics not already being enrolled in your schedule...
  • Developing RESTful Web Services with JAX-RS and Jersey (by Marc Hadley and Paul Sandoz from Sun)
    - The two spec leads of JSR-311 made a quick walkthrough from the architectural style REST to the JSR-311 (JAX-RS) and showed two demos running on the reference implementation Jersey.
    - One demo showed how JCDI (JSR-299, fka WebBeans), Java Contexts and Dependency Injection works together with Jersey using Google Guice. This was interesting, and in a side remark he recommended to have a look at Guicey Fruit running on Guice 2.0. Geeks... but we like it ;-)
  • EclipseLink - The Road to JPA 2.0 (by Doug Clarke from Oracle and Co-Lead of the EclipseLink project):
    - no much news for us at this moment
=== Pavilion ===
  • The Pavilion opened at 3pm. Between the sessions and after 5pm, it was interesting to walk from one booth to the other until 7pm when it closed.
  • GlassFish, Portals: We talked to Srikanth Konjarla (Software Architect of Web Space Server, aka WebSynergy Project having the same codebase as the Liferay Portal). He was also not allowed to talk about how Oracle will continue with the GlassFish products like WebSpace Server (Portal) and the GlassFish Application Server... we hope for more details in tomorrow's general session!
  • Atlassian: We had quite a deep introduction by Douglas Butler (thanks!) into the new versions of Atlassian's products:
    - JIRA (4.0 beta)
    - Confluence (3.0 released TODAY!!)
    - Fisheye together with Crucible
    - Bamboo and Clover -- Really nice what we have seen here!
    - The new versions generally invested a lot into the visualization of data, hiding complexities by using more wizards but also many things happened from an integration point of view:
    - Atlassian released widgets/gadgets to be deployed into any portlet container in order to create nice dashboards etc.
    - They will also soon provide RESTful interfaces for all their products to freely integrate them into any other app.... This sounds very cool indeed.
    - And the give-away gadgets are nice too ;-) Have a look at their new T-Shirts: If you wear one of those and have it filmed by an Atlassian camera, some things get out of the shirt!! ;-)

    - And yes, they acquired GreenHopper (announced TODAY).
  • Livescribe: At last year's Java One, Livescribe presented their JavaME based pen and sold 150 pieces right after the general session... I also bought one. I'm happy to see that the company still exists and that they heavily extended their features (e.g. Pencasts). At their booth today I got a nice little paper blanks (which is not sold in Europe so far).
  • Vaadin: IT Mill has released the 6th version of their server driven RIA framework known as IT Mill Tollkit. Together with the release they rebranded it into Vaadin. It is free, open source and looks actually very much like GWT... The demo looked very nice. Certainly worth having a closer look at it!
  • James Gosling: Spotted early at the Pavilion entrance! ;-)

  • Sun Cloud: We haven't had the chance to check out the details of Sun Cloud yet but with the rather big party this evening sponsored by Sun Cloud and OpenSolaris we expect a bigger announcement by tomorrow... so stay tuned.
  • NUUX: We also met Ben (an Alumni CTP Consultant) at his booth in the Java Utopia corner. Check out his website!!
  • Anchor Steam Beer: San Francisco's local beer is really worth to be mentioned here as single item ;-) and it tasted great in the OpenSolaris branded glass!


=== Bookstore ===
=== Tomorrow ===
Sure, lots of interesting session are registered in our schedule, but:
tomorrow is also the long expected JavaPosse BOF from 9.30pm to 10.20pm, so don't expect a summary like this after that :-) We will most probably post a 2-day summary on Wednesday evening... ok?
So cu then! And don't forget to follow Balz @ Twitter for live updates!
- Cheers, Balz & Dani.

Friday, May 29, 2009

JBoss Seam Hot Deploy with Maven - EAR Projects

As requested on some comments on my previous posts (initial post and update), the Seam Hotdeploy Maven plugin now works also with EAR projects.

Some more details on how to configure your project can be found in our Google Code Wiki. The plugin now defines a new packaging type for Seam WAR modules - the only possibility to override the war:war goal in the package phase.

If you're interested in how to override the default lifecycle Maven goal, you can check out the plugin source - something I haven't been able to google easily. Or, maybe wait for a dedicated blog post - stay tuned!

Something you should definitely checkout with the Hot Deploy plugin is the Maven CLI plugin. See the great post from Dan here, or the integration in the sample POM.

As usual, feedback and contributions are very welcome!

Friday, May 15, 2009

CTP @ JavaOne 2009


Only three weeks until Java One! Can't believe it's less than one month away!!
So let's have a look at what we think is hot this year. As every year, the conference has a certain umbrella topic where this year's JavaOne is certainly in the light of Java EE 6:
  • JavaEE6: JSF 2.0 @ TS-4640 (by Ed Burns)
  • JavaEE6: Servlet 3.0 @ TS-3790
  • JavaEE6: JPA 2.0 @ TS-5214
  • JavaEE6: Contexts & Dependency Injection (WebBeans) @ TS-6726 (by Gavin King)
  • JavaEE6: EJB3.1 @ TS-4605
  • JavaEE6: Developing JPA Applications with NetBeans and EclipseLink @ TS-5018
  • JavaEE6: JAX-RS (REST) @ BOF-4878
  • JavaEE6: Glassfish v3 (JavaEE6 Reference Implementation) @ TS-4923
  • JavaEE6: JCA 1.6 @ TS-4733
  • JBoss Seam: Conversations and Page Flows on the JSF Platform @ TS-5045 (by Seam in Action author Dan Allen)
  • Java Posse BOF @ BOF-4418 with Dick Wall (he likes the Groovy! :-), Joe Nuxoll and Carl Quinn, why is Tor Norbye not listed? Probably still digesting Snoracle!
  • Google App Engine @ TS-3817
  • Building JavaEE based Web Apps with Google Open-Source Technology @ TS-4062
  • Effective Java: Still effective after all these years @ TS-5127 (by Joshua Bloch!)
  • Defective Java Code: Mistakes that matter @ TS-5335
  • Metro Web Services Security @ TS-4402
  • Enterprise Integration Patterns in Practice @ TS-4839
  • SOA at Enterprise Scale @ TS-5123
  • Spring 3.0 @ TS-5225 (by Rod Johnson)
Of course there are much much more topics addressed like Scala, JavaFX, Java Mobile including Bluray Disc Java, lots of sessions about Cloud Computing, GWT, Groovy, OSGi and many more...

Interesting sessions at the CommunityOne West Conference (starting 1 day before JavaOne):
  • Oracle EclipseLink: S308133
  • SUN Glassfish Portfolio: Where is it going?: S307894
  • Architecting robust Applications for Amazon EC2: S304314
How to get updates:
  • Follow Balz live from JavaOne via his Twitter account (also see widget at the end of this post)
  • Follow other twitworks: Kevin Farnham or the JavaOne official twitwork
  • Java.net will produce again lots of Podcasts (not Pencasts!):
    The Schedule has been published already.
  • And: Check this blog after JavaOne for a summary!
Cheers!








Friday, May 8, 2009

CTP Java Pencast #1

Welcome to the first pencast!
Switch on audio to fully enjoy the show!
Be aware that this has been recorded in one single shot and without any post-processing...



Shownotes:
  • JavaME enabled pen by Livescribe
  • Customer Technology Stack: JSF 1.2, JBoss Seam 2.1 (with jBPM), Hibernate 3, WebLogic Server 10.3 or JBoss Application Server 5
  • Java EE5 : JSF 1.2, EJB 3.0, JPA 1.0, Glassfish v2
  • Java EE6 : JSF 2.0, EJB 3.1, JPA 2.0, Glassfish v3
So come back to visit us for checking details on the discussed web technology stacks!

Monday, April 20, 2009

Portal Update March / April 2009

Winter has turned into Spring, at least here in Switzerland... and in parallel to the brighter days, let's bring some light into the Java Portal area as well: What products are interesting these days and which should be followed for sure in 2009?

From the commercial side, major players are:
Open Source portals that have the most promising potential at the moment are:
  • Liferay Portal 5.2:
    back in August 2008, SUN and Liferay announced their partnership to work jointly on the next portal generation and presented their roadmap, Liferay keeping their Liferay Portal and SUN continuing their WebSynergy project).

  • SUN's brand new Web Space Server:
    Since February 2009, SUN has released Web Space Server version 10 which is including all the efforts from the internal Project WebSynergy. WebSpace Server is not only a portal product, it is a full fletched portal platform and has been integrated into the Glassfish Portfolio.
    For more info, read their first documentations.

  • JBoss Portal 2.7.2:
    - On March 12th, JBoss has released the latest version of its portal product and is available for download.
    - On Apr 3rd, JBoss released the JSR-301 compliant Portlet Bridge CR1. Currently the bridge supports any combination of JSF, Seam, and RichFaces to run inside a portlet.

  • eXo Portal 2.5.1

  • Jetspeed 2: no updates since version 2.1.3 from December 2007.
From a portal technology point of view, it is interesting to see the product's maturity with regards to the following standards:
  • JSR-168 - Portlet Specification (final since Oct 2003)
  • JSR-286 - Portlet Specification 2.0 (final since June 2008)
  • WSRP 1.0 - The first specification of Web Services for Remote Portlets (final since August 2003)
  • WSRP 2.0 (final since April 2008)
  • JSR-301: Portlet 1.0 (JSR-168) Bridge Specification for JSF 1.x:
    Current Status: proposed final draft in Jan 2009
    Currently available implementations of JSR-301:
    - MyFaces Portlet Bridge
    - OpenPortal Portlet Bridge (used in Liferay Portal)
    - JBoss Portlet Bridge (used by JBoss Portal)
  • JSR-329: Portlet 2.0 (JSR-286) Bridge Specification for JSF 1.2:
    too early for products to support this JSR as it has been created in January 2009 and is in the status "Early Draft Review" as of March 2009.
    Note that this specification is led by Oracle exclusively at the moment.
  • JSR-314: JSF 2.0:
    The support of JSF 2.0 in a portlet container is not yet officially addressed. There is no JSR around like "Portlet 2.0 Bridge for JSF 2.0".




Besides the Portal related activities, let's have a look on Java related quick news:
  • SUN has announced that Glassfish v3 Milestone 2 will be ready by Java One 2009 in June.
    For the complete schedule, click on this link.
  • Liferay 5.2 is now fully supporting WSRP 2.0 with the release of the WSRP 2.0 FCS binary.
  • Oracle & SUN: Oracle buys SUN as of the announcement on April 20th 2009.
    It will be very interesting what will happen to SUN's products like
    - The whole Glassfish Portfolio
    - MySQL
    - Netbeans
    - OpenSolaris and
    - JavaFX
  • Java EE 6: The JSR-316 has passed the Public Review state. See its results.

Friday, April 17, 2009

Java People Spotlight: Domenico Crescenti

In this edition of the "CTP People Spotlight" series we introduce Domenico, one of the CTP competences for content related topics.

Java Competence Role:
Messica (insider)
My Master Kung-Fu Skills
:
They call me Mr. Bean
I'd be excited to get my hands dirty on:
JCR 2.0 (JSR-283)

Q&A

Q: Hi Domenico, how would your message look like if you would have to tell it via Twitter what you are currently doing?
A: I'm buying some insecticide to feed the bug in my code :)

Q: What was the greatest piece of code you have ever written so far?
A: That was definitely the play fair chiffre

Q: What is the best quote you have ever heard about programming?
A:
"Cool!!! You didn't mess up my code"

Q: What is the best quote you have heard from our managers?
A: "........."

Q: What is the most cutting-edge technology or framework you actually used on projects?
A: Vamosa!

Q: What is your favorite podcast?
A: Discovery Channel Video Podcast – the US original of course – and the Java Posse Podcast

Q: Which Java book can you recommend and for what reason?
A: Java (Taschenbuch) by far the best Java book I’ve ever read.

Thursday, April 16, 2009

JBoss Seam on Google App Engine - First Steps

I spent the last three weeks in a repetition course of the Swiss army - far away from any Java code. Naturally my fingers started to itch while reading the announcement of Google that their App Engine now supports Java! So I grabbed my MacBook to enjoy the sun, Java coding and Eastern holidays.

As I usually write web applications with JBoss Seam, I decided to give the framework a try in the Google cloud - preparing for a bumpy road as Seam founds on standards which are mostly listed as either not or not known to be working. The following article describes the (bad) tweaks I had to do to get something basic running - I guess if you start doing serious development, you might hit more walls.

First, install the Eclipse Plugin for App Engine and create a new project. I'll base my descriptions on this initial setup. Switch on sessions in appengine-web.xml:
<sessions-enabled>true</sessions-enabled>

Setting up JSF 1.2

Download the latest Mojarra 1.2 release [1.2_12] and put it in the WEB-INF/lib directory. You can configure the Faces servlet in web.xml as usual
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.seam</url-pattern>
</servlet-mapping>

Starting Jetty with only this will fail due to some incompatibilities of Jetty and Mojarra. As with Seam we will need JBoss EL anyway, we can configure Mojarra to use the JBoss EL ExpressionFactory. Add the JBoss EL JAR to WEB-INF/lib and the following XML to your web.xml:
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>

Now it's already patch time. Jetty in the Google environment seems to have a bug in its Servlet API implementation, missing the ServletContext.getContextPath() method (new in version 2.5). Also, Mojarra tries to be clever about initialization work and uses Threads in the ConfigManager - the App Engine SecurityManager will let the whole thing blow up. Something similar happens in the JBoss ReferenceCache class. All patched classes can be found here. Drop the Java code in your source folder, Jettys classloader will pick it up.

This will at least make the whole thing start up. I also added facelets (JAR file, view handler in faces-config.xml and view suffix in web.xml).

Unfortunately, using RichFaces components is an absolute no go on App Engine. RichFaces is full of references to AWT or JAI classes, which Google blocks completely. If anybody wants to try ICEFaces - good luck!

Adding Seam

Now it's time to add all the Seam stuff. Quite a couple of JARs to put into the application. I basically used Seam 2.1.1.GA and libraries from JBoss 4.2.3.GA. The complete list of what should go into WEB-INF/lib is shown in the screenshot below.



JTA is not even on the list of APIs Google gives a recommendation, so let's fall back on Java SE behavior. Configure components.xml with:
<transaction:entity-transaction entity-manager="#{entityManager}"/>


Although we cannot use Hibernate as persistence provider, Seam has a couple of dependencies to it (e.g. when using Hibernate Validators). As soon as we have it in the classpath, Seam activates its HibernatePersistenceProvider component. This will behave pretty bad, and for simplicity we just override this component:
@Name("org.jboss.seam.persistence.persistenceProvider")
@Scope(ScopeType.STATELESS)
@BypassInterceptors
@Install(precedence = Install.APPLICATION,
classDependencies={"org.hibernate.Session", "javax.persistence.EntityManager"})
public class OverrideHibernatePersistenceProvider extends PersistenceProvider {
}

Now also add a persistence provider as described in the Google docs and disable DataNucleus checking for multiple PersistenceContextFactory instantiations with this property in appengine-web.xml.
<property name="appengine.orm.disable.duplicate.emf.exception" value="true"/>


As before, also Seam needs a couple of patches. Main reasons for those are references to javax.naming.NamingException (which is not white listed, credits to Toby for the hint) and session/conversation components not implementing Serializable correctly. The last point is probably something not hitting Seam or your application the last time.

Identity

As a next step I tried to add some users to the application. Seam's Identity module builds around the javax.security.auth.Subject and Principal classes. Even though those classes are white listed, the SecurityManager blocks any attempt to add a Principal to a Subject. Well, how useful is that... As a quick fallback I integrated the Google Accounts API:
@Name("org.jboss.seam.security.identity")
@Scope(SESSION)
@Install(precedence = Install.APPLICATION)
@BypassInterceptors
@Startup
public class AppEngineIdentity extends Identity {

private static final long serialVersionUID = -9111123179634646677L;

public static final String ROLE_USER = "user";
public static final String ROLE_ADMIN = "admin";

private transient UserService userService;

@Create
@Override
public void create() {
userService = UserServiceFactory.getUserService();
}

@Override
public boolean isLoggedIn() {
return getUserService().isUserLoggedIn();
}

@Override
public Principal getPrincipal() {
if (isLoggedIn())
return new SimplePrincipal(getUserService().getCurrentUser().getNickname());
return null;
}

@Override
public void checkRole(String role) {
if (!isLoggedIn())
throw new NotLoggedInException();
if ((ROLE_ADMIN.equals(role) && !getUserService().isUserAdmin()) || !ROLE_USER.equals(role))
throw new AuthorizationException(String.format(
"Authorization check failed for role [%s]", role));
}

@Override
public boolean hasRole(String role) {
if (!isLoggedIn())
return false;
return ((ROLE_ADMIN.equals(role) && getUserService().isUserAdmin()) || ROLE_USER.equals(role));
}

@Override
public String getUsername() {
if (isLoggedIn())
return getUserService().getCurrentUser().getNickname();
return null;
}

public String createLoginURL(String destination) {
return getUserService().createLoginURL(destination);
}

public String createLogoutURL(String destination) {
return getUserService().createLogoutURL(destination);
}

public User getUser() {
if (isLoggedIn())
return getUserService().getCurrentUser();
return null;
}

private UserService getUserService() {
if (userService == null)
userService = UserServiceFactory.getUserService();
return userService;
}

}

Both create... methods can be used in the UI for generating login/logout URLs. Destination defines the URL the user gets redirected after successful login/logout. Also make sure that the identity configuration is removed from components.xml

Wrap up

Running this setup should give you a base for a very simple Seam app like in the screenshot below.



This first step has not been doing any persistence work, and my first tries with DataNucleus were not as straight forward as I had expected from a JPA implementation. Hope Google will catch up here with something more mature. Also, even the simple setup required a couple of nasty tweaks on the frameworks. Another big hurdle here are the runtime differences from production to local environment. For some serious work on App Engine, it's so far more recommendable to look into GWT.

Anyway, if you found this useful - looking forward to hear from your next steps in the cloud.

Friday, March 20, 2009

JBoss Seam Hot Deploy with Maven - Update

I just published an updated version of the Seam Hotdeploy Maven Plugin (see my previous post here). For a detailed description on how to use it, have a look at the Google Code Wiki. I also updated the sample Maven POM featuring JBoss Seam 2.1.1.GA.

The new version should be easier to configure and play nicer with e.g. the Eclipse Maven plugin (I'm not using NetBeans/IntelliJ too often, but I hope this works also fine there). The new Eclipse builder configuration looks like shown in the image below:



Note: The Eclipse Maven plugin using its embedded Maven had somehow problems with the extended lifecycle of the Hotdeploy Plugin. Using an external Maven installation (2.0.10) felt not only faster but was also not having problems with it.

Friday, February 13, 2009

Java People Spotlight: Daniel Käppeli

The "People Spotlight" series continues with a Java fellow who is at Cambridge Technology Partners since years now: Dani is continuously working in projects that most often deal with Open Source technology stacks.

Java Competence Role:
Senior Developer
My Master Kung-Fu Skills
:
... there are so many to choose from ...
I'd be excited to get my hands dirty on:
Java EE 6 : see how all the bits and pieces fit together

Q&A

Q: Hi Dani, how would your message look like if you would have to tell it via Twitter what you are currently doing?
A: Recovering from a busy week and from yesterday’s dinner.

Q: What was the greatest piece of code you have ever written so far?
A: Parsing an XML document in 1 LoC with Spring OXM. Isn't that cool?



@SuppressWarnings("unchecked")
JAXBElement<GpxType> object = (JAXBElement<GpxType>)this.getUnmarshaller().unmarshal(new StreamSource(inputStream));

Q: What is the best quote you have ever heard about programming?
A: “These performance improvements are quite slow!”, K. K. 02.09

Q: What is the best quote you have heard from our managers?
A: "In the next quarter the hockey stick effect will kick in."

Q: What is the most cutting-edge technology or framework you actually used on projects?
A: RESTful Web Services with Jersey
Q: Wow! I actually didn't know that CTP uses that already... so we belong to the very early adopters of JSR-311 in customer projects! Nice Dani... when are you doing a Knowledge Share on this? ... Ok let's keep on with this short questionnaire first.

Q: What is your favorite podcast?
A: Discovery Channel Video Podcast – the US original of course – and the Java Posse Podcast

Q: Which Java book can you recommend and for what reason?
A: Joshua Bloch’s Effective Java Second Edition, by far the best Java book I’ve ever read

Friday, January 30, 2009

Portal Update January 2009

After the snowy december we are back with new posts this year and we are looking forward to an interesting year! Java EE 6 is the late christmas present for many of us Java aficionados and it is going to be released probably around JavaOne in June...

In the portal corner, the following was important this month:
  • SUN: no updates

  • Liferay:
    - One UI to rule them all: Check out this introduction of a new management console in Liferay Portal. This portal product is definitely going to be more and more interesting among the free portal products!

  • Oracle:
    - Oracle Fusion Middleware Radio has released some talks about portal product roadmaps. No much news if you followed all our portal updates so far ;-). But if you are interested in to listen to them, here they are:
    Oracle WebLogic Portal Roadmap (formerly BEA WebLogic Portal)
    Oracle WebCenter Interaction Roadmap (formerly BEA AquaLogic User Interaction)
    Oracle Portal
    Roadmap

  • JBoss:
    - Release of JBoss Portal 2.7.1 which is a maintenance release for the 2.7 series that support JSR-286 portlets. The detailed release notes can be found here.
    - The JBoss Portlet Bridge has reached Beta 6 and it integrates Seam and RichFaces. Documentation on this Beta release can be found here.
    - Next-Gen Identity API for JBoss Portal is in public review. Check their documentation here.

  • eXo:
    - eXo Portal 2.5.1, a maintenance release, is now available and has finalized its support of Right-To-Left languages like arabic. See video here.
    - eXo Portal and Spring Security: This is a very nice documentation released in January about how to integrate Spring Security 2.5.x into eXo Portal.

  • Other portal and Java related quick news:

    Jan-26: JSR-299: WebBeans is dead. Long live Java Contexts and Dependency Injection!

    Jan-23: Java EE 6 has gone Public Review!
    - WebBeans (Gavin King, JSR 299, @TA )
    - Bean Validation (Emmanuel Bernard, JSR 303, @TA )
    - JSF 2.0 (Ed Burns & Roger Kitain, JSR 314, @TA )
    - Servlet 3.0 (Rajiv Mordani, JSR 315, @TA )
    - JPA 2.0 (Linda DeMichiel, JSR 317, @TA )
    - EJB 3.1 (Ken Saks, JSR 318 @TA )
    - JCA 1.6 (Binod PG & Sivakumar Thyagarajan, JSR 322, @TA )

    Jan-18: Performance Analysis: VisualVM 1.1 has been released!
    Dec-16: JBoss Application Server 5.0 has gone GA. So JBoss has finally joined the list of "Java EE 5 Compatible Implementations".

  • NetBeans:
    - Portal Pack 3.0 Beta is now available
  • IBM: no portal news
  • Eclipse: no portal news
  • IntelliJIDEA: no portal news

Saturday, December 6, 2008

Using JBoss Seam Hot Deployment with a Maven Build

[UPDATE: The new plugin version is documented here]

As you might have read in previous posts, one of our favorite web application stacks consists of JBoss Seam. While combining this with our favorite tooling suite consisting of Eclipse and Maven, we had to realize that Seam has a much longer tradition with Ant, and Maven support is only slowly moving in. Today I want to share some ideas on how to tackle the combination issues.


While JBoss Tools provides a nice code hot deployment feature when working with Seam on JBoss, things can get a little hairy when using a Maven build with the project. Seam uses a special classloader and relies on monitoring the WEB-INF/dev folder for changed classes - where Maven is completely unaware of this and uses the standard WEB-INF/classes folder to deploy all classes in the project. More than once I've seen the situation where JBoss Tools and Maven got in each others way, ending with JBoss rejecting to restart the application due to "duplicate components". The reason was that Eclipse hot deployed classes to WEB-INF/dev where Seam expects them, but Maven being completely unaware of it packaging all classes in the common WEB-INF/classes folder.

In order to avoid trouble and also to allow using hot deployment from a command line build, I experimented with several approaches to achieve hot deployment with Maven. The main challenges here are:
  • Distinguishing compiler output: The Maven compiler plugin by default compiles everything in the same output folder. We need to be able to distinguish between hot and regular deployable code.
  • Publish updated resources to JBoss, including domain model classes, seam components as well as XHTML pages.
  • Make sure Seam unit tests still compile.
The solution I came up with was to write a new Maven plugin which extends the Maven compiler plugin with a new hotdeploy:compile goal and the following functionalities (source code as well as a simple Maven 2 repository is available in our Google Code account):
  • Hook into the compile phase and compile the source code to a dedicated directory. The source code location is configurable as well as the output directory.
  • Remove outdated hot deployable class files from the JBoss deployment. This is necessary for the Seam classloader to pick up the changes, only updating the file is not enough.
The plugin configuration is straight forward as it's based on the regular compiler plugin and is shown in the XML snippet below. Note that it is recommended to create a profile for this build setup as both your continuous build as well as your operations team might not care too much about using hot deployment.
<plugin>
<groupId>com.ctp.seam.maven</groupId>
<artifactId>maven-hotdeploy-plugin</artifactId>
<version>0.1.0</version>
<configuration>
<source>${java.source.version}</source>
<target>${java.source.version}</target>
<hotdeployOutputDirectory>${directory.hotdeployables}</hotdeployOutputDirectory>
<includes>
<include>**/session/**</include>
</includes>
<deployDirectory>
${directory.deploy.jboss}/${build.finalName}.${project.packaging}
</deployDirectory>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>

The main additions to a regular compiler plugin setup are:
  • This variant uses the common /src/main/java source folder and uses in- and excludes to distinguish the hot deployable sources. Alternatively you can set the sourceDirectory configuration value pointing to a dedicated source folder (similar as JBoss Tools does the setup for you). Don't forget that this requires then the Build Helper Maven plugin to add source folders to your regular build.
  • The deployDirectory is a reference to your exploded application directory inside the JBoss deploy folder. This is needed in order to remove outdated hot deployable classes.
  • You can specify the hotdeployOutputDirectory directory where the code should be compiled to. Note that this defaults to the value shown in the example - feel free to skip this part. The plugin will compile into this folder after appending a WEB-INF/dev to the path.
The rest of the setup we can do by simply reconfiguring existing plugins. Note the Google Code Wiki contains a complete sample POM ready for you to start your own Seam webapp. The details on the configuration are:
  • Reconfiguring the WAR plugin so the webappDirectory points inside our JBoss deploy folder. Maven uses this folder to assemble the WAR file, which perfectly corresponds to an exploded deployment. Additionally we define our hot deployment compilation folder as a webResource, which will copy our compilation exactly to the WEB-INF/dev folder in the exploded deployment.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${directory.hotdeployables}</directory>
<filtering>false</filtering>
</resource>
</webResources>
<webappDirectory>
${directory.deploy.jboss}/${build.finalName}.${project.packaging}
</webappDirectory>
</configuration>
</plugin>

  • Similarly, we have to add our output folder to the test classpath. This is simplest done by adding it as a resource folder, which will copy the classes to the target/test-classes directory before the test classes are compiled:
<testResources>
<testResource>
<directory>${directory.hotdeployables}/WEB-INF/dev</directory>
<filtering>false</filtering>
</testResource>
...
</testResources>

If you want to run a similar luxury setup as you get from JBoss Tools, you can add a Maven builder to your project. Simply go to the Eclipse Project properties and click "New" on the "Builders" properties. The new Maven build should look like the following:



Make sure that the following conditions apply to your Eclipse setup:
  • The JRE you have configured is actually a JDK - otherwise the builder will fail. Once you see that the builder does not fail, you can also switch off the console allocation in the "Common" tab.

  • Also take care that you always build with your specific hot deploy profile - otherwise make sure to clean before using the build again.

  • Assert that Eclipse uses a dedicated output folder and not the Maven target/classes.

Unfortunately when activating the builder Eclipse might prompt you when editing files and (depending on the speed of your machine) hang for a second or two after saving a file. Still, this is much better than waiting a minute for your JBoss server to restart.

Happy coding!

Friday, November 28, 2008

Portal Update November 2008

Another month has passed, year end is close so let's see what happened this month in the portal space:
  • SUN:
    - WebSynergy Milestone 3 Release! This is the last milestone release before the upcoming commercial release. Enhancements are mainly in documentation, integration between Liferay and WebSynergy.

  • JBoss:
    - JSR-286 Portal: Release 2.7 has been released on Oct 30th, right after I posted last month's summary ;-) This release supports all features specified by the Portlet 2.0, namely Public Parameters, Portlet Resource Serving, Portlet Filters, Portlet Coordination and provides some additional features not actually specified by JSR-286.

  • eXo:
    - eXo Portal 2.5 beta released: Fully JSR-286 compliant, supports Google Gadgets and comes with an integrate Gadget Repository
    - At DevFest in Bangkok, eXo announced a new product called eXo Social. It is consisting of two modules, eXo People and eXo Spaces, both running on top of eXo Portal 2.5. Both modules feature API based on OpenSocial and will bring social networking closer to the enterprise!
    The release of eXo Social 1.0 is targeted for January 2009.

  • Oracle (BEA):
    In some Oracle Open World 2008 slide decks I picked up these interesting statements:

    WebLogic Portal (WLP):
    - The whole WSRP framework of the WebLogic Portal will be integrated into WebCenter
    - WebLogic Portal's VCR (Virtual Content Repository) will also be integrated into WebCenter
    - Supported Content Management APIs in next year's releases of Oracle's portal products will be focused on JSR-170, REST and the recently announced new standard from OASIS called CMIS (announced Sept 10th 2008, involved companies are SUN, Microsoft, IBM, Oracle, Alfresco)
    - Next release (11g) has codename "Sunshine"

    AquaLogic User Interaction (ALUI):
    - Fully part of WebCenter Suite and WebCenter Services, means:
    - ALUI Blogs/Wikis and Tagging have been integrated into WebCenter Services
    - ALUI Collaboration and Interaction Mgmt have been integrated into WebCenter Suite
    - Next release (11g) has codename "Neo"


  • Other portal and Java related quick news:
    - Dec-10: Devoxx is already sold out! ;-) (fka JavaPolis, Javoxx)
    - Dec-02: SUN announced that JavaFX Desktop should be released!
    - Nov-27: JPA 2.0 released (public review)
    - Nov-19: NetBeans 6.5 is out
    - Nov-11: SpringSource acquires G2One (Groove and Grails specialists company)
    - Nov-08: Seam 2.1 supports GlassFish v2
    - Nov-06: GlassFish v3 Prelude released! Together with the OpenPortal Portlet 2.0 Update 1 and OSGi, RESTful Web Services, support for Rails and Grails, and technology previews (JSF 2.0, JAX-RS 1.0, EJB 3.1)
    - Nov-05: JSR-299 WebBeans released (public draft)
    - Nov-03: Metro 1.4 released ( = WSIT 1.4 + JAX-WS RI 2.1.5 + JAXB RI 2.1.7)
    - Oct-31: GlassFish includes EclipseLink as its default JPA implementation

  • IBM: no portal news

  • Eclipse: no portal news

  • NetBeans: see quick news above

  • IntelliJIDEA: no portal news

Wednesday, October 29, 2008

Portal Update October 2008

This month's portal summary got a little slimmer than the others:
  • SUN: Groovy Support: WebSynergy and the associated Portal Pack 3.0 continue to add features as part of its partnership with Liferay. Besides Ruby and PHP, you can now run Groovy apps as JSR-286 portlets deployed to WebSynergy as described by Frerk Meyer.

  • Oracle (BEA): no news.

  • IBM: Finally, WebSphere Application Server 7 is out. This means that IBM has joined the Java EE 5 vendor parade. With this release, the server also supports JSR-286 portlets as described in a very detailed release post.

  • eXo: The next release of eXo Portal (v2.5) will support right-to-left (RTL) languages (see picture) like Arab or Hebrew. A wiki dedicated to this RTL framework provides more details.

  • JBoss:
    > JSR-168 Portal:
    Release of JBoss Portal 2.6.7, a maintenance release of JBoss Portal 2.6: Main improvements have been done in scalability. JBoss claims that you can tune your portal application on a 1-node environment as the new version scales linearly.

    > JSR-286 Portal: Release 2.7 is in the process to go GA.

  • Eclipse: The first milestone of Eclipse Portal Pack 2.0 has been released. The portal pack consists of three plugins: JSR-286/168 Portlet Wizard, WebSynergy Plugin and the OpenPortal Plugin.

  • NetBeans and IntelliJIDEA: no news regarding portal support.

Friday, October 24, 2008

Giving EJB 3.1 a Test Drive

Although not yet final, project GlassFish features already an alpha implementation of EJB 3.1. TheServerSide posted a nice series of articles on what you can expect to come - but honestly, wouldn't it be much more fun to actually get some hands dirty? Here's a quick description on how you can give it a spin. We will demonstrate the following new features:
  • Singleton Beans
  • Simplified EJB packaging
  • Simplified EJB without Interfaces
  • Unified JNDI naming
Start with downloading the latest release of GlassFish v3. The Windows installer guides you through the installation. Use the default settings except for the authentification - choose a username and a password (this used to default to "admin/adminadmin"). At the end you will be prompted by the Updatetool - start it and install the Add-Ons shown in the image below:


Beside the EJB Container we'll also install the new JAX-RS REST API to access the EJB. The JAX-RS JSR has just recently gone final, and is definitely also worth a look. Once the installation is done, we'll switch to the IDE to code our beans. I'm using Eclipse with the Maven 2 plugin to get started quickly.

Choose New Maven Project and select the maven-archetype-webapp archetype as shown in the screenshot below. We're naming our project "ejbtestdrive" - note the name as it will be used a couple of times in the further process. Finish the create wizard and add the src/main/java folder as a source folder in Eclipse after creating it.


To resolve our dependencies, lets first configure the Maven repositories to download the EJB 3.1 as well as the JAX-RS API. Add the following lines to your pom.xml:
<repositories>
<repository>
<id>glassfish</id>
<name>Glassfish Repository</name>
<url>http://download.java.net/maven/glassfish</url>
</repository>
<repository>
<id>java.net</id>
<name>java.net Repository</name>
<url>http://download.java.net/maven/2</url>
</repository>
</repositories>

Which allows us to download following dependencies:
<dependencies>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api-3.1-alpha</artifactId>
<version>10.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

Almost done with the Maven setup. We'll just add the GlassFish Maven plugin to our build and set the compiler to deal with Java 6 (Java 5 should be fine too):
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.glassfish.maven.plugin</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
<version>2.1</version>
<configuration>
<glassfishDirectory>${glassfish.home}</glassfishDirectory>
<domain>
<name>domain1</name>
<adminPort>4848</adminPort>
</domain>
<user>${domain.username}</user>
<adminPassword>${domain.password}</adminPassword>
<components>
<component>
<name>${project.artifactId}</name>
<artifact>${project.build.directory}/${project.build.finalName}.${project.packaging}</artifact>
</component>
</components>
<autoCreate>true</autoCreate>
<debug>true</debug>
<echo>true</echo>
</configuration>
</plugin>
</plugins>
</build>

The referenced properties should be defined in a Maven profile, but for simplicity we'll just add them now to our POM (just replace the values with your installation location and your username/password):
<properties>
<glassfish.home>E:\work\servers\glassfish\glassfishv3-prelude\glassfish</glassfish.home>
<domain.username>admin</domain.username>
<domain.password>adminadmin</domain.password>
</properties>

You're now ready to run the WAR file on GlassFish. Just run
mvn package glassfish:deploy

to start GlassFish and get your WAR file deployed (Note: If the Maven plugin complains about asadmin not be a Win32 application, just remove the UNIX script so the .bat will be taken).

Finally, time to write some code! Go back to Eclipse and create a package. Our EJB is going to be a (surprise surprise) HelloWorld bean. Create a new class which looks like the following:
package com.ctp.ejb;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.ejb.Singleton;

/**
* The friendly first EJB 3.1 bean.
* @author [you!]
*/
@Singleton
public class HelloWorldBean {

private Set<String> names = new LinkedHashSet<String>();

public String hello(String name) {
names.add(name);
return "Hello " + names;
}
}
In case Eclipse complains about the compiler compliance, just set the Java project facet in the project's properties to something > 1.4. You've now created one of the new Singleton EJBs. The bean is going to remember everybody who said "hello" and give back a friendly greeting. Note that there is no local or remote interface at all! Also using a global state in a bean is something nasty to achieve before EJB 3.1. Run
mvn package glassfish:redeploy

to deploy your bean - noteably in just a simple WAR file! Did you notice how fast this deploys?

Now it's time to access our bean over JAX-RS. Create another class which looks like this:
package com.ctp.ejb;

import javax.naming.InitialContext;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

/**
* A RESTful bean being hopefully quite busy!
* @author [you!]
*/
@Path("/hello/{username}")
public class HelloWorld {

@GET
@Produces("text/plain")
public String hello(@PathParam("username") String name) throws Exception {
HelloWorldBean hello = (HelloWorldBean)
new InitialContext().lookup("java:global/ejbtestdrive/HelloWorldBean");
return hello.hello(name);
}
}

Simple enough, right? This is taking requests under /hello/... with a username, looking up the bean in JNDI and call it's hello method. Did you notice the format of the JNDI lookup? Yes, this is finally standardized, making your applications much more portable! In case you named your application differently, make sure the names match between global/ and /HelloWorldBean.
Further details on the JAX-RS functionalities can be found here.

As a last step, we need to add the Jersey servlet to our web.xml. Modify it to match this snippet:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>embeddable</display-name>
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.ctp</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>

Check that your package name matches in the Servlets init param. Now package and redeploy - and we're ready to go! Just go to http://localhost:8080/ejbtestdrive/hello/[your name] to see you greeted by your new EJB! Experiment with different names and browser sessions and see the global state preserved.

Hope you enjoyed this little test drive. Let us know on how you're using EJB 3.1 and what your experience is with it!

Sunday, October 19, 2008

Java People Spotlight: Piyush Shah

"People Spotlight" is going to bring some light into the undercover hacker rooms at CTP where Piyush is getting his hands dirty on new frameworks and technologies. The picture tells both: his strong developer skills as well as his social engagements at CTP being official "CTP Staff" of the Social Committee...Enjoy!

Java Community Role:
Developer [aka 0800-DEBUG: "Who you gonna call?" - "Bug-Shah Buster!!!!"]
My Master Kung-Fu Skills
:
Apache Tomcat 6, WebLogic 10, Javascript
I'd be excited to get my hands dirty on:
Spring and JBoss Seam

Q&A

Q: Hi Piyush, how would your message look like if you would have to tell it via Twitter what you are currently doing?
A: Trying to break and rebuild Interwoven Teamsite to incorporate Xopus.

Q:
What was the greates piece of code you have ever written so far?
A: request.getRequestDispatcher(URL).forward(request, response);

Q: What is the best quote you have ever heard from one of your peers?
A: "Developing an application is like making a movie"

Q: What is the best quote you have heard from our managers?
A: "XYZ technology, you can do it. It’s a piece of cake."

Q: What is the most cutting-edge technology or framework you actually used on projects?
A: Porting my custom code using SSH client on Solaris server and making sure it is Java1.4 compatible.

Q: What is your favorite podcast?
A: TSS (TheServerSide.com)

Q: Which Java book can you recommend?
A: SCJP6 - by Katherine Sierra

Tuesday, October 7, 2008

Java People Spotlight: Douglas Rodrigues

Our "People Spotlight" series continues with an official JUG Brazil member... "Braziiiiiiiiiiiiiiiiiiiiiiiil !!! ;-) ". Besides contributing his excellence to CTP's Java Community, Douglas makes sure that Brazil stays the number 2 in the list of the countries with most hits to this blog! ;-) ... and here are Douglas answers:

Java Community Role:
Developer [aka Java Code Spitter]
My Master Kung-Fu Skills
:
Write code that (almost) anyone can read and understand in the future.
I'd be excited to get my hands dirty on:
JBoss DNA and IntelliJ IDEA 8.

Q&A

Q: Hi Douglas, how would your message look like if you would have to tell it via Twitter what you are currently doing?
A: while (!weekend) { iTunes.open(); while (!night) { iTunes.play(); doCode(); iTunes.pause(); getCoffee(); } iTunes = null; } // One-liners rocks! \o/
Q': and where is the exception handling??!!! ;-)

Q: What was the greates piece of code you have ever written so far?
A: An image to HTML converter. It takes a 30kB image and produces a 5MB HTML file.

Q: What is the best quote you have ever heard about programming?
A: "The nice thing about standards is that there are so many of them to choose from", by Andrew S. Tanenbaum.

Q: What is the best quote you have heard from our managers?
A: Well, I hear "we're all in sales" at least once every month.

Q: What is the most cutting-edge technology or framework you actually used on projects?
A: Java Content Repository API (JCR).

Q: What is your favorite podcast?
A: I'm not a big fan of technology related podcasts, but I tried Java Posse and it's kinda funny.

Q: Which Java book can you recommend and for what reason?
A: Head First Design Patterns

Tuesday, September 30, 2008

Portal Update September 2008

Despite autumn degrees start dropping, portal updates don't get freezed:
  • SUN presents Mango*: Traditionally when we talk about the FOSS stack (free open source software), the first thing that still comes to mind is the LAMP/SAMP stack (Linux/Solaris, Apache, MySQL, PHP/perl/pyhton).
    While LAMP/SAMP has been very successful for lots of Internet based businesses (e.g. Facebook), it may not be enough for enterprises looking for advanced middleware features found in commercial products (like JavaEE5 features in general, Portals, SSO, etc.).
    Along with the evolution of Java based open source products, SUN positions certain bundles to build the official successor of FOSS:
    MANGO* (MySQL And Netbeans, Glassfish and an Open*-Glassfish product) can be seen as the next generation FOSS stack or FOSS 2.0 which brings reliable, scalable and open software to the enterprise. So with the OpenPortal project, there is a strong OSS portal stack ready as a Mango... nice!
  • SUN: WebSynergy Community Build 5 has been released at the end of this month! Updates are: WSRP 2.0 improvements, jBPM integration into SAW and first functionalities of SWA (Secure Web Access, originally packaged with OpenPortal).
  • SUN: Netbeans 6.5: Portal Pack 3.0 M1 has been released. It supports WebSynergy Stable Build 2, and has provides tooling for the following:
    - Non-Java portlets: Groovy, Ruby and PHP
    - SAW-Plugin included (Simple API for Workflow)
    - The plugin for the JCR based Mirage product is also included

  • eXo:
    - People News: Sep 8th: former JBoss portal project lead Julien Viet starts as new eXo Portal Product Manager with focus on portlet container and JCR.
    - They announced a new release for september including GWT application support in the eXo Portal. I have not seen such a release this month, so if I missed it, let me know. Otherwise I'll post it next month.

  • JBoss:
    - JBoss released JBoss Portal 2.7.0 CR1
    - JSR-286 Portlet Coordination: a very good post about how JBoss Portal has implemented this new Portlet 2.0 feature.

  • Oracle (BEA)
    - WebLogic Portal 10g3: On Sep 16th, Oracle has released Oracle WebLogic Portal 10g3 for download. It is pretty much like WLP 10.2 with the major difference that it runs on WebLogic Server 10.3. The codename for this release is Sunrise.
    - WebCenter Interaction (formerly known as BEA ALUI): No news during this month.
    - Oracle seeds the cloud: At Oracle OpenWorld, Oracle announced that it will certify/support deployments of Oracle Database (all editions), Oracle Enterprise Linux, Oracle Enterprise Manager and Oracle Fusion Middleware (and therefore WLP and WebCenter Suite) to Amazon Web Services' (AWS) Elastic Compute Cloud (EC2). In fact you may transfer your existing licenses to AWS if you like. Oracle is also providing free Amazon Machine Images (AMIs) in that environment, so you can get up and running on a full Oracle-on-EC2 environment in minutes.
    - Oracle Beehive: At OpenWorld 2008, Oracle announced Oracle Beehive (for the developers: this is NOT Apache Beehive): "Oracle Beehive is the solution to cure the present communication fragmentation", said Oracle President Charles Phillips and continued: "The goal is to take a company's setup, in which various communication and collaboration software applications from a number of vendors are running on an army of servers, and integrate the offerings into one Beehive system."

    Architecturally, it is an open, secure, scalable and standards based Collaboration Platform providing all collaboration features through web services (using WSDL, SOAP, WS-Security based on SAML). The core of the platform is based on an event-driven architectural style which allows easy logic implementations for certain events (like "customer got an email"). Content-wise the platform features a JSR-170 compliant interface for document accesses as well as interfaces for protocols like IMAP and SMTP (mail), WebDAV (documents), CalDAV (calendar events), XMPP (instant messaging).

    Beehive has been quoted already as "Oracle's answer to Microsoft's Sharepoint, but with real enterprise readiness".
    However the uphill battle in the collaboration market will look like, I wonder how Oracle will position it with the feature-overlapping WebCenter Suite (which includes collaboration components of BEA ALUI already). It probably addresses a different business need (e.g. build collaboration platform from scratch or from existing).

  • IBM: no updates for September:
    - still WebSphere Portal Version 6.1 with a couple of extension modules, called portal accelerators
    - WebSphere Portals can be tried out without installation at IBM's Greenhouse

  • Vendor agnostic:
    - CTP: Our collegues from the Advisory Solutions have posted a nice overview on enterprise portals in the future.
    - As indicated in last month's post, InfoQ has now posted all three articles about writing portlets using JSF, Ajax and Seam deployed to JBoss Portal: Part 1 , Part 2 and Part 3.

Friday, September 26, 2008

Adding JCR support to your existing web application

In addition to the two recent technology posts (1, 2) that contained a product and technology overview about JCR, this post is guiding you through the practical steps in order to add JCR support to your web applications.

A new alternative to manage your application data is to store it in a content repository. The approach brings some advantages if compared to the most widespread persistence mechanism in use currently, the relational databases. The main advantage is the ability to have unstructured data. You can store your data first, and then define how it’s going to be organized and how the pieces of persistent information relate to each other. Besides the fact that not enforcing data integrity constraints, when they are not necessary, certainly helps in your application performance. This feature is especially useful when it’s necessary to enhance the data model. Relational databases are known for not having a very flexible structure. On the other hand, the JCR API was designed to target this need.
Suppose that you got a request to have a modification date added to some of your entities. In the relational model you’ll have to find out which tables should get the new field, and maybe provide an initial value for the column. Using JCR, you can simply have this modification date available only in the newly created entities. There is no need to concern about the existing data, because with JCR you can add and remove attributes on-the-fly. There is also no need to change any structure information, because it’s not required to declare any structure at all. If you would like to add a JCR repository to your existing web application, here is a walkthrough covering all the required steps.
The presented scenario assumes a Maven 2 web application, to be deployed in a Tomcat 5.5 server.
If you don’t have a web application to start with, or if you prefer to use a test project first, I suggest you to use Apache Maven to create a simple web project. To do so, run the following command in an empty directory:


mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes \
-DarchetypeArtifactId=maven-archetype-webapp \
-DgroupId=com.ctp.jcr.sample -DartifactId=webapp -Dversion=0.1 \
-Dpackage=com.ctp.jcr.sample.webapp


The “archetype:create” Maven goal will create an empty web project called “webapp”. Let’s import this project into Eclipse, so it will be easier to change it. Change to the project directory and run the following command to generate the Eclipse specific project configuration files:


mvn eclipse:eclipse -Dwtpversion=1.5


The project is ready to be imported by Eclipse (File > Import > Existing projects into workspace; no Maven for Eclipse plugin is required, just an environment variable needs to be configurated).
Another approach to create this project is to use a Maven plug-in for Eclipse called m2eclipse. After installing it, you can create a Maven project by opening the menu “File > New > Other…” and choosing “Maven Project”. In the “New Maven Project” wizard, click “Next”, Choose the “Internal” catalog and in the archetypes list, choose “maven-archetype-webapp”. Click “Next” and provide the group ID “com.ctp.jcr.sample” and the artifact ID “webapp”. To complete the project creation, click “Finish”.
The next step is to add the proper dependencies to the project’s POM. So change it to match the following dependencies:


<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-core</artifactId>
<version>1.4.5</version>
<scope></scope>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-rmi</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-server</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-webapp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>


After changing the POM file, run the “eclipse:eclipse” goal again, and refresh your Eclipse project. As the JCR API has a “provided” scope, the JAR file which can be found in your local Maven repository (~/.m2/repository/javax/jcr/jcr/1.0/jcr-1.0.jar) should be copied to the shared/lib Tomcat folder.
Using a context descriptor file (create the file webapp/src/main/webapp/META-INF/context.xml) a shared resource, the JCR repository, will be defined. This resource receives essentially two important parameters: “configFilePath”, which is the absolute path to the repository descriptor (the “repository.xml” file, to be explained in the next steps) and “repHomeDir”, the absolute path to the directory which will contain the repository data files.


<Context>
<Resource name="jcr/repository"
auth="Container"
type="javax.jcr.Repository"
factory="org.apache.jackrabbit.core.jndi.BindableRepositoryFactory"
configFilePath="c:/TEMP/webapp/repository/repository.xml"
repHomeDir="c:/TEMP/webapp/repository" />
</Context>


This shared resource needs to be declared in the web.xml file:


<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>Archetype Created Web Application</display-name>
<resource-ref>
<description>JCR Repository</description>
<res-ref-name>jcr/repository</res-ref-name>
<res-type>javax.jcr.Repository</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>


Don’t forget to create the repository descriptor file, in the same path as specified in the context descriptor. If you don’t have your own descriptor, or if you don’t want to concern about it right now, simply copy and paste this one:


<?xml version="1.0"?>
<!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 1.4//EN"
"http://jackrabbit.apache.org/dtd/repository-1.4.dtd">
<Repository>
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${rep.home}/repository" />
</FileSystem>
<Security appName="Jackrabbit">
<AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager" />
<LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule" />
</Security>
<Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default" />
<Workspace name="${wsp.name}">
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${wsp.home}" />
</FileSystem>
<PersistenceManager
class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
<param name="path" value="${wsp.home}/index" />
</SearchIndex>
</Workspace>
<Versioning rootPath="${rep.home}/versions">
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${rep.home}/versions" />
</FileSystem>
<PersistenceManager
class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
</Versioning>
</Repository>


This simplified repository descriptor doesn’t depend on any kind of specific storage system. You can enhance it to store your data in a relational database, for example, but in our example it will store everything as XML files under the repository home directory.
Now let’s create a session factory class. This class will locate a repository instance and authenticate to it, to get a javax.jcr.Session instance. Create the directory ./webapp/src/main/java, and create the following class on it:


package com.ctp.jcr.sample.webapp;

import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class SessionFactory {

public static Session getSession() throws RepositoryException, NamingException {
InitialContext ctx = new InitialContext();
Context env = (Context) ctx.lookup("java:comp/env");
Repository repo = (Repository) env.lookup("jcr/repository");
return repo.login(new SimpleCredentials("admin", "".toCharArray()));
}

}


With this setup, the JCR repository can be accessed through your web application. The following JSP shows how to use the service factory to list the repository contents:


<%@page import="javax.jcr.Node"%>
<%@page import="javax.jcr.Session"%>
<%@page import="com.ctp.jcr.sample.webapp.SessionFactory"%>
<%@page import="javax.jcr.NodeIterator"%>
<html>
<body>
<%!
private void printContents(Node n, JspWriter out, String padding) throws Exception {
out.println(padding + n.getPath() + "(" + n.getPrimaryNodeType().getName() + ")");
NodeIterator it = n.getNodes();
while (it.hasNext()) {
printContents(it.nextNode(), out, padding + " ");
}
}
%>
<%
Session jcrSession = SessionFactory.getSession();
Node root = jcrSession.getRootNode();
%>
<pre>
<%
printContents(root, out, "");
%>
</pre>
</body>
</html>


This is the result displayed by the page. Observe that even for an empty repository, the infrastructure nodes are displayed as well.

Optional step: exposing the repository through WebDAV



To access your repository through WebDAV, it’s necessary to declare a servlet, through which the repository will be exposed. Add the following servlet declarations to your web.xml file:


<servlet>
<description> This servlet provides other servlets and jsps a common way to
access the repository. The repository can be accessed via JNDI, RMI or
Webdav. </description>
<servlet-name>Repository</servlet-name>
<servlet-class>org.apache.jackrabbit.j2ee.RepositoryAccessServlet</servlet-class>
<init-param>
<description> Property file that hold the same initialization properties
than the init-params below. If a parameter is specified in both places
the one in the bootstrap-config wins. </description>
<param-name>bootstrap-config</param-name>
<param-value>WEB-INF/repository/bootstrap.properties</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet>
<description> The webdav servlet that connects HTTP request to the
repository. </description>
<servlet-name>Webdav</servlet-name>
<servlet-class>org.apache.jackrabbit.j2ee.SimpleWebdavServlet</servlet-class>
<init-param>
<description> defines the prefix for spooling resources out of the
repository. </description>
<param-name>resource-path-prefix</param-name>
<param-value>/repository</param-value>
</init-param>
<init-param>
<description> Defines various dav-resource configuration parameters.
</description>
<param-name>resource-config</param-name>
<param-value>/WEB-INF/repository/config.xml</param-value>
</init-param>
<load-on-startup>4</load-on-startup>
</servlet>
<servlet>
<description> The webdav servlet that connects HTTP request to the
repository. </description>
<servlet-name>JCRWebdavServer</servlet-name>
<servlet-class>org.apache.jackrabbit.j2ee.JCRWebdavServerServlet</servlet-class>
<init-param>
<description> defines the prefix for spooling resources out of the
repository. </description>
<param-name>resource-path-prefix</param-name>
<param-value>/server</param-value>
</init-param>
<load-on-startup>5</load-on-startup>
</servlet>
<servlet>
<servlet-name>RMI</servlet-name>
<servlet-class>org.apache.jackrabbit.servlet.remote.RemoteBindingServlet</servlet-class>
</servlet>
<servlet>
<description>Downloads binary data from repository</description>
<display-name>Repository Download Servlet</display-name>
<servlet-name>RepositoryDownloadServlet</servlet-name>
<servlet-class>br.com.hapkidocontato.site.presentation.RepositoryDownloadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Webdav</servlet-name>
<url-pattern>/repository/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>JCRWebdavServer</servlet-name>
<url-pattern>/server/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RMI</servlet-name>
<url-pattern>/rmi</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RepositoryDownloadServlet</servlet-name>
<url-pattern>/content/*</url-pattern>
</servlet-mapping>


Other two configurations file are referenced by those servlets. Create the directory webapp/src/main/webapp/WEB-INF/repository/ and create the file bootstrap.properties with the following values:


repository.name=java:comp/env/jcr/repository
jndi.enabled=true
jndi.name=jcr/repository


In the same directory, create the file config.xml:


<?xml version="1.0" encoding="UTF-8"?>
<config>
<iomanager>
<class name="org.apache.jackrabbit.server.io.IOManagerImpl" />
<iohandler>
<class name="org.apache.jackrabbit.server.io.VersionHandler" />
</iohandler>
<iohandler>
<class name="org.apache.jackrabbit.server.io.VersionHistoryHandler" />
</iohandler>
<iohandler>
<class name="org.apache.jackrabbit.server.io.ZipHandler" />
</iohandler>
<iohandler>
<class name="org.apache.jackrabbit.server.io.XmlHandler" />
</iohandler>
<iohandler>
<class name="org.apache.jackrabbit.server.io.DirListingExportHandler" />
</iohandler>
<iohandler>
<class name="org.apache.jackrabbit.server.io.DefaultHandler" />
</iohandler>
</iomanager>
<propertymanager>
<class name="org.apache.jackrabbit.server.io.PropertyManagerImpl" />
<propertyhandler>
<class name="org.apache.jackrabbit.server.io.VersionHandler" />
</propertyhandler>
<propertyhandler>
<class name="org.apache.jackrabbit.server.io.VersionHistoryHandler" />
</propertyhandler>
<propertyhandler>
<class name="org.apache.jackrabbit.server.io.ZipHandler" />
</propertyhandler>
<propertyhandler>
<class name="org.apache.jackrabbit.server.io.XmlHandler" />
</propertyhandler>
<propertyhandler>
<class name="org.apache.jackrabbit.server.io.DirListingExportHandler" />
</propertyhandler>
<propertyhandler>
<class name="org.apache.jackrabbit.server.io.DefaultHandler" />
</propertyhandler>
</propertymanager>
<noncollection>
<nodetypes>
<nodetype>nt:file</nodetype>
<nodetype>nt:resource</nodetype>
</nodetypes>
</noncollection>
<filter>
<class name="org.apache.jackrabbit.webdav.simple.DefaultItemFilter" />
<namespaces>
<prefix>rep</prefix>
<prefix>jcr</prefix>
</namespaces>
</filter>
</config>


And that’s all: the default workspace can be accessed through WebDAV in the following URL: http://localhost:8080/webapp/repository/default. On Windows, you can go to “My Network places” and “Add network place” to map the WebDAV location as a folder. When prompted by a username and password, just provide anything; the repository is configured to grant access to any user.
To find more about JCR, Jackrabbit and its related technologies, visit the dev.day.com weblog.

Thanks Douglas for this post! - [Tom & Balz]

Thursday, September 25, 2008

Java People Spotlight: Stefan Malär

Our "People Spotlight" series continues with the first candidate from CTP's Business Analysis team. "Java and BA? Make sure they don't consider PHP!" -- "No worries... having Stefan on a Java project is like doubling HP of your sports car:-)" -- Enjoy this spotlight on Stefan Malär:

Java Community Role:
  Senior Business Analyst [aka Java Backseat Driver]
My Master Kung-Fu Skills
:
  Hitting the Achilles heel: discovery of bugs and weak spots in the code.
  Finding the missing link: getting to work whatever doesn’t.
I'd be excited to get my hands dirty on:
  DISC (AJAX Framework) in WLP10.2, Flex integration in WLP10.2, WSRP that actually works out-of-the-box...

Q&A

Q: Hi Stefan, how would your message look like if you would have to tell it via Twitter what you are currently doing?
A: Getting our project live with whatever it takes, even coding… and of course telephone conferences with India, lots of those.

Q: What was the greates piece of code you have ever written so far?
A: A Firefox extension (that was in the days they were still called like that) to link and annotate websites and store this information through SOAP on a multimedia linking server.

Q: What is the best quote you have ever heard from one of your peers?
A: "Don’t explain it away" (bugs stay bugs...)

Q: What is the best quote you have heard from our managers?
A: "If you use JIRA you don’t need a code versioning system anymore, right?"

Q: What is the most cutting-edge technology or framework you actually used on projects?
A: WSRP, AJAX and SOAP mixed on WLS10 and WLP10. Really a lot of cutting and bleeding involved...

Q: What is your favorite podcast?
A: I was forced to write Java Posse here…, no seriously they are quite good, especially if they talk about non-Java stuff ;-)

Q: Which Java book can you recommend and for what reason?
A: Why read books if you can ask your colleagues whatever you need to know? (How cheesy is that answer! …, actually I can’t remember having read a Java book lately)

Wednesday, September 24, 2008

Top 10 Java Technologies Update: JCR Part 2

As promised in the Top 10 Technologies post, here are more details regarding JCR and the way we use it in projects.

In the other post, I have written about the requirements we usually encounter in projects when it comes to dealing with content in web applications. Not only functional requirements but also non-functional requirements such as "content is stored at different places and must be made available at a single point" were most probably the reasons for Day Software (located in Switzerland) to bring that extra layer to life and started leading the JSR-170.
Instead of rebuilding all that from scratch, Cambridge Technology Partners has chosen many times to propose and implement a JSR-170 based solution.

Being in contact with Day directly, we carefully track the evolution of JCR, currently mainly in the JSR-283 area where the JCR 2.0 standard is about to reach its final state (currently in Public Review Ballot phase).

Since JSR-170 started, it is a hot topic in different places:
a) at conferences like JavaOne in 2006,
b) on the feature lists of product vendors (JSR-170 compliance),
c) used internally in open source products like Drools BRMS for managing business rules, Apache Sling for universal resource storage and Mule Galaxy for SOA governance management and last but not least
d) CTP had many projects in the Enterprise Content Management area where we used JSR-170 bridges (e.g. "SPI to JSR-170 bridge" in the BEA WebLogic Portal where SPI is the BEA custom content interface to their Virtual Content Repository in the portal), we used JCR products directly in projects (mostly Alfresco but also Jackrabbit which is the reference implementation both being good enough for small companies, Vamosa as content migration tool where customers wanted to automate content migration from a legacy content repository to a JCR (and yes, vice-versa also :-). To make the list complete, on projects we never had the chance to use Day's Content Repository Extreme (CRX), eXo JCR (part of the eXo platform), Mirage or Jeceira (part of the Jackrabbit alternative Magnolia).

As said earlier, the official successor JSR-283 is on its way and addresses enhancements in the areas of federation, remoting, client/server protocol mappings and extensions to content modeling capabilities just to name a few. I'm sure we'll compile an extra post on this topic... so check back later.

Tuesday, September 23, 2008

Java People Spotlight: Phuong Nguyen

Our "People Spotlight" series continues with the next Java Community member Phuong Nguyen!

Java Community Role:
  Developer [aka Fongdroid or JTroubleshooter]
My Master Kung-Fu Skills
:
  Aikido (Java incompatible and performance leak issues debug & solve)
  Judo (Java unexpected errors debug & solve)
I'd be excited to get my hands dirty on
:
  Android 1.0 SDK with a Google Dream phone

Q&A

Q: Hi Phuong, how would your message look like if you would have to tell it via Twitter what you are currently doing?
A: Twitter??? Never heard about. Is it a new facebook application? :D

Q: What was the greates piece of code you have ever written so far?
A:


String documentId = request.getAttribute("documentid");
  • This line of code will fail to get what we expect to get in a WSRP scenario if the consumer doesn't federate the data to the producer.
  • In addition, for some specific configuration of an application server, it would be executed only once, or several times or not executed at all.
  • With IPC (Interportlet Communication), it could have the effect that the second portlet get the old value of the last request (one step back effect).
  • Many lessons learned from a single line of code. Isn't it great?
Q: What is the best quote you have ever heard from one of your peers?
A: "No problems :-)"

Q: What is the best quote you have heard from our managers?
A: "At the end of the day, we have to focus" (in french accent)

Q: What is the most cutting-edge technology or framework you actually used on projects?
A: WebLogic Portal 10.0 with WSRP

Q: What is your favorite podcast?
A: Jave Posse ! What else!

Q: Which Java book can you recommend and for what reason?
A: "The Java™ Language Specification", know Java as well as a Java compiler does

Monday, September 22, 2008

How to use Google's Syntax Highlighter in Blogspot

Being a techie, we sometimes wish to post source code. Now, we all know that reading it can be a pain in the neck, especially if it's not nicely formatted. As convenient as blogspot is, it doesn't provide any funtionality to format source code. Luckily there's a thing called syntax highlighter and it's quite easy to have it working with your blog. Simply follow those four steps

1. Download Syntax Highlighter from Google
2. Extract files and upload them to a webserver ([your URL])
3. Edit your template and replace

</div></div> <!-- end outer-wrapper -->
</body>
</html>


by

</div></div> <!-- end outer-wrapper -->
<link href='[your URL]/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>
<script src='[your URL]]/shCore.js' type='text/javascript'/>
<script src='[your URL]/shBrushCpp.js' type='text/javascript'/>
<script src='[your URL]/shBrushCSharp.js' type='text/javascript'/>
<script src='[your URL]/shBrushCss.js'type='text/javascript'/>
<script src='[your URL]/shBrushJava.js' type='text/javascript'/>
<script src='[your URL]/shBrushJScript.js' type='text/javascript'/>
<script src='[your URL]/shBrushSql.js' type='text/javascript'/>
<script src='[your URL]/shBrushXml.js' type='text/javascript'/>
<script class='javascript'>
//<![CDATA[
function FindTagsByName(container, name, Tag){
var elements = document.getElementsByTagName(Tag);
for (var i = 0; i < elements.length; i++){
if (elements[i].getAttribute("name") == name) {
container.push(elements[i]);
}
}
}
var elements = [];
FindTagsByName(elements, "code", "pre");
FindTagsByName(elements, "code", "textarea");
for(var i=0; i < elements.length; i++) {
if(elements[i].nodeName.toUpperCase() == "TEXTAREA") {
var childNode = elements[i].childNodes[0];
var newNode = document.createTextNode(childNode.nodeValue.replace(/<br\s*\/?>/gi,'\n'));
elements[i].replaceChild(newNode, childNode);
} else if(elements[i].nodeName.toUpperCase() == "PRE") {
brs = elements[i].getElementsByTagName("br");
for(var j = 0, brLength = brs.length; j < brLength; j++) {
var newNode = document.createTextNode("\n");
elements[i].replaceChild(newNode, brs[0]);
}
}
}
//clipboard does not work well, no line breaks
// dp.SyntaxHighlighter.ClipboardSwf =
//"[your URL]/clipboard.swf";
dp.SyntaxHighlighter.HighlightAll("code");
//]]>
</script>
</body>
</html>



4. Write your post and add source code (in the HTML tab) using either

<pre name="code" class="java">
// your code here
</pre>

or

<textarea name="code" class="java">
// your code here
</textarea>

As an example, the following code

<textarea name="code" class="java">
/**
* Hello World Example
*/
   class HelloWorld {
      public static void main(String[] args) {
         String message="Hello World!";
         System.out.println(message);
   }
}
</textarea>

becomes

/**
* Hello World Example
*/
class HelloWorld {
public static void main(String[] args) {
String message="Hello World!";
System.out.println(message);
}
}

Note:
  • When posting XML or HTML, replace < by &lt; and > by &gt;
  • change class="java" as needed to java, csharp, css, xml, html, ... (complete list)
  • JavaScript removes <br/> tags because blogger automatically adds them in case of a linebreak but syntax highlighter would display them in plain text

Friday, September 19, 2008

Java People Spotlight: Christoph Reimann

We now start with a series of "People Spotlight" posts to introduce Java related CTP consultants. Our kickoff candidate is Christoph Reimann!

Java Community Role: Developer [aka Java Grizzly Bear]
My Master Kung-Fu Skills
: WebLogic 10, JSF 1.2, Hibernate 3
I'd be excited to get my hands dirty on
: EJB 3 , Spring 2.5

Q&A

Q: Hi Christoph, how would your message look like if you would have to tell it via Twitter what you are currently doing?
A: Right now I'm coordinating the database migration of a marketing application in production together with the single point of contact and the database team.

Q: What was the greates piece of code you have ever written so far?
A: Dynamic Form generation based on business rules

Q: What is the best quote you have ever heard from one of your peers?
A: "sure sure sure" (Martin L, onsite running gag)

Q: What is the best quote you have heard from our managers?
A: "Christoph, was isch denn das füren shizzle?" (BS)

Q: What is the most cutting-edge technology or framework you actually used on projects?
A: WebLogic Portal 10.0 portlet implementations using custom data federation with WSRP

Q: Which Java book can you recommend and for what reason?
A: Handbuch der Java-Programmierung (covers all J2SE topics easy to understand)

Top 10 Java Technologies at Cambridge Technology Partners

In the second part of our "Top 10" series, we dive into the actual technologies we use in our projects.
  • Enterprise JavaBeans (EJB) 3:
    Already declared as dead, Java EE has managed to jump back on the train with EJB 3. It incorporates many best practices like convention over configuration, dependency injection and usage of annotations, simplifying development a lot compared to its predecessor.

    Although the spec for EE 5 has been out for quite a while, adoption at our customers has taken a while - but now starts getting momentum. I've seen some very nice "Aha!" moments while demonstrating what the new platform has to offer to developers. The combination of POJOs, annotations and Java standard makes setting up projects and unit tests very easy and a powerful mix for development.

    EJB 3.1 looks also promising in terms of further simplifications (and fixing some holes left in the APIs) - we're looking forward to help our customers taking this turn as well!

  • Java Persistence API (JPA) and Hibernate:
    As a de facto standard for object persistence, Hibernate has been used in our projects for years now. While working with other persistence technologies like Beehive DB Controls, iBatis or even Entity Beans due to legacy code, Hibernate has proven most efficient once the domain model got a little complexer.

    With the new Java Persistence API coming in Java EE 5, Hibernate gets even easier to integrate and use into an enterprise application. We're still missing some Hibernate features like a criteria API in JPA, but JPA 2.0 is about to fix this. Besides easier integration, JPA makes applications also more portable - there are also a couple of other JPA implementations available: Oracle TopLink, openJPA (or its big brother Kodo) or Apache Cayenne to name the best known. Being part of the EE standard, it's not a surprise that integrating JPA with EJB (or vice versa) works great!

    Mentioning JPA 2.0, let's see how EclipseLink (nominated as reference implementation) compares to Hibernate!

  • JavaServer Faces (JSF):
    MVC frameworks seem to be around like sand on the sea. From old school Struts over Wicket to Google GWT (or other fancy new AJAX frameworks) - it's hard to decide for "the right one" on projects. My recommendation usually goes to using JSF (with Facelets). Investing in a standard is in general a good thing.

    In case of JSF:
    - It has proven to be extensibe. There are a couple of very nice AJAX component libraries around, like JBoss RichFaces, Woodstock or ICEfaces. And also, JBoss Seam adds a few killer features to JSF, just to name stateful navigation or transactional backing components here.
    - It is programmable with a declarative view definition in XHTML and an expression language. Facelets adds an extremely powerful templating to JSF, which I found much easier to use than frameworks like Tiles or SiteMesh.
    - Growing IDE support (Eclipse WTP, JBoss Tools, NetBeans and the latest IntelliJ to name some) featuring WYSIWYG editors or (for me much more useful) XHTML and EL code completion.

    By the way, Java EE 6 features JSF 2.0, including enhancements for component developers as well as standardazing on Facelets!

  • JBoss Seam:
    In my humble opinion, one of the most innovative frameworks over the last years. As already mentioned in a previous post, the stack around Seam works for me extremely well and efficient to develop web applications.

    Getting back on my previous statement on investing in standards - I'm looking forward to WebBeans (I hope JSR-299 makes it into Java EE 6), combining Seam with typesafe dependency injection of Google Guice! Looking back at my first servlet based web application during CS studies, things have become amazingly elegant to develop!

  • Spring Framework:
    Both EJB 3 and Spring in the same list? Yes, Spring is also a great piece of technology in use at many of our customers. It has not been the first open source dependency injection container (just to mention e.g. Pico) but was the first "enterprise ready" implementation out there making me extremely happy to work with after sweating on an EJB 2 project.

    Third party products (e.g. CRMs) which do not support Java EE 5 application server versions are sometimes limiting constraints for upgrading, which make usage of Spring a great alternative to customers which are still bound to EJB 2. Even if you don't deploy a Spring runtime, it offers great support for your unit tests - like using SimpleNamingContextBuilder to mock an InitialContext!

    The latest 2.5 release of Spring makes also (finally) use of annotations to inject bean dependencies, which is a great improvement over the previous "XML salad". Adam Bien has written a nice post on XML vs. annotations in EJB 3, which covers with my experiences and can be similarly handled in Spring.

  • JAX-WS:
    While we've gone through a couple of web service technology stacks, the JAX-WS standard has been for us the most convincing on to work with (did I already mention we generally like standards? ;-). Its reference implementation Metro has made its way into major application servers like Oracle WebLogic, JBoss, GlassFish (and probably others), allowing us to easily take best practices from customer to customer.

    If you're rather out for something simpler than a full SOAP stack, also have a look at JAX-RS, the standard for RESTful web services. Its reference implementation Jersey is on its way to version 1.0, but already now ready for some really cool use cases (try it out with e.g. JFreeChart to create dynamic charts in web applications)!


  • TestNG:
    While writing unit tests for years with JUnit, I've made the experience that some limitations of the framework have somehow led to ugly test code - clunky test method signatures with no arguments, no mechanism to define dependencies between tests and no built-in mechanism to run test methods with different test data.

    In a real world enterprise project, testing just the "unit" is not always enough. With Spring for example, we can run the whole container and execute test cases on it - this is definitely much faster than deploying to the container. TestNG has shown to be more useful than JUnit in this context. Also several large open source projects have decided for TestNG, to name JBoss (by the way: congrats for passing the EE 5 TCK!) or GlassFish.

  • jBPM and Drools:
    Probably not the most advanced BPM on the market, but at least in the open source space jBPM is the leading engine we've been working with so far. Now part of JBoss middleware suite, jBPM together with the Drools rule engine form a powerful couple when shaping SOA applications. But also running without jBPM, Drools has shown to be a great engine to externalise business rules in a very clean and maintainable way (which would otherwise probably have ended up in some ugly if-else jungle or rather complex decorator pattern classes).

  • Java Content Repository (JCR):
    It is extremely common for applications to store various pieces of information, most of the time in relational databases. While they do a great job when working with regular data types (e.g. int, string), we think they are not very efficient when dealing with binary data (unstructured), for example images or documents (structure binaries). On top of that, many features are not covered by pure DB products out of the box:
    Usually, such requirements we encounter on projects are proper management of documents, versioning, enhanced meta data tagging, handling of structured as well as unstructured content, proper handling of dependencies between content nodes (known as referencial integrity), flexibility with regards to node attribute extensions and inheritance, administration delegation, and many more.

    In such cases where an extra layer is needed on top of a database, JCR and JSR-170 quickly come into the picture of our solution proposals for our customers.

    More details will follow in a few days regarding JCR at CTP.

  • Scala:
    Honestly, we haven't had Scala in a customer project yet. Still it seems to be the most interesting newcomer in the "scripting on the JVM" category, offering static typing and a couple of interesting language constructs (to build e.g. DSLs). Unfortunately the learning curve is a little steeper than with other scripting languages, so a deeper analysis on where we can leverage this at our customers will have to wait until my next "beach time".