0 and 1′s

Getting idl2java Ant Task up and running

Posted in Uncategorized by Rama Krishna on November 25, 2009

This blog is about using idl2java Ant task to generate Java artifacts from CORBA IDL file. The idl2java Ant task is provided by OpenORB, an open source CORBA implementation.

Any CORBA project starts with a idl file that describes the interface or service. Then, we use a tool to generate language specific client and server artifacts. The tool can be a command line executable or a Ant task.

The following idl file represents a simple attendance service.


module tracker {

	interface attendance {
		long addEmployee(in string empName);

		string removeEmployee(in long empId);

		void enterEmp(in long empId, in string empName);

		string empReport(in long empId);

	};

};

The Ant Task idl2java is contained in openorb_orb_tools-<version>.jar. So, i add the jar to the Apache Ant Classpath. The task defination class is org.openorb.compiler.taskdefs.Idl2Java. I add the task defination.

The Ant build file is a very simple one. It invokes the idl2java task with two attributes, one points to the directory which contains the idl file and another points to the directory where the generated source files are dumped.


<project>
	<property name="idlDir" value="idl">
	</property>
	<property name="srcDir" value="src">
	</property>
	<target name="idl2java_task">
		<idl2java srcdir="${idlDir}" destdir="${srcDir}" verbose="false">
		</idl2java>
	</target>
</project>

The Ant task idl2java has extensive set of options available. Check the documentation for more details.

Execute the Ant task and the build fails with the following error.

Buildfile: C:\java\myProjWorkSpace001\CORBAProj\build.xml

idl2java_task:
BUILD FAILED

java.lang.NoClassDefFoundError: org/openorb/util/launcher/CompoundClassLoader
Total time: 188 milliseconds

As per error message, a class is missing. The documentation does not mention of any additional jar that needs to be added. I decided to check more on this missing class in additional jars that accompany the OpenORB distribution. But, none of them have it. Then, i checked out in website http://www.findjar.com and found that the jar tmporb-tools-1.0-DEAD.jar had the class. The website http://www.findjar.com provided a maven link for the jar, but i got 404 error. Searched in Google and found a maven repository which had it.

I added this jar to the Ant Classpath and executed the build script again. The ant task executed successfully and the Java artifacts coresponding to the idl are generated.

C:\java\myProjWorkSpace001\CORBAProj\src>cd tracker
C:\java\myProjWorkSpace001\CORBAProj\src\tracker>ls -ltr
total 22
a-----      3444 26-Nov-109 00:33 attendanceHelper.java
a-----       531 26-Nov-109 00:33 attendanceOperations.java
a-----      1809 26-Nov-109 00:33 attendancePOATie.java
a-----      7360 26-Nov-109 00:33 _attendanceStub.java
a-----      3359 26-Nov-109 00:33 attendancePOA.java
a-----      1244 26-Nov-109 00:33 attendanceHolder.java
a-----       222 26-Nov-109 00:33 attendance.java

Next, to move ahead with implementation. :)

Reblog this post [with Zemanta]
Tagged with: ,
Follow

Get every new post delivered to your Inbox.