Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown type: null. #33

Open
abcfy2 opened this issue Mar 19, 2019 · 1 comment
Open

Unknown type: null. #33

abcfy2 opened this issue Mar 19, 2019 · 1 comment

Comments

@abcfy2
Copy link

abcfy2 commented Mar 19, 2019

Here is my log:

2019-03-19 19:04:50.013  INFO pertySourcedRequestMappingHandlerMapping : Mapped URL path [/v2/api-docs] onto method [public org.springframework.http.ResponseEntity<springfox.documentation.spring.web.json.Json> springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)]
2019-03-19 19:04:56.821  INFO d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2019-03-19 19:04:56.925  INFO d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2019-03-19 19:04:57.146  WARN o.grails.core.DefaultGrailsDomainClass   : The GrailsDomainClass API should no longer be used to retrieve data about domain classes. Use the mapping context API instead
2019-03-19 19:04:59.889  WARN o.grails.core.DefaultGrailsDomainClass   : The GrailsDomainClass API should no longer be used to retrieve data about domain classes. Use the mapping context API instead
2019-03-19 19:04:59.906  WARN o.grails.core.DefaultGrailsDomainClass   : The GrailsDomainClass API should no longer be used to retrieve data about domain classes. Use the mapping context API instead
2019-03-19 19:04:59.946  WARN o.grails.core.DefaultGrailsDomainClass   : The GrailsDomainClass API should no longer be used to retrieve data about domain classes. Use the mapping context API instead
2019-03-19 19:04:59.983 ERROR o.s.boot.SpringApplication               : Application startup failed

java.lang.IllegalArgumentException: Unknown type: null
        at net.bytebuddy.description.type.TypeDefinition$Sort.describe(TypeDefinition.java:213)
        at net.bytebuddy.description.type.TypeDefinition$Sort.describe(TypeDefinition.java:190)
        at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.defineField(DynamicType.java:2487)
        at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.defineField(DynamicType.java:2482)
        at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.defineField(DynamicType.java:2477)
        at springfox.documentation.builders.AlternateTypePropertyBuilder.apply(AlternateTypePropertyBuilder.java:69)
        at springfox.documentation.builders.AlternateTypeBuilder.build(AlternateTypeBuilder.java:64)
        at springfox.documentation.grails.GrailsSerializationTypeGenerator.from(GrailsSerializationTypeGenerator.java:39)
        at springfox.documentation.grails.DefaultGrailsAlternateTypeRuleConvention.lambda$rules$0(DefaultGrailsAlternateTypeRuleConvention.java:42)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
        at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
        at springfox.documentation.grails.DefaultGrailsAlternateTypeRuleConvention.rules(DefaultGrailsAlternateTypeRuleConvention.java:43)
        at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper$1.apply(DocumentationPluginsBootstrapper.java:125)
        at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper$1.apply(DocumentationPluginsBootstrapper.java:122)

Here is my Grails application project: https://github.com/dteam-top/grails-rest-seed

And I find the reason is that some fields cannot use property.getReferencedPropertyType();(Here will get null:

)

Here will trigger this error: https://github.com/DTeam-Top/grails-rest-seed/blob/1a5eeee346dd14b81fa54b2ba9a25d9a3156e169/grails-app/domain/top/dteam/earth/backend/user/User.groovy#L24

And this line: https://github.com/DTeam-Top/grails-rest-seed/blob/1a5eeee346dd14b81fa54b2ba9a25d9a3156e169/grails-app/domain/top/dteam/earth/backend/user/User.groovy#L54

I comment out these lines and works very well.

One is

    Set<Role> getAuthorities() {
        (UserRole.findAllByUser(this) as List<UserRole>)*.role as Set<Role>
    }

Another is

    static transients = ['accountExpired', 'accountLocked']
@igoraguiar
Copy link

Hi.
The only way I could work around this issue was to declare a new GrailsPropertySelector bean in the Application class inside the init directory.
This way you can ignore properties which are causing problems. I know this is not a real solution, just a workaround. But this way you can get the application running, at least.

This is how my bean declaration looks like:

    @Bean
    GrailsPropertySelector propertySelector() {
        return new DefaultGrailsPropertySelector() {
            @Override
            boolean test(GrailsDomainClassProperty each) {
                boolean b = super.test(each) &&
                        !(each.referencedPropertyType == null && each.name == 'instituicaoId') &&
                        (each.isPersistent() || each.getName().endsWith("Id")) &&
                        !(Geometry.isAssignableFrom(each.type))
                return b
            }
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants