Category: Development

Nexus installation on Tomcat 7 with JDK7

I tried to install Nexus 1.9.2.2 OSS on my Tomcat 7.0.20 with the new Oracle JDK 7. This was not a big success. Ok first of all make sure to use the unpacked version of the nexus war or else it wont be able to find the NEXUS_PLEXUS_WORK environment variable.

Second, you need to patch the unpacked war. Strip out the xstream-1.3 and add the latest snapshot. Also add the latest xmlpull.org API jar to the WEB-INF/lib of the unpacked nexus war.

More info see this JIRA ticket.

Solving JAX-WS problems on Tomcat 7

When running JAX-WS applications on Apache Tomcat 7 you might encounter the following exception:

java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
	at com.sun.xml.ws.model.RuntimeModeler.processExceptions(RuntimeModeler.java:1077)

To solve this add the webservices-api-x.y.jar to the CATALINA_HOME/endorsed directory.

Do NOT add the webservice-rt-x.y.jar to the endorsed directory or you will encounter the following exception:

java.lang.NoClassDefFoundError: javax/servlet/ServletContext
	at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.<init>(WSServletDelegate.java:102)

Git server on Windows

DVCS

Distributed version control systems gained a lot of attention over the last few years. There are many hosting providers that offer free DVCS space on the web. But there are situations that you want to run your own private DVCS server and do not want use a publicly and open DVCS like Gitorious, Github or BitBucket. Of-course you can always buy a commercial offering for a private DVCS solution.

The nice thing about a DVCS is that there is not one version, there are multiple ‘versions’ of a source tree. But at some point you do want a central location to store your (releases) sources. In this article I will explain how to setup a Git server on a Windows machine using Apache to server Git request over HTTP.

If you want to know more, Atlassian has an excellent presentation on DVCS, recorded at the Atlassian Summit last June. And Linus Torvalds talk on Git is worth your time: http://www.youtube.com/watch?v=4XpnKHJAok8

msysgit

You will need to install msysgit, I used version msysGit-fullinstall-1.7.6-preview20110708.exe. On my machine I installed msysgit to D:/dev/msysgit

Repositories

Create a directory that contains your Git repositories, for example: D:/dev/repo/git. To get you started, go to the directory and create an empty Git repository.

cd D:/dev/repo/git
git init --bare Test.git

Apache configuration

In this tutorial I use Apache 2.2.19. You need to setup git-http-backend.exe in order to serve Git through Apache. First copy ..\msysgit\mingw\bin\libiconv-2.dll to ..\msysgit\libexec\git-core or else you will get a 500 error from Apache. To test if your setup works run ..\msysgit\libexec\git-core\git-http-backend.exe

Add the following to your Apache conf\httpd.conf:

SetEnv GIT_PROJECT_ROOT D:/dev/repo/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAliasMatch \
        "(?x)^/(.*/(HEAD | \
                        info/refs | \
                        objects/(info/[Apache Git server on Windows^/]+ | \
                                 [0-9a-f]{2}/[0-9a-f]{38} | \
                                 pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
                        git-(upload|receive)-pack))$" \
                        "D:/dev/msysgit/libexec/git-core/git-http-backend.exe/$1"

I also made the Apache DocumentRoot point to my Git repos:

DocumentRoot "D:/dev/repo/git"

<Directory "D:/dev/repo/git">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

The result:

Using the repo

You can create a local copy of this git repo using the clone command.

git clone http://localhost/Test.git

Warning

Make sure that you setup authentication if you do not want your sources to become publicly available. This can be done using the regular Apache authentication modules.

Links

Many thanks to: http://www.jeremyskinner.co.uk/2010/07/31/hosting-a-git-server-under-apache-on-windows/

Asus EEE Pad Transformer (with dock)

Yeej! Yesterday I read on a Dutch forum that the Asus EEE Pad transformer with dock arrived in the Netherlands. So immediately I drove to Amsterdam to pick one up ;-) And my, my what a fancy device it is!

The specs

The tablet uses the 1GHz Nvidia Tegra 2 processor, has 1GB RAM, a Gorilla Glass multitouch screen (10.1 inches), 1.2 and 5MP cameras, gyroscope, compass, GPS, HDMI output and so on.

Keyboard dock

The keyboard is little more than a dock with a trackpad and battery (without the dock, the battery life drops to 9.5 hours). With the dock Asus claims a battery life of 16 hours.

