svnsync to existing repository

Basically I will explain how to synchronize with svnsync on an existing repository. I had trouble to find the info on the Internet so I am sharing it. I am by no mean a subversion administrator therefore if the info is not correct please be kind to let me know.

Yes I know subversion is not really 2013 but recently I had to synchronize a large master subversion repository with a slave. The slave had to be rebuilt from scratch. It turned out that synchronization with svnsync was really too slow to be considered. Therefore to speed up the process. I created a svn repository on the slave machine :

svnadmin create myrepo

And synced by dumping and loading through a ssh tunnel :

 svnadmin dump /var/subversion/myrepo | ssh remoteuser@remotehost "svnadmin load /var/subversion/myrepo "

If you sync with svnsync it will complain that the repository has not been initialized with it (svnsync init). No panic, a bunch of revision properties for revision 0 have to be created.

The properties are:

  • svn:sync-from-uuid : the uuid of the master repository. Can be found with the svn info command.
  • svn:sync-last-merged-rev : the last merged revision. The synchronization will resume from it. So it has to be set the first time to the last revision, can be retrieved with svn log.
  • svn:sync-from-url : The URL of the master with the file scheme like file:///var/subversion/myrepo.

Set the properties with the user that does the svnsync on the slave repository, example:

svn propset --revprop -r0 svn:sync-from-url "file:///var/subversion/myrepo" file:///var/subversion/myrepo --username syncuser

Last post

I decided to no longer post on my blog due to a serious lack of motivation, time and inspiring topics ;-). Of course, comments will now be closed. As a side note here are the titles of drafts that never turned into posts:

  • Difficulty of choosing a Java web framework
  • Seam managed persistence context and Spring
  • Bye Bye computer book shelf
  • Drools flow or jBPM4 ?
  • Ejb3 on JBoss with Maven
  • Creating a Spring based library (with its own context)
  • Au revoir Windows vista

Update January 4th 2012 : Migrated blog to github.com, revamped it. It is now powered by octopress and statically generated (it used to be fueled by Wordpress)

Mimic facelet layouts in grails

I wanted to mimic facelets <ui:insert /> and <ui:define /> tags in grails.I find facelets to be quite powerful because it allows to define a fragment in your template that can be redefined by the view, otherwise a default fragment is displayed.It can be useful for instance for a menu where you want all views to use a default menu and some use another menu.

In facelets, you would create a template file and add a <ui:insert /> statement for the menu, like this:

<ui:insert name="menu">
<ui:include src="../frags/menu.xhtml" />
</ui:insert>

Here the <ui:insert/> statement by default includes with the help of the <ui:include/>element a menu fragment (a partial page).

In your view you could if wanted redefine the menu with the <ui:define/> element, like this:
<ui:composition template="layout/template.xhtml">
<ui:define name="menu" />
</ui:composition>

Override default menu here

Grails template system is handled by sitemesh. To achieve the same goal, you can in your template file (layout/main.gsp for instance), add the following element for the menu :

<g:pageproperty name="page.menu" default="${render(template:'/frags/menu')}" />

It achieves the same purpose, actually instead of defining a page section like in facelets, it displays the calling page’s <content> element named menu if present (control is inverted but the result is the same).Otherwise, if the <content> element is not found, the menu fragment is rendered.The fragment page should be in our example created in the frags directory under the name _menu.gsp. In your view, you can therefore define the menu section of your template by declaring a content element.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="layout" content="main" />
<title>Show Book</title>
</head>
<body>
<content tag="menu">
<div>Override default menu here</div>
</content>
<!-- More content here -->
</body>
</html>

Acquisition de Sun par Oracle

Pas sûr que Java soit gagnant dans l’histoire. Les incertitudes sur le devenir des produits Java n’est pas fait pour inciter les décideurs à opter pour cette technologie. Quelles sont les futures cibles : SpringSource, Redhat ? Sachant que SpringSource a été largement financé par des VC, à mon avis c’est un bon candidat. Bref, je me mets à la place d’un DSI aujourd’hui; si je ne veux pas prendre de risques j’opte pour .Net et les produits Microsoft : ligne de produits complète, cohérente et intégrée qui ne va pas disparaître d’ici 6 mois (j’exagère un peu…).

Je pense aussi que la période de flottement qui va suivre accentuée en + par une baisse d’investissements liée à la conjoncture va freiner grandement l’innovation autour de la plateforme Java et laisser le champ libre à d’autres technologies. Java n’est pas prêt de combler le retard sur C#.

Bref, sans doute quelques mois difficiles en perspective pour la plateforme Java avant d’y voir + clair.

Seam usage in production

There ‘s an interesting thread on the Seam forum about Seam in “profesional use”. Performance and steep learning curve are often mentioned as drawbacks.

