Wednesday, October 6, 2010

Creating Glassfish webservices using Andromda.

As part of our ongoing development I needed to add webservice support to our application.  During my initial Andromda setup I had indicated that we would not be using webservices so the build was not set up to support this... so I knew this would likely require a configuration change.

Since most of the configurations are done via the andromda.xml file located under the MDA/src/main/config folder of the project, this was the first place I looked.

Sure enough, I found a setting called: webServiceEnabled which was set to false.  I switched this to true.

Then I opened my uml model and proceeded annotate one of my Service methods with the stereotype of 'WebServiceOperation' ...exported model and saved it, recompiled...

And was getting an annoying class not found error.  After investigating the ServiceWSInterface.java file I found an annotation which looked like this:
@org.jboss.ws.annotation.PortComponent(contextRoot = ...

Since everything else in the file looked good, and since I was not using JBoss for my persistence, I should be able to just remove the offending line from the andromda template as a worse case scenario.

I cracked open the andromda cartridge template WebServiceInterface.vsl and found the line that was inserting the offending piece of code.  I noticed around that block of code was an if statement saying to add that line only if the persistenceContainerName = jboss.

After further inspection of the andromda.xml config file, I found the following property:


property name="persistenceContainerName" which was set to jboss... changed that to glassfish, recompiled and everything seems to be working properly now.

Hope this helps someone else out there.