Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

ClassCastException with recent changes #269

Closed
kumaranae opened this issue Jun 1, 2017 · 6 comments
Closed

ClassCastException with recent changes #269

kumaranae opened this issue Jun 1, 2017 · 6 comments
Assignees

Comments

@kumaranae
Copy link

Hi Team,

I have patched the changes did for the issue "RuntimeException with Unknown type #256"

Then am getting the below exception,

Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
at org.raml.emitter.IndentedAppendableEmitter.pickTypeHandler(IndentedAppendableEmitter.java:243)
at org.raml.emitter.IndentedAppendableEmitter.writeQueryParameters(IndentedAppendableEmitter.java:297)
at org.raml.emitter.IndentedAppendableEmitter.writeMethod(IndentedAppendableEmitter.java:195)
at org.raml.emitter.IndentedAppendableEmitter.writeResource(IndentedAppendableEmitter.java:118)
at org.raml.emitter.IndentedAppendableEmitter.writeResource(IndentedAppendableEmitter.java:122)
at org.raml.emitter.IndentedAppendableEmitter.writeApi(IndentedAppendableEmitter.java:86)
at org.raml.emitter.IndentedAppendableEmitter.emit(IndentedAppendableEmitter.java:71)

@jpbelang
Copy link
Contributor

jpbelang commented Jun 1, 2017

I know what this is, it think:

It's related to #247. To pick up the annotation from a type, it needs to be a Class. We just need an instanceof test. This was done for one case here:

jaxrs-to-raml/jaxrs-parser/src/main/java/org/raml/jaxrs/parser/model/JerseyJaxRsEntity.java

You could emergency fix it the same way. I'll fix this tonight.

@kumaranae
Copy link
Author

I tried but still hitting the same issue. Can you please fix it tonight and share the fix.

Thanks for your quick response and fixes. I really appreciate it.

@jpbelang
Copy link
Contributor

jpbelang commented Jun 1, 2017

I've pushed a quick fix. If this works for you, I'll make a general fix.

It's on branch 2.0.1, don't forget.

@kumaranae
Copy link
Author

Now it throws on the below,

Number of foreign imports: 1
import: Entry[import from realm ClassRealm[maven.api, parent: null]]


    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:196)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 20 more

Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
at org.raml.emitter.plugins.DefaultTypeHandler.writeType(DefaultTypeHandler.java:43)
at org.raml.jaxrs.emitters.ParameterEmitter.emit(ParameterEmitter.java:52)
at org.raml.emitter.IndentedAppendableEmitter.writeQueryParameters(IndentedAppendableEmitter.java:311)
at org.raml.emitter.IndentedAppendableEmitter.writeMethod(IndentedAppendableEmitter.java:197)
at org.raml.emitter.IndentedAppendableEmitter.writeResource(IndentedAppendableEmitter.java:120)
at org.raml.emitter.IndentedAppendableEmitter.writeResource(IndentedAppendableEmitter.java:124)
at org.raml.emitter.IndentedAppendableEmitter.writeApi(IndentedAppendableEmitter.java:88)
at org.raml.emitter.IndentedAppendableEmitter.emit(IndentedAppendableEmitter.java:73)
at org.raml.emitter.FileEmitter.emit(FileEmitter.java:59)
at org.raml.jaxrs.raml.core.OneStopShop.parseJaxRsAndOutputRaml(OneStopShop.java:81)
at org.raml.jaxrs.plugin.JaxRsToRamlMojo.confinedExecute(JaxRsToRamlMojo.java:120)
at org.raml.jaxrs.plugin.JaxRsToRamlMojo.execute(JaxRsToRamlMojo.java:77)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 21 more

@jpbelang
Copy link
Contributor

jpbelang commented Jun 1, 2017

Ok: I went all over the code to cast stuff through a function.
ParameterizedType -> Raw Type
TypeVariable -> Exception.

If I missed one, you'll be the first to know.

@kumaranae
Copy link
Author

It worked like a charm... thanks a ton. I really appreciate it.

@jpbelang jpbelang self-assigned this Jun 6, 2017
@jstoiko jstoiko closed this as completed Jul 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants