Skip to main content

WSGEN fails with spurious NoClassDefFoundError/ClassNotFoundException

4 replies [Last post]
Joined: 2007-07-03

I'm getting a somewhat puzzling ClassNotFoundException; I've confirmed that the class exists; in fact, it's in the same folder as the service endpoint interface and if I remove the classpath entry that they share, it gives a class not found exception for that interface (BooksService).

Here's the output from wsgen including a stack trace:

Note: ap round: 1
[ProcessedMethods Interface: books.service.BooksService]
... a bunch of verbose output ...
Note: ap round: 2
Exception in thread "main" java.lang.NoClassDefFoundError: Lbooks/service/AuthToken;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(
at java.lang.Class.getDeclaredFields(
Caused by: java.lang.ClassNotFoundException: books.service.AuthToken
at Method)

Here's the class files happily side by side:

29/09/2008 07:42 PM 4,184 AuthToken.class
29/09/2008 07:42 PM 15,984 BooksService.class

The supposedly missing class itself is pretty straightforward, too:

package books.service;

import java.util.Date;

public class AuthToken implements Serializable, Comparable {
private static final long serialVersionUID = -8284570128013183692L;

Long myUserId;
Date expiryDate;
String restriction;
String site;
String locale;
String authenticationCode;

public AuthToken() {

public AuthToken(Long myUserId, Date expiryDate, String restriction,
String authenticationCode, String site, String locale) {
this.myUserId = myUserId;
this.expiryDate = expiryDate;
this.restriction = restriction;
this.authenticationCode = authenticationCode; = site;
this.locale = locale;

/* ... standard getters, setters, hashCode, and equals follow ... */

Has anyone run into this kind of oddness with the wsgen classpath before?

Any ideas on how I could debug this further?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-07-03

Figured out a workaround on my own.

Joined: 2008-11-03

My workaround on this was a bit different. I tried adding the location of the class to the wsgen classpath (in the script and in the -cp parameters passed) as suggested by dobes but that didn't work for me. Turns out (at least in my case) that what I needed to do was run wsgen from within the directory where my package started. Nothing else worked for me.

Thank you for the reply dobes!

Joined: 2008-11-03

I am having the exact same problem. If anyone has any suggestions they would be greatly appreciated.

Thank you,

Joined: 2007-07-03

I figured this one out - there's a bug somewhere in WSGEN which means that passing the classpath as a parameter isn't good enough; you actually have to have the classes on WSGEN's classpath.

The workaround is to look inside the wsgen.bat file and run it yourself with a classpath including the class you are looking for.

For example, I created a run profile in eclipse to run wsgen using my project's classpath and passing in the same parameters as the batch file would.