Java Chatter and Random Nagging

Tuesday, November 20, 2007

Spring 2.5 is out !!

The long-awaited release of Spring 2.5 (formerly called Spring 2.1) is here !!
I am gonna port my pet-application right away. SpringSource (formerly called Interface21) claims that the upgrade should be extremely easy. Let's check it out.

Labels: ,

Thursday, November 15, 2007

Bus factor of Echo2

Tuesday, I went to a presentation by Alef Arendssen
where he discussed the choice of Web Frameworks. One thing he mentioned was the bus factor: for example, when a open source project is managed and programmed by only 1 person, the project has a bus factor of 1. It signifies that it only takes one bus to stop the project, if the person behind the project is hit by a bus, the project is terminated.

It definitely made me rethink my own choice for the webtier. I am currently using Echo2 and I definitely love it, it allows me to create very rich user interfaces (check out the demos in a previous blogpost) and I don't spot too many bugs or missing features. But there has not been an updated version since March 2007, and this scares me. There is not a large community supporting Echo2, although it is a great piece of software.

So, let's look at other options:

I don't know about the bus factor of all the following projects, but they all seem promising and are direct competitors for Echo2 :
  • JSeamless : nice demo, although it seems quite heavy and slow
  • Wings : same issues
  • GWT : definitely not a bus factor of 1, and more client based than Echo2 (probably a good thing, although you can only use a subset of Java this way)
  • And, most interesting to me, definitely considering my objections against Echo2 bus factor : Coeee. Besides having a silly name (really!), Coeee was started as a branch of the Echo2, EchoPointNG and Echo2 Extras source code. The project aims to further develop the code that formed Echo2 into a highly robust web UI framework. It is supported by Karora which aims to create a community around a few open-source web frameworks. They claim that it can port easily ported from Echo2 to Coeee (merely a package change apparently). It all seems a bit too easy. For what reason did the Karora guys fork Echo2 instead of contributing to it directly (they argue that the community support was insufficient with NextApp, and maybe they do have a point here). At least I am noticing quite some activity on their Jira tracker.
For my pet project, I am sticking with Echo2 (which I will probably migrate to Coeee, if I find the time), but for a future webapplication, I will probably consider using GWT.

Offtopic : a very interesting article about an enterprise application sharing almost the same architecture as my pet project (Echo2, Hibernate, MySql).

Labels: , , ,

Wednesday, November 07, 2007

Connecting to a SSL SMTP Server using Spring/Java

One of the toughest things I did for a long time :
I needed to connect to a SMTP Mail Server using an SSL connection.
When doing this using my SMTP GMail Server, all it took were a few lines :

public class SslMailServerCheckerGmail {

public static void main(String[] args) throws Exception {

JavaMailSenderImpl mailSender = new JavaMailSenderImpl();

Properties mailProps = new Properties();
mailProps.put("mail.smtps.auth", "true");
mailProps.put("mail.smtp.starttls.enable", "true");
mailSender.setJavaMailProperties(mailProps);

mailSender.setProtocol("smtps");
mailSender.setPort(465);
mailSender.setHost("smtp.gmail.com");
mailSender.setUsername("my.email@gmail.com");
mailSender.setPassword("mypassword");

MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);

helper.setTo("softwarre@hotmail.com");
helper.setFrom("my.email@gmail.com");
helper
.setSubject("If you can see this message in your mailbox, your code worked");

helper.setText("See subject", true);

mailSender.send(mimeMessage);

}
}


However, when trying this for another SSL SMTP Server, I kept having the error :

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target


The solution to this problem was to obtain the public key from the SMTP Server and make your Java client trust this key. Use the command
smtps.kuleuven.be:443
to grab the public certificate of the smtps server. Copy the certificate (including begin and end lines) into a file, for example call it
kuleuven.pem
. Then, import this certificate into your java keystore by using the command
keytool -import -alias smtps.kuleuven.be -keystore "C:\Program Files\Java\jdk1.6.0_02\jre\lib\security\cacerts" -file kuleuven.pem
. The default keystore password is
changeit
. Press yes to accept the certificate.

Small tip on the solution : If you use "C:\Program Files\Java\jdk1.6.0_02\jre\lib\security\cacerts" as your -keystore file, you will even not have to set the -Djavax.net.ssl.trustStore VM parameter, it will find the keystore file automagically.

Labels: , , , ,