GWT compiler keeps complaining about missing source files

230 views
Skip to first unread message

mmo

unread,
Jul 26, 2022, 4:21:05 AM7/26/22
to GWT Users
In the code that I inherited my predecessors had decided to use a couple of Spring classes even in GWT client code.
While I am not exactly enthused by this decision the referenced classes are - at least from my point of view - OK to use in GWT client code, since they are mostly interfaces or simple classes that don't pull too much of "Spring" into the client. So my aim is to leave the code as such unchanged as much as possible (trying to follow the "never change running code"-principle...).

What I don't like, however, is that so far they had simply ignored the resulting GWT compile errors. I am thus now trying to correct the GWT settings such that this at least compiles without errors (i.e. that I can use the "strict" compiler setting).

The initial error was that the Spring sources for GrantedAuthority, CredentialsContainer and a few more classes could not be found during GWT compilation.
When I then added the Spring sources jar to the dependencies the GWT compiler ran havock and apparently tried to compile the ENTIRE Spring library. That was definitely NOT what I wanted.
Next I tried to provide ONLY (copies of) those sources that are actually referenced in our GWT code, i.e. I added copies of those spring source files to our resources folder and try to direct the GWT compiler to use only those. Besides the mentioned java files I thus also added a GwtSpring.gwt.xml file which I reference from our application's ZHStRegisterJPWeb.gwt.xml like so:


* <project_root>
|
+-* src
| +-* main
| | +-* java
| | | +-* ch
| | | | +-* zh
| | | | | +-* registerjp
| | | | | | +-* client
| | | | | | | +-- ...
| | | | | | +-* shared
| | | | | | | +-* security
| | | | | | | | +-- ZHStRegisterJPUser.java
| | | | | | | | +-- ...
| | | | | | | +-- ...
| | | | | | +-* server
| | | | | | | +-- ...
| | |
| | +-* resource
| | | +-* ch
| | | | +-* zh
| | | | | +-* registerjp
| | | | | | +-- ZHStRegisterJPWeb.gwt.xml   << our application's gwt-file
| | | | | ...
| | | |
| | | +-* org
| | | | +-* springframework
| | | | | +-- GwtSpring.gwt.xml   << the added Spring gwt-file
| | | | | +-* security   << copies of the referenced Spring source files below this folder
| | | | | | +-* core
| | | | | | | +-- GrantedAuthority.java
| | | | | | | +-- CredentialsContainer.java
| | | | | | | +-- ...
| | | | | | | +-* userdetails
| | | | | | | | +-- User.java
| | | | | | | | +-- UserDetails.java
| | | ...


[Note: '*' are directories]


The ZHStRegisterJPWeb.gwt.xml reads:
---
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='ZHStRegisterJPWeb'>
    <!-- Inherit the core Web Toolkit stuff. -->
    <inherits name='com.google.gwt.user.User' />

    <!-- used in ZHStRegisterJPUser and ZHStRegisterJPAuthority: -->
    <inherits name="org.springframework.GwtSpring" />
   
    ... further details omitted here ...

---


The GwtSpring.gwt.xml reads:
---
<?xml version="1.0" encoding="UTF-8"?>
<module>
    <source path="security.core">
        <include name="GrantedAuthority.java" />
        <include name="CredentialsContainer.java" />
    </source>
    <source path="security.core.userdetails">
        <include name="User.java" />
        <include name="UserDetails.java" />
    </source>
   
    ... further details omitted here ...
</module>

---

However, the GWT compiler STILL complains that it can not locate the sources of GrantedAuthority and other Spring classes:
...
[INFO]    Tracing compile failure path for type 'ch.zh.ksta.zhstregisterjp.shared.security.ZHStRegisterJPUser'
[INFO]       [ERROR] Errors in 'ch/zh/ksta/zhstregisterjp/shared/security/ZHStRegisterJPUser.java'
[INFO]          [ERROR] Line 40: No source code is available for type org.springframework.security.core.userdetails.User; did you forget to inherit a required module?
[INFO]          [ERROR] Line 94: No source code is available for type org.springframework.security.core.GrantedAuthority; did you forget to inherit a required module?
...


Any idea why it doesn't find these files even though I now provide them explicitly?  What am I missing here? 

Peter Donald

unread,
Jul 26, 2022, 5:42:56 AM7/26/22
to GWT Mailing List
It looks like you put the source in the resources tree rather than in the source tree. If you fix that then it may help

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/cffab879-e6ac-4aac-9fe1-cabcaac72d0an%40googlegroups.com.


