Published JavaDocSuppressor or jadosu v1.0 to github

August 25th, 2012

So every so many time I come across some Java code that’s littered with useless JavaDoc comments that do nothing more than obfuscate what the code actually does. So when I found myself looking for the same set of regular expressions yet again I thought it wise to finally automate it.
The binary downloads as well as the Java sources can be found on github. The whole is available under the Apache License 2.0.

Rather than modifying the original sources, the modified sources are stored at a designated  directory path which will be created. Unmodified sources can be optionally included as well by provided the ‘-i’ argument, effectively resulting in a full copy of the source path with modified sources.

Grab it here

WebSphere Portal Theme Optimization & Portal WebDAV

May 23rd, 2012

WebSphere Portal sports new theming features since 7 FixPack 2 and the freshly GA’d 8 release that enable the creation of advanced client side aggregated themes while allow for optimized delivery (that is minimal number of requests / kilobytes transfer required) to client devices : Portal Theme Optimization; here’s links to the docs for portal 7 and portal 8

For one, the theming framework itself is fully javascript library agnostic (the included theme uses dojo 1.6 on portal 7 and dojo 1.7.2 on portal 8 ) and furthermore defines a set of metadata components (modules/profiles) that express dependencies between static/dynamic html, css and javascript resources in such a way that the designer can define what resources are sent to the client by associating a profile with a theme, page or by setting the default profile for an entire Portal environment. One big benefit is you no longer need to touch code to eg. remove a feature from your theme, you just modify the profile metadata or assign a different one to the correct scope, very neat.

As a first step to creating such a theme, the right resources have to be created, primarily by copying & modifying the included theme (Portal7.0.0.2 for 7 FixPack 2).

This involves among others copying the theme directory from the WebDAV themelist mountpoint to a local harddisk for modification and copying it back afterwards to register it in Portal as a new theme.

While WebDAV is great, it did cause me to scratch my head a few times since I was noticing quite a few ‘file could not be found’ exceptions while copying back the new theme to the WebDAV themelist mountpoint and the copy operation itself did not seem to complete successfully.

As it turns out, you need to manually verify every file from your new theme has been copied over correctly and manually correct where/when needed until the entire theme directory has been trasferred to WebDAV successfully.

In my case, the metadata.properties file in the root of the theme directory was present *but* the contents were not as expected, and the localized metadata properties were missing altogether.

This was quite confusing, as a basic best practice when dealing with Portal (or any server/service) is to keep an eye on the logs (aka exceptions == bad), and the manual verification/retry was equally foreign to me (something usually completes successfully or not at all, there is no ‘partial’).

So, when adding directories to the Portal WebDAV:

  • verify everything was copied over properly, completely
  • keep correcting until everything is present

Sending email to your SSL/TLS enabled smtp with Spring from WAS/Glassfish

February 28th, 2011

So what I needed to accomplish:

  • send automated emails from a webapp using Spring 3.0
  • running on a Glassfish / WAS  instance
  • to an SSL/TLS secured SMTP (smtps) service running on a different host

Import the certificate

First of all, we need our jvm to trust the certificate of the remote host that offers the smtps service which in my case is available on port 465 (which is common).

To do that, first of all read Andreas Sterbenz’ old Sun blog post regarding the InstallCert tool he wrote.

Download InstallCert.java to some directory, move to that dir, and run
javac InstallCert.java

Next, run
java InstallCert

from the same dir to get usage instructions.

I went for the version
java InstallCert your.host.com:your_port

After selecting the certificate you want to add to the trusted keystore by pressing the associated number you’ll end up with a file called jssecacerts in your working directory.

Also note the last line of the generated output, which should be something along the lines of:
Added certificate to keystore ‘jssecacerts’ using alias ‘your.host.com-1′

You’ll need that alias for the next step.

Export the certificate from the keystore file ‘jssecacerts’

To do this we’ll use keytool, note the alias name which needs to be equal to the one mentioned in the last step:

keytool -export -alias your.host.com-1 -keystore jssecacerts -file my_actual_cert.cer -storepass changeit

We now have a file representing the actual certificate we need to trust in order for our application to be able to set up a secured connection with your.host.com

Importing the certificate

Before we get to use keytool again, make sure you have proper permissions to modify your JRE installation and go to
<jre_root>/lib/security

Eg. for the Sun (Oracle) JDK on Debian/Ubuntu <JRE_ROOT> could be
/usr/lib/jvm/java-6-sun/jre
You should see a file cacerts in this directory. Next run:
keytool -import -alias your.host.com-1 -file my_actual_cert.cer -keystore cacerts -storepass changeit

This will effectively add the certificate you just exported to the trusted certificates.

Making Glassfish trust our certificates

To do this, you need to point to the trustStore you just updated (cacerts) in the properties associated to the Glassfish JVM.
First of all copy the cacerts keystore file you just updated to <your_glassfish_domain>/config/my-cacerts.jks

Next login to the Glassfish Admin Console, and proceed to
Common Tasks -> Configuration -> JVM Settings -> JVM Options

