JPA2 and CloudBees

Besides its “Tomcat-as-a-Service”, the CloudBees service is also offering a hosted MySQL (5.0.51) database. This “database-as-a-service” can be used in various ways. Once you’ve created your database, you can get detailed informations about it in the management console. This console includes a few code samples on how-to configure the hosted database, e.g to be used in JSP or ColdFusion.

Of course, you can also use JPA inside of the CloudBees offer. I’ve tested it with EclipseLink and OpenJPA.

In order to use JPA with the hosted database, you need to include something like below, in your persistence.xml file:

<persistence-unit
  name="myUnit"
  transaction-type="RESOURCE_LOCAL">

<class>my.PersistentObject</class>
...

 <properties>
<!-- JPA standard properties -->
<property
   name="javax.persistence.jdbc.driver"
   value="com.cloudbees.jdbc.Driver"/>
<property
   name="javax.persistence.jdbc.url"
   value="jdbc:cloudbees://YOURSCHEMA"/>
<property
   name="javax.persistence.jdbc.user"
   value="USER"/>
<property
   name="javax.persistence.jdbc.password"
   value="PASSWORD"/>
....

That’s all you need! Now you are able to use the database!

Note: For your local development you can also access the DB via a real URL and the regular MySQL driver. The management console does show the remote connection details as well.

Leaving Oracle

After almost five years I am leaving Oracle at the end of February. In 2006 I joined the company to work on JavaServer Faces related projects like Apache MyFaces/Trinidad or ADF Faces. I had a great time at Oracle and I do have a lot of friends there! I had the opportunity to work on pretty interesting projects with great engineers. I’ve learned a lot!

As I am leaving Oracle, I won’t participate actively in JSF related projects anymore. Therefore I am also step back from being the Apache MyFaces PMC Chair.

I will be moving on to work on some really exciting stuff! I am looking forward to my new adventure!

NotSerializableException for UIComponents

Sometimes I am getting ‘bugs’ that claim there is something wrong with the (Trinidad) framework, as its UIComponents are NOT serializable… An example:

java.io.NotSerializableException:
org.apache.myfaces.trinidad.component.UIXSwitcher

No, this is not a bug at all!

First:
Your (session/application/pageFlow scoped) backing beans should not have an UI component as its property… (if you really really need the “cool” binding attribute).

Second:
UIComponents are not serializable – for a good reason!
In JSF there is StateSaving (see the restore/saveState() hooks)….

Apache MyFaces Trinidad does have a tool that helps to store an reference to an UIComponent (instead of the component itself).

Here are a few blogs on that, that may give more information on the API and why the tool is there:

http://matthiaswessendorf.wordpress.com/2010/03/31/uicomponent-references-in-session-scoped-jsf-beans/

http://leadingyouastray.blogspot.com/2010/02/references-to-uicomponents-in-session.html

Have fun!

Apache MyFaces in the cloud – Part II

A few days ago I did a quick test to see how well Apache MyFaces “works” in the cloud. The Amazon Beanstalk test was a success.

Now, I gave the new Run@Cloud offerings from @CloudBees a try.

Apache MyFaces goes Run@Cloud…

I tried to deploy my kickstart project to the cloud – It worked very well. After telling the console the “application name”, selecting the desired WAR file I quickly got a notification “popup” that my App is ready!

It was very quick. After these simple steps, on the nice UI, I was able to use my application:

The project itself is quite simple and therefore a good candidate to give offerings like Run@Cloud a test-drive. Besides the neat size of the project, it still contains an interesting set of modern JavaEE 6 technologies:

  • CDI (Apache OpenWebBeans)
  • JPA (Apache OpenJPA)
  • JSF2 (Apache MyFaces)

and a set of CDI extensions (Apache MyFaces CODI)!

The Run@Cloud service uses Tomcat 6.0.29 and since the application is able to run in “standalone” Tomcat 6 (and 7) installations, I was expecting it works with CloudBees as well. And yes, it was the case!

Looks like there is another interesting “Tomcat as a Service” offer in the market :-)