Oscar Londoño
Oscar Londoño

Reputation: 75

No source code is available for type org.springframework.security.core.GrantedAuthority

No source code is available for type org.springframework.security.core.GrantedAuthority; did you forget to inherit a required module?

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:

  1. 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
  2. The project was generated with 3 modules: GWTRPCModular-client, GWTRPCModular-server and GWTRPCModular-shared.

  3. I added a module called GWTRPCModular-model for the DTOs (similar to my legacy project) and in the pom.xml I added the necessary dependencies.

  4. I included the <source path="model" /> to the *.gwt.xml file.

  5. I created the UserSessionDTO class

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
    }
}
  1. I ran the mvn clean install
  2. Finally I ran the mvn package and 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!

Upvotes: 2

Views: 204

Answers (1)

Robert Newton
Robert Newton

Reputation: 1611

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 file

Refer to this question/answer: https://stackoverflow.com/a/70538165/1920835

Upvotes: 0

Related Questions