- I have a legacy multi-module GWT project.
- One of the modules contains the DTO and Enum classes.
- One of the DTO classes extends the
org.springframework.security.core.GrantedAuthorityclass, so in the pom.xml it has the maven spring-security-core dependency of org.springframework.security. - When I tried to run the
packagecommand, i got the message:
No source code is available for type org.springframework.security.core.GrantedAuthority; did you forget to inherit a required module?
- I tried to apply solutions that were recommended in some posts that I found with similar messages, I even found one that related the same error, but none of those solutions worked for me.
Could you please help me figure out what is causing this error and how I could fix it?
To reproduce the issue you can follow the steps I did:
I used GWT Archetypes to create a basic project called
GWTRPCModular; and:- JDK 17 (but also I tried it with 8)
- Eclipse 2023-03
- Apache Maven 3.8.6
- GWT 2.10.0
The project was generated with 3 modules:
GWTRPCModular-client,GWTRPCModular-serverandGWTRPCModular-shared.I added a module called
GWTRPCModular-modelfor the DTOs (similar to my legacy project) and in the pom.xml I added the necessary dependencies.I included the
<source path="model" />to the *.gwt.xml file.I created the
UserSessionDTOclass
import java.util.Collection;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
public class UserSessionDTO extends User {
private static final long serialVersionUID = -6391317902265663080L;
public UserSessionDTO(String username, String password, Collection<? extends GrantedAuthority> authorities) {
super(username, password, authorities);
// TODO Auto-generated constructor stub
}
}
- I ran the
mvn clean install - Finally I ran the
mvn packageand the message appeared:
...
[INFO] --- gwt-maven-plugin:1.0.1:compile (default-compile) GWTRPCModular-client ---
[INFO] Compiling module com.foo.gwtmodular.App
[INFO] Tracing compile failure path for type 'com.foo.gwtmodular.model.dto.UserSessionDTO'
[INFO] [ERROR] Errors in 'com/foo/gwtmodular/model/dto/UserSessionDTO.java'
[INFO] [ERROR] Line 8: No source code is available for type org.springframework.security.core.userdetails.User; did you forget to inherit a required module?
[INFO] [ERROR] Line 12: No source code is available for type org.springframework.security.core.GrantedAuthority; did you forget to inherit a required module?
...
If you need anything else to review this case, please let me know.
I thank you in advance for any help you can provide!
In your GWT (*.gwt.xml) module file, you need an
<inherits>tag for this spring dependency also.This spring library probably does not come with its own GWT module file though, so you will need to create your own. In your client project you could create a package such as
org.springframework.security, create a GWT module file for the spring library and put it in the package. Then you can inherit it in your main GWT module fileRefer to this question/answer: https://stackoverflow.com/a/70538165/1920835