Seam heavily relies on proxy based components created by javassist. And javassist is known to be unperformant compared to cglib. This library might have been chosen due to politic reason at JBoss. Seam Managed Persistence Context (SMPC) is also seen as a culprit but i guess that like many other frameworks you have to understand what’s underneath the carpet, lazy loading in some use cases can really hit performance.

Scalability is not mentioned but i guess that since Seam is stateful it also can be an issue for large websites.

For the learning curve, it might be true if you don’t come from the JavaEE world or have never developed JSF applications. Seam still requires good knowledge of JSF 1.X and how it corrects it in many ways. The request lifecycle is also complex albeit powerful.Also other “lightweight” JSF based frameworks are quoted like makefaces.

Seam for me is both a IOC container specialized for web development and a web integration framework of Java EE (Ejb,Web beans), JBoss stack (jBPM, Drools, Richfaces, JSFUnit) and commonly used libraries (quartz,jfreechart, itext, javamail,etc.) It also addresses many commonly asked features (conversations, mail sending, page caching,etc.) I am not sure for the future of Seam. Seam 3 might be a complete rewrite due to support of JSF 2 and JSR-299 aka Java Contexts and Dependency Injection, but it is a comprehensive and efficient web framework with a decent IDE (JBoss tools).

Economic downturn and impact on javabloggers

I wanted to know if the economic crisis had an impact on blogging. I was curious because it seemed for me that the blogs that i usually follow had less activity . With the help of a groovy script and gchart, here’s the last 2 years monthly blog posts count (don’t know why there’s a high peak for July 07). It seems that, so far, java bloggers still post.

For the quality of the blog posts that’s another story but my blog is not a good example ;-)

The source :

JBoss resources

I recently discovered 2 good web sites that provide good JBoss knowledge :

  • Master the boss : especially with articles with jBPM/JBoss ESB integration, jBPM best practices and JBoss AS tuning (a little bit outdated by the way, but still a good resource).
  • Enterprise BPM blog : blog by a Redhat engineer involved in jBPM and WS-BPEL jBPM implementation. It has also links to other jBPM related sites.

Some Maven tips

First post of the year, here are some Maven tips you might find useful (or obvious for experienced users):

  • How to version commercial libraries in your SCM and use them as dependency ?

In case you don’t have your own central repository and you’d like to version your libraries in your SCM server, you can declare in your pom a repository like this :

<repository>
  <id>sipphonyrepo</id>
  <url>file:///${basedir}/../repository</url>
</repository>

The ‘repository’ directory should be versioned in your scm server but it also means that it should be checked out with your project. Also like any other repository, the dependencies will be copied in your local repository.

*How to just copy files ?

It might be useful on a development machine to copy files while installing an artifact, for instance you might want to copy a JBoss datasource file to a JBoss profile to make sure it’s deployed. For this you can use the Maven resource plugins. For instance the following plugin statement will copy the datasource file to your JBoss server’s default profile deployment directory if JBOSS_HOME environment library is defined (on the development machine) :
<profile>
<id>jboss.deploy</id>
<activation>
<property>
<name>env.JBOSS_HOME</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactid>maven-resources-plugin</artifactid>
<version>2.3</version>
<executions>
<execution>
<id>copy-ds</id>
<goals>
<goal>copy-resources</goal>
</goals>
<phase>install</phase>
<configuration>
<outputdirectory>${env.JBOSS_HOME}/server/default/deploy</outputdirectory>
<resources>
<resource>
<directory>${basedir}</directory>
<includes>
<include>mysql-ds.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
  • How to perform complex build build logic ?

One solution would be to use profiles for that like in the above example. But it can quickly become cumbersome and limited. So a good option is to use Ant Maven plugin with ant-contribs dependency for control statements and loops or even better the groovy GMaven plugin (avoiding XML verbosity).Profiles have still the benefit of clearly identifying an intent in your build. The following command will list all profiles:

mvn help:all-profiles

If build logic can be extracted and used in different contexts, it’s time to create a plugin. It’s quite simple.

  • How to create an artifact of a zip or tar ?

One obvious solution is to use maven assembly plugin but if you need to add some custom logic during packaging, you could just create the zip or tar file with Ant maven plugin or groovy GMaven plugin and gant during the package phase. Then attach the file to your project with Maven build helper plugin and its attach-artifact goal to install it in your repository during the install phase. Once installed in your local repository, the zip or tar file can be become a dependency, just use the proper type in the dependency declaration.

<type>zip</type>
  • How to create a full delivery layout with multiple archetype ?

My advice for creating a comprehensive delivery directory structure would be to use a dedicated module, take advantage of ant,assembly and resource plugins for that. Struts2 has such a module : see the assembly module’s pom