No source code is available for type java.lang.NoSuchFieldError

644 views
Skip to first unread message

Nathan Klatt

unread,
Jun 20, 2011, 2:59:00 PM6/20/11
to google-we...@googlegroups.com
I've inherited a GWT project and I'm receiving the following compiler error (more info below):
[java] [ERROR] Line 51: No source code is available for type java.lang.NoSuchFieldError; did you forget to inherit a required module?
It's complaining about a core part of the language here, right? Why is it looking for source code for it at all? Is it not finding one of the core jar files? Do I need to point it at something in the ant build.xml file?

For testing purposes, I followed all the GWT instructions, used webAppCreator to generate a "Hello, world." app, and that builds and runs just fine. I added a simple try...catch(NoSuchFieldError err) - and an import java.lang.NoSuchFieldError line - and it gave me the error.

I'm new to this Java/GWT stuff so I suspect I'm missing something obvious - I'd love it if you could point out exactly what! :)

Thanks.

=====

$ ant build
Buildfile: build.xml

libs:

javac:
    [javac] Compiling 1 source file to /home/nklatt/gwt-2.3.0/MyWebApp/war/WEB-INF/classes

gwtc:
     [java] Compiling module com.mycompany.mywebapp.MyWebApp
     [java]    Validating newly compiled units
     [java]       [ERROR] Errors in 'file:/home/nklatt/gwt-2.3.0/MyWebApp/src/com/mycompany/mywebapp/client/MyWebApp.java'
     [java]          [ERROR] Line 51: No source code is available for type java.lang.NoSuchFieldError; did you forget to inherit a required module?
     [java]    Finding entry point classes
     [java]       [ERROR] Unable to find type 'com.mycompany.mywebapp.client.MyWebApp'
     [java]          [ERROR] Hint: Previous compiler errors may have made this type unavailable
     [java]          [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly

BUILD FAILED

Hilco Wijbenga

unread,
Jun 20, 2011, 4:21:22 PM6/20/11
to google-we...@googlegroups.com
On 20 June 2011 11:59, Nathan Klatt <n8k...@gmail.com> wrote:
> I've inherited a GWT project and I'm receiving the following compiler error
> (more info below):
>
> [java] [ERROR] Line 51: No source code is available for type
> java.lang.NoSuchFieldError; did you forget to inherit a required module?
>
> It's complaining about a core part of the language here, right? Why is it
> looking for source code for it at all? Is it not finding one of the core jar
> files? Do I need to point it at something in the ant build.xml file?

GWT doesn't support *everything* available in the Java core libraries.

> For testing purposes, I followed all the GWT instructions, used
> webAppCreator to generate a "Hello, world." app, and that builds and runs
> just fine. I added a simple try...catch(NoSuchFieldError err) - and an
> import java.lang.NoSuchFieldError line - and it gave me the error.
>
> I'm new to this Java/GWT stuff so I suspect I'm missing something obvious -
> I'd love it if you could point out exactly what! :)

Without knowing why you want to catch NoSuchFieldError, I'd say the
"obvious" answer is not to catch NoSuchFieldError. :-) Try it with
e.g. IllegalStateException instead (assuming you just want to test
exception handling).

Paul Robinson

unread,
Jun 21, 2011, 5:04:08 AM6/21/11
to google-we...@googlegroups.com

On 20/06/11 21:21, Hilco Wijbenga wrote:
> On 20 June 2011 11:59, Nathan Klatt<n8k...@gmail.com> wrote:
>> I've inherited a GWT project and I'm receiving the following compiler error
>> (more info below):
>>
>> [java] [ERROR] Line 51: No source code is available for type
>> java.lang.NoSuchFieldError; did you forget to inherit a required module?
>>
>> It's complaining about a core part of the language here, right? Why is it
>> looking for source code for it at all? Is it not finding one of the core jar
>> files? Do I need to point it at something in the ant build.xml file?
> GWT doesn't support *everything* available in the Java core libraries.

See http://code.google.com/webtoolkit/doc/latest/RefJreEmulation.html

Note in particular that reflection is not supported for code translated to javascript (ie everything in the client).

Paul

Ben Munge

unread,
Jun 20, 2011, 4:03:20 PM6/20/11
to Google Web Toolkit
In your GWT console double click the individual errors and you should
get a more detailed stack trace. It likely is something wrong with
your code rather then a missing import/resource. I've gotten a similar
error in the past and it's not overly intuitive.

On Jun 20, 1:59 pm, Nathan Klatt <n8kl...@gmail.com> wrote:
> I've inherited a GWT project and I'm receiving the following compiler error
> (more info below):
>
> [java] [ERROR] Line 51: No source code is available for type
> java.lang.NoSuchFieldError; did you forget to inherit a required module?
>
> It's complaining about a core part of the language here, right? Why is it
> looking for source code for it at all? Is it not finding one of the core jar
> files? Do I need to point it at something in the ant build.xml file?
>
> For testing purposes, I followed all the GWT instructions<http://code.google.com/webtoolkit/gettingstarted.html>,

Nathan Klatt

unread,
Jun 21, 2011, 12:53:51 PM6/21/11
to google-we...@googlegroups.com
Makes perfect sense - thanks so much for the reply and the link!

Nathan Klatt

unread,
Jun 21, 2011, 12:55:39 PM6/21/11
to google-we...@googlegroups.com
Thanks for the idea - right now I'm strictly command-line (on a remote server) but I'll add this to my list of Reasons to Develop on My Local Machine with a GUI. :)
Reply all
Reply to author
Forward
0 new messages