Archive for the 'F/OSS' Category

Initial Derby-support in DbFit

DbFit does heavy lifting!This just in: you can now run FitNesse tests with DbFit using Derby/JavaDB as your database of choice.

Have a go and download it from Subversion here: https://dbfit.svn.sourceforge.net/svnroot/dbfit/dbfit/dist/dbfit-20080530.jar

It’s not terribly complete which you can tell from the limited set of acceptance tests available, but it works for the basic cases.

Notable omission: Stored Procedures. My current project doesn’t need it so it’s not yet implemented.

If you are missing something, let me know and I will add it. (To get it fixed fast, also supply a failing DbFit-test case.

JtestR 0.2 out now

Ola Bini+friends’ cool tool, JtestR has just been released in a 0.2 release that adds some nice features and fixes a few bugs as well.

JtestR, for those of you who haven’t heard about it yet, is a tool to enable testing of java code using alot of the cool ruby tools available for testing such as rspec, test/unit and more.

As if that wasn’t enough, it’s also integrated nicely with Ant and Maven and can also run your existing junit and testng tests.

Any day now I’ll try to find some time to put together a post on my experiences with using ruby to test java code. But for now, go take a look at jtestr!

Manually adding MD5 checksum to files using Ant

I just added some JAR’s from the DctmUtils project to my local Maven repository to be able to use it like anyother dependency. In doing so I had to create a POM and the structure for the JAR. This in itself works like a charm, but if you do not supply valid checksum-files (SHA1 or MD5) for the POM and JAR Maven 2 will give you warnings.

Solution:
Save the following in a build.xml file in your folder and run ant md5 to generate MD5-files for all files in the folder. Easy peasy.

<project>
  <target name="md5">
    <checksum forceOverwrite="yes" fileext=".md5">
      <fileset dir="." excludes="**/*.md5"/>
    </checksum>
  </target>
</project>

Getting a handle on custom WebTop components using Spring

When customizing an EMC Documentum WebTop application and using the Spring Framework to tie everything together, you find yourself wishing you could use Dependency Injection at all places in the existing WebTop source.

I don’t yet know of a workable way to achive that sort of plumbing with a WebTop application (especially for all types of existing components and tags) to just expose any new dependencies and let Spring handle it all.

Another way to achive interoperability with Spring and still use most of what’s good there is to allow our legacy components to have access to a Spring ApplicationContext, but setting one using Spring is not feasible because of the same reasons as above. Thus we introduce the StaticSpringApplicationContext.

The StaticSpringApplicationContext works simply by containing a static reference to the Spring ApplicationContext and exposing a static helper method to get beans configured by Spring.

Configure the helper class by defining it in your web.xml like so:

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

And at least the following in your WEB-INF/applicationContext.xml file:

<bean id="StaticSpringApplicationContext"
class="com.palbrattberg.spring.StaticSpringApplicationContext" />

This will make sure Spring itself configures the StaticSpringApplicationContext on startup.

Now you can simply get your configured beans (preferably in your constructor) like this:

MyBean myBean = (MyBean) StaticSpringApplicationContext.getBean("myBean");

Now you are free to use Spring for configuring all your future code.

Source code for StaticSpringApplicationContext

image_science not found using attachment_fu on Windows

I’m using the attachment_fu plugin for Ruby on Rails for a project I’m working on and the plugin works just great on the test and deployment platform using GNU/Linux (Fedora) but I had some troubles getting it to play nicely on my Windows workstation (yeah, yeah, I should get a Mac, and can’t we all just get along? …).

The problem I had was with the ImageScience processor which just doesn’t like the line: require 'image_science'

Fix is easy enough, edit vendor/plugins/attachment_fu/ lib/technoweenie/attachment_fu/ processors/image_science_processor.rb by replacing require 'image_science' with

if RUBY_PLATFORM =~ /mswin32/
  require 'imagescience'
else
  require 'image_science'
end

Tables and images in JSPWiki2PDF!

Finally. The two bugs most people have requested (and for a long time I might add) for my PDFPlugin for JSPWiki was support for tables and images. It’s now here!

I’ve just released version 2.1 of jspwiki2pdf and with that you can now see your images and tables in your PDF-files.

Read more on JSPWiki or the jspwiki2pdf projecty page.

Google Code Hosting is here

Just a few days after I grew tired of managing my own subversion repository and gave myself the treat of DevGuard’s hosting services (which are quite nice so far), Google launches Googe Code Hosting.

As usual with Google, this is a no-fuzz, no-frills webpage that allows to sign up and create a project with a very basic offering (Wiki, Issue tracker & Subversion) as long as they choose an open source license and understand that all they publish will be freely available for the world (and Google).

I think it looks lika a promising alternative to Sourceforge and others, suitable for the smaller projects where you just want a little place to save your stuff and registering a new project at Sourceforge is too much work.

I will be using it myself ASAP, and promise to get back if it’s better or worse than expected.

Give it a shot!

Tomcat and AbstractMethodError

As I’m moving some old web applications to a newer Tomcat (testing version 6) I ran into some bad JSP and Java errors. The logs complained about no JAVA_HOME (which was bogus of course), cannot find jspc and a bunch of java.lang.AbstractMethodError’s.

The problem was one of having an offending JAR-file in the WEB-INF/lib directory of an application. (In this case jasper-compiler.jar & jasper-runtime.jar)

I simply had to remove these and restart Tomcat and all was well.
Continue reading ‘Tomcat and AbstractMethodError’

MySQL 5 and Unexpected end of input stream

As I ran into this beautiful Exception once again and had to think about it again I decided to put it up for you googlers.

Problem: You have upgraded MySQL server to 5 and you keep getting errors even though it used to work.

Solution: Upgrade your driver to the latest version by downloading it at the MySQL developer site.

Rationale: MySQL changed the implementation of the protocol, which is why you need to trade that oldie JAR for a shiny new one.
Continue reading ‘MySQL 5 and Unexpected end of input stream’

ClassNotFoundException using XMLUnit with JDK 1.4

I recently set up a testcase for validating generated XML and in doing so, decided to use the XMLUnit extensions to jUnit.

When running my testcase, I got the following stacktrace:

java.lang.ClassNotFoundException: org.w3c.dom.ranges.DocumentRange
	at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:141)
	at com.client.MapHandlerTest.testMarshal(MapHandlerTest.java:79)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

This client uses a fairly old release of Java 1.4, and it appears the

org.w3c.dom.ranges.DocumentRange

class (and family) hadn’t entered the JDK at that time.

No worries, just downloaded a more recent XML parser (Xerces 2.8.1), added xml-apis.jar to my classpath and the tests run smoothly again. :)