Wednesday, May 14, 2008

Running wsgen easily from within JDeveloper

It occured to me that in my previous post if you are deploying to a jax-ws platform that is pre 2.1.4, and need to run wsgen, you might like an easier way of doing it that doesn't require you to shell out to ant. (For example JAX-WS deployed to BEA WLS 10.2 and 10.3 tech preview or deployed to earlier builds of glassfish)

The easiest way to do this is to go to Tools->External Tools and create a new tool entry. On the first page of the wizard enter the path to wsgen(.sh|.bat)? on your platform, this is in the "bin" directory under JDK 6. Run directory isn't important; but in the arguments box put the following code:

-d ${project.outputdirectory} -s ${project.first.sourcepath} -keep -cp ${project.outputdirectory} ${target.class}

On the next page I will leave it up to you to put the right entries in for display as this is down to personal preference. On the integration page you probably want:

  • Only add to "Navigator Context Menu"
  • Before tool starts "Save All"
  • After tool exits "Reload Open Files"
  • Log output to message console

On the avaliability page make sure you only enable this for "Java Source" file types. It is probably not a good idea to allow this on other types. And thats it, you can now right click on a java web service and generate the extra boiler plate classes when you start fom the java class and work your way up. (Also known as bottom up)

You might have to refresh the navigator to see new files when they are generated, I am going to raise a bug for this and try to see if we can get JDeveloper to do this for you.

Update 9th June 2009

I noticed a slight bug in the above command line as it is missing the project classpath, this can cause the task to fail if you are using EJB for example. (Make sure you swap the ; for a : if you are on unix/mac.

-d ${project.outputdirectory} -s ${project.first.sourcepath} -keep -cp ${project.outputdirectory};${project.classpath ${target.class}

No comments: