views:

230

answers:

2

I am working on eclipse plugin which will have a wizard. This wizard will be available form example from context menu while mouse right click on Java editor.

The wizard will be responsible for collecting such information as:

  • location of WSDL file
  • Package name

When the wizard finishes, I would like to have stub of a webservice described in WSDL generated into package provided earlier.

THE QUESTION IS: How can I generate webservice stub dymanically and from source code (not from command line) and add it to the current project?

Until now, I came across WSDL2Java (Axis), Apache CXF and wsimport. I try to use Apache CXF and wsimport but I'm always getting ClassNotFoundException even though all jars are included into buildpath. I think I might have used them incorrectly.

Please help me folks! Time for that task is running out :-(

Little example:

Let's say the code is (Apache CXF):

String[] args = {"-client", "-d", "D:\\test", "D:\test.wsdl" };
WSDLToJava w = new WSDLToJava(args);
ToolContext t = new ToolContext();
w.run(t);

The first few lines of exception are:

java.lang.NoClassDefFoundError: org/apache/cxf/tools/wsdlto/WSDLToJava
    at plugin.wsreplication.ui.wizard.component.AddComponentWizard.performFinish(AddComponentWizard.java:160)
    at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:752)
    at plugin.wsreplication.ui.wizard.component.AddComponentWizardDialog.finishPressed(AddComponentWizardDialog.java:39)
    at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:373)
    at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3910)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3503)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
    at org.eclipse.jface.window.Window.open(Window.java:801)
    at plugin.wsreplication.ui.action.AddComponentAction.run(AddComponentAction.java:35)
    at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
A: 

Sounds to me like cxf-tools is not on your Classpath.

I'm not sure how it works with Eclipse plugins and OSGi, and exactly how to specify a classpath for your plugin, but you need to be able to specify where the CXF JARs are on the classpath.

matt b
I think that the problem could be in a classpath during runtime. While developing plugin, I set up all environment and it works. When I install plugin in Eclipse (different one, let's say with default settings) cxf is not present. Is it possible? Should I add some dependencies to the plugin?
MarcinK
Got it done. Tools were on developing environment's classpath whereas at runtime the package were not included. The solution was to add tools to runtime environment's classpath
MarcinK
A: 

It seems like you have done an error while setting up an environment for the plugin. Check this list for details. If the error will not disappear, try to figure out an actual class path with System.getProperty("java.class.path"). If jar is really on a classpath, the problem may be in an Eclipse itself.

Andrei