Once the dock is attached Android presents a mouse cursor. This actually works very good, especially when writing emails and doing quick navigation.

Micro + SD

The device itself has a MicroSD expansion slot. The keyboard dock includes a SD slot. I have not tried them yet. One of the main reasons for not buying the 32GB version was the availability of the memory expansion slot. The device will cost you 100 euro more for the 32GB version while 32GB of MicroSD memory only cost a much as 45 euro.

System update

After the initial setup I got a notification that a system update was available. So I installed it an rebooted the device. For some reason it gave me a black screen after the update installation so I had to reset it after the update by pressing the power button. When it started the device again I noticed that Android 3.1 was installed on it, yeah baby!

Multiple Google accounts

What I like already is that it is very easy to setup multiple Google accounts and switch between them in application. Both my wife and I will be using the device.

Agenda

The build in Google Agenda is one of the features I use most often to synchronize appointments between multiple calendar. The Agenda app in Honeycomb has a fresh and clean interface that is wel usable on tablet format.

Market

The market app is a bit different in Honeycomb from what I am used to on my Android 2.2 phone. One flaw in the Honeycomb market is that you are not able to rate applications in the market app.

Not all apps are ready for Honeycomb yet. Some apps work but a lot of them need to be updated to work on the 3.x version of Android. I have sent a few crash reports to developers already ;-)

More to come

I have been playing around with it today but it runs very smooth. I will post some impressions later this week or next week.

I’ll Keep you posted!

Moving toward standard APIs

For my current client I am involved in the process of creating a list with allowed, deprecated and blacklisted frameworks and dependencies. I`ve noticed that there are a lot of internal projects that copy dependencies and framework choices from previous projects and are therefore using old and deprecated libraries. We are trying very hard to get projects to use standard APIs and get rid of the old stuff.

Frameworks like Spring, Google Guice, Seam, etc, are also moving toward standard APIs. Spring 3.0 embraces a lot of standards APIs like JSR303, JSR330, JSR317, which in my opinion is a good thing!

Why move to these new APIs?

It allows developers to focus on one API instead of learning a specific API for each framework. Switch or to other/competing frameworks or upgrading becomes easier. For example, the gap between Spring 3 and Java EE 6 (CDI + EJB3) has become much smaller due to these new standards. A good example were standardisation helps is the JSR 303 Bean Validation API which is supported by both Spring, Hibernate/JPA, JSF, etc.

Springmodules validation

In Spring 3 the JSR 303 Beans Validation API support was introduced which effectively replaces the springmodules validation project. Users of Spring 3 are encouraged to use this new JSR 303 Beans Validation API.

More information

When you want to leverage the standard API in your project, please have a look at the following articles:

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/validation.html#validation-beanvalidation
http://www.openscope.net/2010/02/08/spring-mvc-3-0-and-jsr-303-aka-javax-validation/

Spring Dependency Injection annotations

Spring and Google have been working on a standardisation for Dependency Injection annotations, result: the JSR 330 specification. This is a standard API for doing annotation based dependency injection. Spring supports this API since Spring 3.0 (http://blog.springsource.com/2009/09/29/spring-framework-3-0-rc1-released/).

More information

Have a look at the following articles:

http://code.google.com/p/atinject/
http://ralf.schaeftlein.de/2009/11/19/spring-3-0-rc-2-and-jsr-330-dependency-injection-for-java/

Hibernate vs Java Persistence API

The Java Persistence API (JPA) was introduced as part of the Java EE 5 and EJB 3 specification. JPA is in a way the formalisation of Hibernate in a Java Specification (JSR). Since the makers of Hibernate were actively involved in this specification there are numberous of simularities between Hibernate and JPA.

Differences between Hibernate and JPA

JPA defines the standard API for using persistence in Java. You can use Hibernate as a JPA implementation. When using JPA developers can leverage the power of a standardised persistence API and still being able to use Hibernate specific functionality if required. But it opens up possibilities to move to EclipseLink or some other JPA implementation.

Hibernate 3.5 – JPA 2.0

In Hibernate 3.5 a lot of Hibernate subprojects have been merged back into the Hibernate core. This makes it easier to configure and use JPA in conjunction with Hibernate. The JSR 303 API was not officially included as a requirement for JPA 2.0 but Hibernate integrates nicely with the validation specification.

Conclusion

There are a lot of examples that demonstrate the benefits of using standard JSR APIs whenever possible. I would advice to use standard APIs whenever possible and only use specific framework functionality when the standards do not provide enough functionality.