--
Cheers,

Peter Donald

mmo

unread,
Jul 26, 2022, 8:26:17 AM7/26/22
to GWT Users
Originally I had indeed placed all the code (also the "drop-ins" for Spring) under src/main/java but I then got the very same errors as described in my previous email.
And also now, after I have moved them back into the java sub-tree I keep getting the same error. So, there must be something else still wrong here... ?!?

I provide an updated view of how my java source and resource tree currently looks like.


* <project_root>
|
+-* src
| +-* main
| | +-* java
| | | +-* ch
| | | | +-* zh
| | | | | +-* registerjp
| | | | | | +-* client
| | | | | | | +-- ...
| | | | | | +-* shared
| | | | | | | +-* security
| | | | | | | | +-- ZHStRegisterJPUser.java
| | | | | | | | +-- ...
| | | | | | | +-- ...
| | | | | | +-* server
| | | | | | | +-- ...
| | | +-* org    << copies of the referenced Spring source files below this folder
| | | | +-* springframework
| | | | | +-* security

| | | | | | +-* core
| | | | | | | +-- GrantedAuthority.java
| | | | | | | +-- CredentialsContainer.java
| | | | | | | +-- ...
| | | | | | | +-* userdetails
| | | | | | | | +-- User.java
| | | | | | | | +-- UserDetails.java
| | ...
| | +-* resource
| | | +-* ch
| | | | +-* zh
| | | | | +-* registerjp
| | | | | | +-- ZHStRegisterJPWeb.gwt.xml   << our application's gwt-file
| | | | | ...
| | | |
| | | +-* org
| | | | +-* springframework
| | | | | +-- GwtSpring.gwt.xml   << the added Spring gwt-file
| | | ...

[Note: '*' are directories]

Thomas Broyer

unread,
Jul 26, 2022, 8:40:37 AM7/26/22
to GWT Users
You may want to try out using super-source instead.
Move your org/springframework into ch/zh/registerjp/super/ and add <super-source path="super"/> in ZHStRegisterJPWeb.gwt.xml (and remove the GwtSpring.gwt.xml and the related <inherits/>)

* <project_root>
|
+-* src
| +-* main
| | +-* java
| | | +-* ch
| | | | +-* zh
| | | | | +-* registerjp
| | | | | | +-* client
| | | | | | | +-- ...
| | | | | | +-* shared
| | | | | | | +-* security
| | | | | | | | +-- ZHStRegisterJPUser.java
| | | | | | | | +-- ...
| | | | | | | +-- ...
| | | | | | +-* server
| | | | | | | +-- ...
| | ...
| | +-* resource
| | | +-* ch
| | | | +-* zh
| | | | | +-* registerjp
| | | | | | +-- ZHStRegisterJPWeb.gwt.xml   << our application's gwt-file
| | | | | +-* super

| | | | | | +-* org    << copies of the referenced Spring source files below this folder
| | | | | | | +-* springframework
| | | | | | | | +-* security
| | | | | | | | | +-* core
| | | | | | | | | | +-- GrantedAuthority.java
| | | | | | | | | | +-- CredentialsContainer.java
| | | | | | | | | | +-- ...
| | | | | | | | | | +-* userdetails
| | | | | | | | | | | +-- User.java
| | | | | | | | | | | +-- UserDetails.java
[Note: '*' are directories]

Jens

unread,
Jul 26, 2022, 9:22:02 AM7/26/22
to GWT Users
The GwtSpring.gwt.xml reads:
---
<?xml version="1.0" encoding="UTF-8"?>
<module>
    <source path="security.core">
        <include name="GrantedAuthority.java" />
        <include name="CredentialsContainer.java" />
    </source>
    <source path="security.core.userdetails">
        <include name="User.java" />
        <include name="UserDetails.java" />
    </source>
   
    ... further details omitted here ...
</module>


Use slash instead of dots in path="security.core" and path="security.core.userdetails"

-- J.

mmo

unread,
Jul 26, 2022, 12:29:31 PM7/26/22
to GWT Users
@Jens: Thanks such a lot for spotting this! I am such an idiot!
 
@t.br...@gmail.com: Thanks for the advice as well. I indeed went that route after having first fixed my paths (above) but which then caused compile errors in the server side code (because my dropped-in classes conflicted with the original ones causing compile errors for the server side code).

Thanks again both! I really appreciate your support!

Reply all
Reply to author
Forward
0 new messages