Change the property
-Djavax.net.ssl.trustStore=${com.sun.aas.instanceRoot}/config/cacerts.jks

to
-Djavax.net.ssl.trustStore=${com.sun.aas.instanceRoot}/config/my-cacerts.jks
Save your changes and restart glassfish.

Making WebSphere Application Server trust our certificate

is documented here (among other places no doubt); basically the same steps.

Sending mail

Check out one of many samples available online showing how to send email using Spring facilities. This is a quick and dirty example without injection.

<bean id="mailSender" p:port="your_port" p:host="your.host.com" p:username="your_authenticating_user" p:password="your_pwd" p:protocol="smtps">
    <property name="javaMailProperties">
      <props>
        <prop key="mail.smtps.auth">true</prop>
        <prop key="mail.smtp.starttls.enable">true</prop>
     </props>
    </property>
</bean>

Afterwards you can just inject the mailSender and use it as desired.

Note that you can easily inject a JNDI mail session, which I didn’t do because there’s no real advantage to warrant having to ensure the proper JNDI resource(s) exist on different servers in this case.

Happy sending! :-)

SwingWorker publish() and process()

December 19th, 2010

I just converted a bunch of legacy code that made use of the add-on SwingWorker version from the Java 5 days to use SE 6′s SwingWorker. Definitely an improvement however I wasn’t getting the updates I expected using the publish() process() mechanism as all data published during the background task was being processed in one go only after the actual background task had finished.

The cause? Starting the SwingWorker operation with run() instead of (the correct) execute().

Is the Java Store dead ?

June 4th, 2010

I’ve been waiting since Devoxx for the Java Store to become available in Belgium.Seemingly zero changes since then :-(

Although it might not be the most original idea, it does sound like a natural fit for the java platform on the desktop.

Anyone knows if Oracle killed this off or if it died when James Gosling left Oracle ?

I for one am still rooting for this to actually happen. Yes I’m a dreamer.

Compiling Spring 3 from SVN on Linux

November 11th, 2009

Mostly so I don’t forget myself next time :-)

Don’t forget to checkout only the wanted HEAD revision from svn:

svn co -r HEAD https://src.springframework.org/svn/spring-framework/trunk spring-framework

If you have ant as part of your distro (as is the case in gentoo), download a binary ant distribution and run <your_new_ant_path>/bin/ant instead of the ‘default’ ant to prevent any classpath issues.

Make sure you do

export ANT_OPTS=”-XX:PermSize=128m -XX:MaxPermSize=128m”

If necessary add -Xmx512m or more too.

Enter build-spring-framework and run

<your_new_ant_path>/bin/ant

to build Spring. In order for Eclipse to be able to find all required jar’s, you’re probably best running the resolve ant target in most of the subprojects.

Open import the projects to an Eclipse workspace, set the IVY_CACHE classpath var in Eclipse prefs to spring-framework/ivy-cache

I had a few errors in tests for the oxm bundle failing, but since I don’t really need them anyways I just removed the src/test source dirs from the oxm project in Eclipse :-)

It’s 2 AM so yea, the above is probably pretty messy :)

GMail down

February 24th, 2009

I was getting 503′s and now no response at all . Lack of a temporarily down page or something similar leads me to assume this wasn’t planned upgrade or anything.

Of course this can happen to the best of us, but still: ouch!!

Me needs my mail :-(

PS: maybe it’s got something to do with SSLStrip?

+1hrs: still no workies :-| fraaakkk

+105mins : it’s back, I suppose we’ll never know what happened :)

Enabling networking in CentOS 5.2 on my ASUS P6T Deluxe

February 18th, 2009

Update : below stopped working after upgrading the kernel to version 2.6.18-92.1.22. Trying to find out why :-|

Update2 : okay I was too fast probably, seems to be working fine after a reboot :-)

The 2 onboard Marvell 88E8056 PCI-E ethernet on my P6T Deluxe weren’t autodetected by CentOS 5.2.

Got this workaround from the CentOS bugtracker :

# modprobe sky2
# echo “11ab 4364″ > /sys/bus/pci/drivers/sky2/new_id

It works! :-)

There’s a warning of data corruption on Gigabyte boards with this workaround, so better check first and do some more looking if you’re in that category.

64bit java plugin out in the wild aka Sun Java 6u12 released!

February 2nd, 2009

Get it hot! :-) As I’ll probably be waiting for this release to hit the/some Gentoo/Ubuntu repo, I have to say I’m surprised at the seemingly short interval between the last update releases. Seems 11 was only last week somehow.

As my previous Athlon64 and current Intel i7 Core are both 64bit, I do have to say I’m anxious to try the long announced java plugin for 64bit platforms. I’ve been using icedtea 6 on gentoo for a while, but as I need a Sun JVM for professional stuff I’m glad this update has finally arrived. Curious to see if it lives up to it’s expectations.

Besides all that, the included improvements seem quite numerous (take a look at the release notes)

Setting your keyboard layout in Linux through X

January 22nd, 2009

Just a quicky for future reference:
setxkbmap -model pc105 -layout be -variant basic

Needed this in fluxbox.