Tuesday, February 10, 2015

class not found in wsgen

When I have finished coding on the web service (using document style), I'm ready to generate extra classes with wsgen. Usually the following command will be used for this purpose.

wsgen -keep -cp . org.huahsin.HelloWorld

Anyhow, this command is incomplete because I receive a class not found error immediately as shown below:
C:\workspace\WebService1>wsgen -verbose -cp . org.huahsin.HelloWorld
Class not found: "org.huahsin.HelloWorld"


Usage: WSGEN [options] 

...
...

Referring to the wsgen documentation, it did mention that the -classpath or -cp is referring to an input class file, not the source file. Thus to ensure the command above work correctly, change to the root of the project directory (not bin/ or src/), then fire the command with -cp point to bin/ instead of current directory like this:

wsgen -verbose -cp ./bin org.huahsin.HelloWorld

Besides that, I notice this command doesn't keep the source files after the extra class files being generated. To keep the source files, command below would help:

wsgen -verbose -cp ./bin -s ./src org.huahsin.HelloWorld

No comments: