Development
SVN fubar
Trying to merge a branch back into the trunk, I’ve been getting this:
Merge operation failed.
RA layer request failed
svn: REPORT of '/svn/xyz/!svn/bc/9110/branches/whatever-module/my_cool_branch/whatever-module': Could not read chunk size: Secure connection truncated (https://www.failhost.com)
for days and days from both Eclipse/Subversive and Tortoise (Tortoise provided a slightly different error message, but it was essentially the same). Suck… Becoming convinced that this is a permanent error and being not very interested (to say the least) to file a support request with our customer about that issue, I resorted to command-line SVN – motivated by pure frustration and the intent to give it one last try – and say what? It worked. Painless.
$ svn co trunkURL
$ cd workingCopy
$ svn merge -r 9059:HEAD branchURL
$ svn ci
<enter message and GO>
$ mv sophisticatedTools /dev/null
I suppose that this might have been a double tool fail, look at the error message: maybe the tool(s) attempted to get revision 9110 of the branch which does not exist, maybe something else – I don’t care too much – I tried several combinations of options (normal merge vs. reintegrate in Subclipse etc.) – it did not work – I ran the errors through Google several times – didn’t find any hints except some Apache DAV module memory leak voodoo – I think I’ll simply ALWAYS use the command line client for merging in the future. EOF.
Next “Meet the Experts” at codecentric
The next “Meet the Experts” is due to happen 09/04/09, see the codecentric blog for details! The first event, focused on performance, was a great experience, so maybe you’d like to join the next one and learn something about agile methods? I’m sure it will be fun.
Basic Reflection Magic, and BeanUtils too
In my current project, a good deal of my daily work goes into an often repeated sequence of tasks:
- Read data from an XML file (so-called “structured content”, OpenCms)
- Put the data into an object tree in order to do stuff with it
- Put the object(s) on a JSP page context in order to display parts or all of the contained data.
The old way was a bit less comfortable, being heavily based on Maps and Lists that were filled with single elements of the structured content and that then had to be parsed a second time in the JSP. I like the use of transfer objects a lot better because it keeps the code clean and easy to maintain and because it’s easier to apply modifications to the data between reading it and displaying it.
Thus, I’m searching for a nice way to get the cleanest, most concise code for the XML -> object tree step. For simple tasks, I make havy use of BeanUtils at the moment. Let’s say the XML contains elements called “title”, “link” and “image”. I then create a class with exactly the same attributes and sensible types (in this case, they are all Strings, but I do use boolean and numeric values in some places).
Because the attribute names in the class are the same as they are in the XSD, respective XML file, I can then easily populate an instance of my class while reading from the XML at the same time, roughly like this:
PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(Teaser.class); Teaser teaser = new Teaser(); for (PropertyDescriptor pD : propertyDescriptors) { try { String xmlPath = /* create basic XPath here */ + pD.getName(); BeanUtils.setProperty( teaser, pD.getName(), document.getStringValue(cmsObject, xmlPath, currentLocale) ); } catch(...) {} /* Exception handling and logging omitted for brevity */ }
This code is partially specific to the OpenCms API, but I think you get the point.
In most situations, you would probably get the PropertyDescriptor array only once and put it into a constant, because it’s not very likely that the transfer class will change during runtime.
This way of saving about n-1 lines of code where n equals the number of attributes you want to read from the XML makes me very happy.
But, as with every solution, I’m still looking to improve this even more. The downside at the moment is that I cannot remove loops yet for lists of entries in nested XML files. Thus, I did some research + experimenting on reflection mechanisms today. My intention: to pass the top-level transfer class into a method that recursively checks the structure (e.g. dives down into lists of other custom transfer classes, e.g. List
First experiments were quite successful and I recommend this article: Java Reflection: Generics, especially section 4, “Generic Field Types”.
I’ll omit my code snippets here, because it’s much more fun to build stuff like this yourself ;-)
I’m quite fascinated by the inner workings of reflection at the moment, and I suppose that I will research this topic until I have a working bit of code – only to then find some proven framework that does the same thing – but maybe my small, self-made solution is just so small and simple that it does NOT require me to put an extra 10 JARs into the project… or maybe the idea turns out to be complete crap – we will see. Essentially, it’s all about having fun with technology :-)
I’ll write a follow-up as soon as I have new results. Stay tuned!
Eclipse 3.4 (Ganymede) vs. SVN
If you’d like to freak out a little, try getting Ganymede to be SVN-capable. I can only say this much: choose Subversive (what else) and the latest SVNKit implementation and you will be likely to have few problems. Finding out which connector to pick (3 alternatives, 2 versions each) can be a pain, though. Many people have blogged about this, for example my workmate Nick. For more, try Google.
3.5 Steps to heaven (the first doesn’t count because the instructions posted there didn’t really work for me):
- Go to eclipse.org and be confused
- Go to Polarion and add the Ganymede update sites to your Eclipse
- In Eclipse, go to Help -> Software Updates and pick at least “Subversive SVN Team Provider” from “Ganymede” -> “Collaboration Tools”, then from the Polarion update site, category “Subversive SVN Connectors”, pick “Subversive SVN Connectors” (didn’t do much for me, I still installed it though) and “SVNKit 1.2.0 Implementation”
- Install, restart Eclipse, be happy.
Eclipse and SVN is by far the worst Hide and Seek game I’ve ever played in 2 years of working with Eclipse :-)
Hibernate cascade options
I just read about 85% of the Hibernate reference documentation because I couldn’t find any information on the cascade options you can set in your mapping file. Here’s what I found and where I found it:
Chapter 5.1.12 “many-to-one”:
Setting a value of the
cascadeattribute to any meaningful value other thannonewill propagate certain operations to the associated object. The meaningful values are the names of Hibernate’s basic operations,persist, merge, delete, save-update, evict, replicate, lock, refresh, as well as the special valuesdelete-orphanandalland comma-separated combinations of operation names, for example,cascade="persist,merge,evict"orcascade="all,delete-orphan". See Section 10.11, “Transitive persistence” for a full explanation. Note that single valued associations (many-to-one and one-to-one associations) do not support orphan delete.
Section 10.11 does indeed explain quite a lot about cascading. I simply wanted a collection of child objects to be deleted as soon as the parent is deleted, so I’ve now set the cascade option on the list mapping to “all, delete-orphan”.
Exception-Handling Antipatterns
Exception handling in Java is a very useful, yet often misunderstood mechanism. I wouldn’t call myself an exception(al) expert in this area either. While googling for something related to exception handling, I found this article today:
Tim McClune on Exception-Handling Antipatterns
Tim provides several examples of the most common mistakes or bad-coding-fails as far as exception handling is concerned. Read it! :)
How to clean clustered MySQL tables
Assuming you have three tables in a MySQL cluster, each using the ndb storage engine. The tables are called A, B and C. C references B and B references A, but there are no foreign keys in clustered tables – or if there are, they are simply ignored. So how would you do a cascaded delete operation on the clustered tables? Here’s how to do it.
Trainings Galore
I took part in two interesting and entertaining trainings during the last two weeks, both highly relevant for my daily work.
The first training I went to was a SCRUM master certification training with Jeff Sutherland and Serge Beaumont (Xebia). It took place in Utrecht on November 13th/14th. Utrecht is quite a nice city, I will go there again next year and look at it in more detail. Next time I travel to the Netherlands, I’ll go by train or helicopter – 90 minutes on the way back for 30 kilometers is too much :-) The SCRUM training itself was quite packed with entertaining stories and hands-on exercises and I learned a lot about team dynamics. As we have been doing SCRUM at work for some weeks now, I’m keen to see how this method of working will develop. After my return home, I immediately started doing SCRUM at home as well – very useful to get things done :-)
This week (November 18-21) we had an in-house Core Spring training with Mike Wiesner, who is a very good trainer as well. The training was very well structured with labs for each topic. SpringSource does not only give a complete set of slides to every participant, but also a printed guide for the labs and a complete Eclipse-based development environment with prepared lab projects and complete solutions. Four days of condensed input gave me quite a bit of brain load, but I think it was well worth the time. I also learned a lot about what I have been using in my projects for almost two years now. I will take the “Certified Spring Professional” exam as soon as possible. The training participation certificate will then be exchanged with the “real” certificate :-)
Thanks to all trainers for their good work!
Enum vs Javadoc
Inspired by a work-related question, I tried to add Javadoc to an Enum. In fact, I simply followed the example found in the first Google search result, but nevertheless here is how to do it:
package demo; /** * This Enum is documented * @author myself */ public enum DocumentedEnum { /**First entry*/ FIRST, /**Second entry*/ SECOND }
Look at the image to see what Javadoc makes of it (standard parts removed):
I think this is quite nice.
Eclipse building blocks
In the Eclipse world, there are two issues that might become real suckers when it comes to developing in teams:
- People who use Eclipse for development usually have their very individual preferences about plugins, tools and so on
- Every time you upgrade to a new Eclipse version, you have to reinstall all the plugins.
If you intend to give the same Eclipse configuration to the entire team, you need to get a bare bone Eclipse, install all plugins, and then pack a bundle and pass it to the team members.
As an alternative, you can use yoxos on demand in order to create an Eclipse configuration profile, enabling multiple people to download exactly identical Eclipse packages.
The interface is quite easy to use. Components are selected from a tree view. For every component selected, dependencies are checked automatically, the necessary components can then be added to the package.
If you have an account there, you can save the profile(s) you created, in order to reuse them. Try it! :-)

