If you go to my JavaOne 2011 talk "Productively Fun Web Development with Apache Wicket and Java EE 6" you will see a demo where Bean Validation is used in conjunction with Apache Wicket.
In order to accomplish that, all that you need is a single Java class that bridges the Wicket validation framework and the JSR 303 validation engine.
I am posting here not only this bridge class (JSR303Validator) but also two other utility classes: ValidationStyleBehaviour and BaseEntityForm.
ValidationStyleBehaviour is a Wicket behaviour that displays form component erros messages close to the form component itself, instead of in a FeedbackPanel.
BaseEntityForm is a Wicket Form that uses any class anotated with Bean Validation annotations and uses JSR303Validator and ValidationStyleBehaviour in every form field, so that the resulting form validates according to the constraints expressed by the annotations and renders validation messages nicely.
JavaOne started for me today with the Glassfish Community Event.
It was a nice opportunity to meet the Glassfish Development Team as well as people I have interacted with but not met in person until today.
The event, as well as the community party afterwards, had more people than last year. That is also my perception for the entire conference: there are more people attending this year than in the last year. If that is true or just my impression is something that only the conference organizers will be able to answer. The Java community seems, at least in numbers, to be stronger than ever...
From the information provided at the event, I can tell you that Java EE 7 and Glassfish are moving towards the Cloud: the next version of Glassfish (Glassfish 4) will have support for managing Glassfish on virtualized environments and will support multi-tenant applications as per the Java EE 7 spec.
There were many customer testimonials about how Glassfish is performing in production environments. Common themes: the high performance of the web stack (Grizzly) and the poor formatting of the server log messages.
Looking forward to the JavaOne keynote tomorrow...
One of the exciting things about teaching is the fact no matter how well you prepare for a class, events will always surprise you.Yesterday I was caught by surprise in the middle of a class by what seemed like a global Glassfish admin console outage.
I was teaching my Software Architecture students at IGTI how to change the default maximum thread pool size for the HTTP listener in Glassfish 3.0.1. We needed to do that in order to run a JMeter load test against our example application. The default maximum thread pool size in Glassfish is just 5 threads, which makes it impossible to stress the system with a decent number of concurrent users.
I tried to access the Glassfish admin console on http://localhost:4848 on my notebook. It started loading but hang after the "Admin Console is starting..." screen. Restarted Glassfish, no change.
So I thought: "well, my Glassfish instance must be broken somehow". Tried it on a student notebook, same thing: admin console would still failed to load.
Switched to a remote virtual desktop(Ubuntu Lucid) running on Amazon EC2, started Glassfish, tried to load management console. Same result, hangs after the starting screen.
Luckily we had a coffee break coming up so I sent the students to eat something while I tried to figure out what was going on. What could possibly have broken admin console in 4 Glassfish instances running under two operating systems (Windows and Linux) in two different countries (Brazil and USA)?
My sysadmin years taught me to look for the network whenever something stops working without any apparent reason. So I ran netstat and found some suspicious connections from the Glassfish process to *pkg.sun.com hosts. So I remembered that admin console has an auto-update feature. Maybe that had something to do with the failure to load?
To test this theory I disconnected my notebook from the network, restarted Glassfish and tried http://localhost:4848 again. Loaded promptly, worked like a charm. So I explained my students why Glassfish was behaving like that and told them to try the same solution on their notebooks. It worked for everyone so we were able to go on with the class.
What I explained to the students was this: admin console must be trying to check for updates while loading. If it cant connect to the update server (a fast kind of failure) it ignores the error and finishes loading. No problem there, only a few seconds lost. But when it can connect to the update server and the server is just not responding (a slow kind of failure) then it will wait forever for a reply and hence not finish loading.
This kind of unintended coupling is not uncommon in networked applications. But when it happens on something as big as Glassfish is gets kind of scary. I wonder how many other users where scratching their heads just then, wondering what was going on with their servers.
But this event, unpredictable as it was, presented me with the opportunity to teach one more Software Architecture lesson to my students: if your application uses a Cloud service, its better be prepared for the service to fail in all sorts of unexpected ways.
I had originally planned to write a blog post per day during JavaOne 2010. That being my first JavaOne I was of course completely unprepared for the hectic routine of sessions, meetings, parties and more sessions. I wrote blog posts in the first two days and disappeared ever since.
I am alive, well, and back to Brazil. I had a terrific time in San Francisco where I got to meet a lot of interesting people, some for the first time and some that I had previously known online. What explains my silence is the fact I got sucked into a new consulting assignment immediately after touching ground, and only now I have time to rest a bit and reflect on what I have seen.
JavaOne 2010 was all about The Cloud for me, and in many ways it changed my views as to what cloud computing really is about. I will have to write a post specifically about that in the future, but I am now convinced that the Cloud is an umbrella concept for a number of practices and technologies related to the simplification of system deployments ( in contrast to the more traditional view related to cost benefits from economies of scale). There were a number of very interesting announcements and demos related to Cloud Computing and I believe over the next year more and more Java-enabled cloud platforms will enter production stage ( and at some point after that we will see some common apis emmerging this space).
There was already a lot of coverage about the future of the Java platform, so I will skip the details here. The overall feeling I got is that in spite of concerns related to the JCP and the Google/Android lawsuit the Java platform is in good hands with Oracle. The JavaOne keynote was very efficient in making the imediate direction clear. I agree with some things ( like splitting Java 7 into 7 and 8 ) and don't understand others ( javame.next and JavaFX) but the important message is that the Java platform will be moving forward again, which is a good thing.
In the Java EE space there were no big new announcements. Instead, there was a renewed commitment with the development of Glassfish as an open source product. That is fine by me: Java EE 6 is still seen as cutting edge by many organizations and has a long way to go before becoming obsolete. My top Java 8 wish ( EE apps as first class citizens in the JVM ) is not going to happen anytime soon, but was hinted to be somewhere in the future of Java EE. This is an area where Java EE and The Cloud intersect. I have seen some demos of PaaS clouds based on Java technology ( CloudBees and VMForce, among others) and I wonder how these services are planning to solve the problem of application isolation. Google has solved it in App Engine by using a custom JVM. If more and more companies go down this route we may end up with a fragmented Java ecosystem in the Cloud.
I was surprised in JavaOne 2010 to not find any sessions about Apache Wicket, my favourite web framework. In order to remedy this situation in JavaOne Brazil 2010, I have submited a session proposal about Wicket development in Java EE 6. Should it be accepted I will be presenting Apache Wicket and how it provides a presentation layer option that fits in the Java EE 6 philosophy even beter than JSF 2.
There was a lot happening at day 1. The amount of simultaneous activity can be dazzling at times and I felt i needed a good nights rest in order to digest the enormous amount of information fed into my brain yesterday.
I am writing this post from the Mason Street tent and the vibe around here is electrifying. Its hard to remember as one goes about the day-to-day development activities that there are so many Java developers in the world...Of course we interact all the time on mailing lists and twitter and blogs but to see so many Java developers in person in a single place gives me an exact idea of just how big and active the Java ecosystem really is.
The main news item today was the JavaOne keynote, which finally laid out definitely what are the Oracle plans for Java in the next couple of years. there was a lot of information for a hour and a half session, and more details will emerge in todays General Technical Session but the highlights are:
Java 7 will be split in two releases: 7 in 2011, 8 in 2012
A new mobile initiative called JavaMobile.next will take JavaME to the next level. It will feature updated apis more suited to todays feature phones and smartphones. Maybe that explains the Google lawsuit?
Oracle is commited to continue developing Glassfish and pushing the Java EE specifications forward.
As I said this is a lot of information and there are a lot of gory details yet to be specified. I am particularly curious about the HTML 5 support in JavaFX as it could enable JavaFX applications on the ipad/iphone. Hopefully we will gain more in-depth understanding of these features in the General Technical Session.
The overal feeling I got was that Oracle is commited to take Java to the next level and they plan to listen a lot fo the community as they do it. At the end of the keynote everyone was invited to wear a t-shirt which had the phrase " I am the future of Java" stamped.
It was my first day at JavaOne 2010 today. And what a day!
The kick off for me was the Glassfish community event. The room was packed with Glassfish users and developers. It was nice meeting in person people I have been reading and interacting with online for such a long time.
There was a presentation on the Glassfish product roadmap and a break out for discussion of many Glassfish-related topics. I ended up in a very stimulating discussion about virtualization support in Glassfish. It is even more interesting in the light of what would be announced in the welcome keynote later on.
In the Oracle OpenWorld welcome keynote there were some announcements, all related to cloud computing. First HP presented their view of the data center of the future, and in their view the data center is a private cloud. They demoed software for automating private cloud design and deployment. Their offering for the private cloud consists in a lot of boxes connected through HP networking gear running operating systems, hypervisors and applications from multiple vendors.
Next came the Oracle keynote itself. From the moment Larry took the stage it was clear that his presentation would be all about the cloud. He started by defining cloud computing by comparing two services commonly associated with the term: salesforce.com and Amazon EC2. His vision is that cloud computing is more like Amazon EC2 than salesforce ( in other words, infrastructure as a service as opposed to software as a service). Next he announced Oracle's take on the private cloud market: a product that is a cloud in a box, tightly integrating hardware and software in order to deliver a high performance computer cluster for general purpose use.
During the announcement he stressed out that this system has been heavily optimized to make Java run as efficiently as possible. In fact he mentiobed Java as a key component many times, which means Oracle is not about to change their mind about the strategic importance of Java any time soon.
Going back to the Glassfish community discussion, the main question was: how can Glassfish integrate better with virtualized envirinments and the cloud? The question for me was strange at the beginning because i am used to think about application servers as being unaware of the details of the environment they live in. But as the discussion evolved it became clear that maybe there is value to be gained in making the application server more aware of the cloud resources. Things like provisionimg, auto-scaling and self-healing require a tigther integration between these worlds.
One thing finally hit me today: while the public clouds are about cost savings and elasticity, the private cloud is about simplifying IT provisioning and deployment. In fact, the cloud computing paradigm can be seen as a metaphor that glues together a number of ideas related to the simplification of IT service delivery. This is the common trait that even the PaaS and SaaS definitions share.
What is clear is that whatever happens next the cloud is here to stay. And Java and the JVM will play a signifficant part on it.