Error injecting constructor with Unrecognized Type: [null] #43
Comments
I have the same issue and after some debugging it seems to be caused by the fact that PlayReader tries to compare Parameter.typeName (including package) with Class.simpleName (just the class name) |
Can you please share some models / case classes that are giving you trouble? |
I have similar problem:
Code that causes this issue:
You should notice that So far I have tracked that code in swagger-core io.swagger.jackson.ModelResolver returns null here:
which later causes error when bootstrapping Guice module. I attached Play project that reproduces this issue |
@fehguy I added a sample project that makes it easy to reproduce the issue https://github.com/rafax/play-swagger-repro The error seems to be related to my use of custom QueryStringBindable. |
I have the same problem, any solutions ? |
I am getting the exact same error. None of my models are documented / annotated yet but I'm curious what others find as the problem here. |
My issue was fixed in version 1.5.1, thanks! |
I'm still seeing the same issue after upgrading to swagger-1.5.1 (with Unfortunatly the stacktrace does not reveal any hints on where to look in
On Fri, Jan 15, 2016 at 10:48 AM, Rafał Gajdulewicz <
|
This error occurs to me with a parameter of |
I had to restructure my routes to remove the Option type. That would be nice to support but getting swagger working was more important than supporting Option for me. 1.5.1 fixed a couple of other issues too - thanks everyone!
|
I am getting same error in version 1.5.1. |
I can confirm this as well. This route works: This does not: However, the second is what I want. You also don't even need to annotate the method to get this error. Simply annotating the controller with @Api and having any route in the controller with an option without a fixed value is enough to cause this error. |
This is a tough one. I think we need some help from the community on this issue. |
EDIT: Never mind my issue, it was induced by swagger but is not related, I had a flag that was being initialized in the globalsettings section that starts my bindings which relied on play to be running by then and was thus failing, after eliminating that it was smooth sailing. OP: Seems like I'm in the same boat, using v1.5.1 this is my stack trace:
I've only used swagger on a single location:
|
Can we get a release on swagger-play2? Thanks. |
I just test with swagger-play2 1.5.1 and run into the same issue using libraryDependencies (as found in #57):
Probably the "?=" syntax in conf/routes is the culprit Should this case work already? On Tue, Feb 16, 2016 at 4:20 PM, osbornk notifications@github.com wrote:
|
@lammel tested with your use case, and it should work ok. Possibly you are pointing to older version, please either build yourself or wait for version to be published |
@frantuma: What should I build actually (master of swagger-play2, swagger-module-scala, ...) or which snapshots should I use? I'd just like to help ensure, that the fix is working and my actual usecase has no other issues lurking around. |
@lammel you should build master of swagger-play2 adding sonatype snapshots repo to resolvers in build.sbt (scala-module 1.0.2-SNAPSHOT and swagger-core 1.5.8-SNAPSHOT published there) |
@frantuma I still have this error running play 2.4 for Java and swagger-play2 1.5.1 This is my route file: Another strange thing is if I change the controllers.ApiController.status to controllers.ApiController.report then it will work. (I have both status and report method implemented in ApiController) |
@trunght I am not sure I get it fully: you mean you have 2 methods status and report with same parameter and only method name changes, and with one it works, and the other not? can you share the controller methods signatures? |
@frantuma: these are my methods: FYI, I coded this ApiController with around 10 methods, today I installed swagger and ran into this bug. So I tried to delete all the routes => run successfully /swagger.json Thanks a lot for your help. |
@trunght I cannot reproduce NPE for your case, but there's indeed a related bug, happening when naming a method "status" (or some other names possibly) in a java controller; We'll have that fixed possibly in next release, as workaround please either rename the method or implement it in scala. Please see also #43 (comment) to be sure you are using latest version |
Thanks @frantuma changed the name of the method and it works. |
i had to remove the Option(al) parameter in my route to make it work. So, this does not work: and this does work: |
Anyone figure out how to get |
I see that there's a test (CatController, line 66) attempting to exercise this case. I attempted to replicate it. The test code doesn't go through a
I get an exception even if I define my endpoint with:
Further, if I define |
Get the latest swagger-play2 1.5.2. Works great for me now. |
@osbornk 👍 You made my day! |
@osbornk Awesome, ran into same problem and found this, works perfectly now! |
CreationException: Unable to create injector, see the following errors:
The stacktrace leads to an error in the resolveProperty method in the SwaggerScalaModelConverter.scala:32. Causing constructType to fail in
So it seems that resolveProperty is the culprit of the issue otherwise (if I misinterpret the stacktrace) a generic error with dependency injection might be also a candidate.
In SwaggerPlugin.scala:33 the dependency injection is done:
With that very generic failure any help would be greatly appreciated.
The text was updated successfully, but these errors were encountered: