users@glassfish.java.net

WSGEN fails with spurious NoClassDefFoundError/ClassNotFoundException

From: <glassfish_at_javadesktop.org>
Date: Mon, 29 Sep 2008 20:13:44 PDT

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(Class.java:2291)
        at java.lang.Class.getDeclaredFields(Class.java:1743)
...
Caused by: java.lang.ClassNotFoundException: books.service.AuthToken
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native 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.io.Serializable;
import java.util.Date;

public class AuthToken implements Serializable, Comparable<AuthToken> {
        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) {
                super();
                this.myUserId = myUserId;
                this.expiryDate = expiryDate;
                this.restriction = restriction;
                this.authenticationCode = authenticationCode;
                this.site = 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?
[Message sent by forum member 'dobes' (dobes)]

http://forums.java.net/jive/thread.jspa?messageID=302470