Blogs from Iterox

Java Enterprise Development

Posts Tagged ‘Plug-in Development

Exploring Apache Axis2 and Eclipse Plug-in Development

with 80 comments

Introduction

Exploring Service Oriented Architecture I decided to dive into Apache Axis2. I like to work with Eclipse IDE and having found this tutorial I started it right away. I use Eclipse Ganymede (SDK 3.4.0) with JDK 1.5.0_16 and Tomcat 6.0.18 (on XP/SP3) and did not pay too much attention to the fact that the tutorial was written for Eclipse SDK v3.2 and Axis2 Eclipse Plug-in v1.3 with JDK 1.4.2.x and Tomcat 4.1.x. Part 1 of the tutorial went fine almost to the last step. I downloaded the two Axis2 Eclipse Plug-ins (of interest for this short story is the Axis2 Code Generator Plug-in which I downloaded from here), unzipped them and installed the two unzipped folders in the dropins folder of Eclipse and restarted Eclipse. Generating the service archive into the deployed Axis2 Web Application went smooth. Generating the WSDL from the Java source gave no problems until I got to the point where I clicked the final Finish button to complete the Axis2 Code Generator Plug-in Wizard.

It said:

No further information. No logging. No nothing. Searching the web lead me to this very same tutorial, where, I now found out, were quite a large number of desperate comments on the occurrence of the java.lang.reflect.InvocationtargetException, but no solution. (Later I found this thread of comments, but that was after I investigated the problem myself). What to do? Since the Axis2 Code Generator Plug-in Wizard came with sources included and a .classpath and a .project file I thought it worthwhile to give it a shot and import the whole thing as a Plug-ins and Fragments into my workspace and debug it! Yeah! Let’s go.

Debugging Axis2 Code Generator Wizard Plug-in

With Eclipse started and the Plug-in Development perspective selected choose Import and from the list select Plug-ins and Fragments like below:


Choose Next. The following screen is displayed:


Choose next. Select Axis2_Codegen_Wizard (1.3.0) in the left panel and click Addà to have the plug-in selected for import. (Make sure that you have the target platform pointing to your Eclipse home directory)


Click Finish. Eclipse will now import the plug-in into the workspace. A couple of errors are displayed. I ignored them.J


Before I move on lets switch over to the Debug perspective and add a Java Exception Breakpoint and select java.lang.reflect.InvocationTargetException like shown below.


Switch back to the Plug-in Development perspective and open plugin.xml with the built-in Plug-in Manifest editor. The Overview tab is shown.


Under the Testing heading click the hyperlink “Launch an Eclipse application in Debug mode”. Ignore the Errors in Workspace notification and click Proceed. A new Eclipse Application is launched in which we now will invoke the Axis2 Code Generator Plug-in Wizard by following the tutorial at the point where the WSDL is to be generated from the java class. Upon clicking the Finish button to complete the wizard you will see that the Eclipse Application from which we launched is now halted at the Java Exception Breakpoint for the InvocationTargetException:


As you can see in the screenshot the Variables view now tells us that a RuntimeException has occurred. This is caused by a NoClassDefFoundError for class javax/xml/stream/XMLStreamException. In Firefox I then went to findjar.com and entered “javax/xml/stream/XMLStreamException”. This lead to stax-api-1.0.1.jar. I downloaded this jar file and added it to the \lib directory of the plug-in residing in the dropins directory of your Eclipse installation. As a matter of fact the jar is listed in the plugin.xml, but apparently the plug-in is provided without the actual jar file in it. After adding the jar file restart Eclipse using the –clean option.

Repeating the same procedure as described above I again launched an Eclipse application in debug mode and invoked the Plug-in Wizard once more. Going through the steps of the wizard I finally clicked the Finish button and again the java Exception Breakpoint for the same InvocationTargetException halted as can be seen in the following screenshot:


Again a RuntimeException, but this time caused by the absence of class edu/emory/mathcs/backport/java/util/concurrent/ConcurrentHashMap. Through findjar.com I established that it’s inside backport-util-concurrent-3.1.jar. This I found to be part of the Axis2 1.4.1 distribution and I copied it from there to the \lib directory of the Plug-in. This time also adding an entry to the plugin.xml, just like the other jar files.

Repeating the steps from the tutorial again, this time clicking the Finish button of the Axis2 Code Generator Plug-in Wizard resulted in the desired WSDL file being created. Yippee!

Conclusion

To get myself familiarized with Apache Axis2 in combination with the Eclipse platform I stumbled upon the Axis2 Code Generator Plug-in Wizard crashing in an exception being thrown. I then used Eclipse Plug-in Development to Import the Plug-in code and start debugging it. (A helpful resource in this respect is the cheat sheet on creating an Eclipse Plug-in). This lead to the discovery of two missing jar files in the lib directory of the plug-in folder. After adding these jar files the Axis2 Code generator Plug-in is working fine. So, now it’s time to continue my journey in the land of SOA.


Written by Eric Tamminga

24 October 2008 at 9:33 am

Posted in Eclipse, Java, Jee

Tagged with , ,