Wednesday, April 8, 2009

Another Bundling tool - Bundlor

This is alternative to BND which can be used to build bundles.

This tool has much more provisions , than bundlor and is provided by spring .It scans much more than just the java class file, including spring configuration files and also has support for hibernate annotations.

It also helps to add exceptions during building the bundle by using a template file.


Uses directive in OSGi

Uses directive is very important when you shift to versioning of jars, that is when two bundles share the same class.

A runtime type is defined by the combination of the type's fully qualified class name and the class loader that defined the type. If the same fully qualified class name is defined by two distinct class loaders, then this produces two incompatible runtime types. This incompatibility causes runtime errors if the two types come into contact. For example, attempting to cast one of these types to the other will result in a class cast exception.

The conflict arises when one bundle(A) imports one version of the class from bundle ( B v1.0) and another bundle(C) depending on bundle A imports a class from different version of class from (B v 2.0) .

This can be solved by mentioning strict dependencies on the imports , but when the dependency tree gets huge this will be difficult to manage , and hence can be easily solved by the uses attribute.

The following article has detailed explanation on the uses attribute and how errors on that can be diagnosed.


Remote Debugging using Eclipse

Set these parameters on the remotely running java process

DEBUG_OPTS="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n -Djava.compiler=NONE"

where 8000 is the port on which the java process listens to debug commands from eclipse.

When the java code is compiled ensure that debug is enabled

In the case of ant set

      <javac debug="on" ....> ... </javac>

from Eclipse choose
Run -->
Debug Configurations -->
Select Your Project
Give the IP and the Port of the machine where the remote process is running.
Finally click on Debug

Now you can set break points as usual from eclipse and the window will pop up when the execution reaches that point.

Free Domain Names @!