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

[policy] [cache] Required type parameter does not match the resource type #962

Closed
David-V2 opened this Issue Dec 26, 2017 · 4 comments

Comments

Projects
None yet
5 participants
@David-V2
Copy link

David-V2 commented Dec 26, 2017

When I set the cache policy like this :

{
  "id" : "[MY ID]",
  "name" : "[MY NAME]",
  ... ,
  "paths" : {
    ... ,
    "/config" : [ 
    ... , 
    {
      "methods" : [ "HEAD", "GET", "OPTIONS", "CONNECT", "POST", "PUT", "DELETE", "PATCH", "TRACE" ],
      "cache" : {"timeToLiveSeconds":86400,"useResponseCacheHeaders":false,"scope":"APPLICATION","cacheName":"mob144010","key":""},
      "description" : "Description of the Cache Gravitee Policy",
      "enabled" : true
    } ],
    ... 
  },
  ... ,
  "resources" : [ {
    "name" : "mob144010",
    "type" : "cache",
    "enabled" : true,
    "configuration" : {"name":"mob-144010","timeToIdleSeconds":0,"timeToLiveSeconds":86400,"maxEntriesLocalHeap":10}
  },
  ... 
 ]
}

And tried to call the API, I get this stacktrace :

io.gravitee.gateway.policy.PolicyChainException: io.gravitee.gateway.policy.PolicyException: java.lang.reflect.InvocationTargetException
	at io.gravitee.gateway.policy.impl.RequestPolicyChain.execute(RequestPolicyChain.java:46)
	at io.gravitee.gateway.policy.impl.PolicyChain.doNext(PolicyChain.java:66)
	at io.gravitee.gateway.policy.impl.StreamablePolicyChain.doNext(StreamablePolicyChain.java:51)
	at io.gravitee.policy.transformheaders.TransformHeadersPolicy.onRequest(TransformHeadersPolicy.java:51)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at io.gravitee.gateway.policy.impl.PolicyImpl.invoke(PolicyImpl.java:89)
	at io.gravitee.gateway.policy.impl.PolicyImpl.onRequest(PolicyImpl.java:44)
	at io.gravitee.gateway.policy.impl.RequestPolicyChain.execute(RequestPolicyChain.java:44)
	at io.gravitee.gateway.policy.impl.PolicyChain.doNext(PolicyChain.java:66)
	at io.gravitee.gateway.policy.impl.StreamablePolicyChain.doNext(StreamablePolicyChain.java:51)
	at io.gravitee.gateway.policy.impl.RequestPolicyChainProcessor.execute(RequestPolicyChainProcessor.java:63)
	at io.gravitee.gateway.policy.impl.RequestPolicyChainProcessor.lambda$execute$0(RequestPolicyChainProcessor.java:57)
	at io.gravitee.gateway.policy.NoOpPolicyChain.doNext(NoOpPolicyChain.java:41)
	at io.gravitee.gateway.policy.impl.RequestPolicyChainProcessor.execute(RequestPolicyChainProcessor.java:63)
	at io.gravitee.gateway.policy.impl.RequestPolicyChainProcessor.lambda$execute$0(RequestPolicyChainProcessor.java:57)
	at io.gravitee.gateway.policy.impl.PolicyChain.doNext(PolicyChain.java:76)
	at io.gravitee.gateway.policy.impl.StreamablePolicyChain.doNext(StreamablePolicyChain.java:51)
	at io.gravitee.policy.apikey.ApiKeyPolicy.onRequest(ApiKeyPolicy.java:94)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at io.gravitee.gateway.policy.impl.PolicyImpl.invoke(PolicyImpl.java:89)
	at io.gravitee.gateway.policy.impl.PolicyImpl.onRequest(PolicyImpl.java:44)
	at io.gravitee.gateway.policy.impl.RequestPolicyChain.execute(RequestPolicyChain.java:44)
	at io.gravitee.gateway.policy.impl.PolicyChain.doNext(PolicyChain.java:66)
	at io.gravitee.gateway.policy.impl.StreamablePolicyChain.doNext(StreamablePolicyChain.java:51)
	at io.gravitee.gateway.policy.impl.RequestPolicyChainProcessor.execute(RequestPolicyChainProcessor.java:63)
	at io.gravitee.gateway.handlers.api.ApiReactorHandler.handleClientRequest(ApiReactorHandler.java:178)
	at io.gravitee.gateway.handlers.api.ApiReactorHandler.doHandle(ApiReactorHandler.java:122)
	at io.gravitee.gateway.reactor.handler.AbstractReactorHandler.handle(AbstractReactorHandler.java:87)
	at io.gravitee.gateway.reactor.impl.DefaultReactor.lambda$route$0(DefaultReactor.java:87)
	at io.gravitee.gateway.reactor.handler.transaction.TransactionHandler.handle(TransactionHandler.java:58)
	at io.gravitee.gateway.reactor.handler.transaction.TransactionHandler.handle(TransactionHandler.java:29)
	at io.gravitee.gateway.reactor.impl.DefaultReactor.route(DefaultReactor.java:98)
	at io.gravitee.gateway.standalone.vertx.VertxReactorHandler.handleRequest(VertxReactorHandler.java:39)
	at io.gravitee.gateway.standalone.vertx.VertxReactorHandler.handle(VertxReactorHandler.java:35)
	at io.gravitee.gateway.standalone.vertx.VertxReactorHandler.handle(VertxReactorHandler.java:25)
	at io.vertx.core.http.impl.ServerConnection.handleRequest(ServerConnection.java:285)
	at io.vertx.core.http.impl.ServerConnection.processMessage(ServerConnection.java:429)
	at io.vertx.core.http.impl.ServerConnection.handleMessage(ServerConnection.java:131)
	at io.vertx.core.http.impl.HttpServerImpl$ServerHandler.lambda$createConnAndHandle$1(HttpServerImpl.java:763)
	at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:335)
	at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:193)
	at io.vertx.core.http.impl.HttpServerImpl$ServerHandler.createConnAndHandle(HttpServerImpl.java:757)
	at io.vertx.core.http.impl.HttpServerImpl$ServerHandler.doMessageReceived(HttpServerImpl.java:676)
	at io.vertx.core.http.impl.HttpServerImpl$ServerHandler.doMessageReceived(HttpServerImpl.java:573)
	at io.vertx.core.http.impl.VertxHttpHandler.channelRead(VertxHttpHandler.java:76)
	at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:122)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:341)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:341)
	at io.vertx.core.http.impl.HttpServerImpl$Http1xOrHttp2Handler.http1(HttpServerImpl.java:1064)
	at io.vertx.core.http.impl.HttpServerImpl$Http1xOrHttp2Handler.channelRead(HttpServerImpl.java:1035)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:341)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:129)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:642)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:565)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:479)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:441)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
	at java.lang.Thread.run(Thread.java:748)
Caused by: io.gravitee.gateway.policy.PolicyException: java.lang.reflect.InvocationTargetException
	at io.gravitee.gateway.policy.impl.PolicyImpl.invoke(PolicyImpl.java:91)
	at io.gravitee.gateway.policy.impl.PolicyImpl.onRequest(PolicyImpl.java:44)
	at io.gravitee.gateway.policy.impl.RequestPolicyChain.execute(RequestPolicyChain.java:44)
	... 75 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at io.gravitee.gateway.policy.impl.PolicyImpl.invoke(PolicyImpl.java:89)
	... 77 more
Caused by: java.lang.IllegalArgumentException: Required type parameter does not match the resource type
	at io.gravitee.gateway.resource.internal.ResourceManagerImpl.getResource(ResourceManagerImpl.java:173)
	at io.gravitee.policy.cache.CachePolicy.onRequest(CachePolicy.java:85)
	... 82 more
@brasseld

This comment has been minimized.

Copy link
Member

brasseld commented Dec 26, 2017

As far as I understand, it seems to happen when you've multiple resources of the same type (in your case cache).

@David-V2

This comment has been minimized.

Copy link
Author

David-V2 commented Dec 26, 2017

Damned, that's right, i need multiples cache profiles for the same api (with different ttl and max entries).
Which time-to-live prevail ? The resource one, or the one defined in the cache policy ?

Gravitee is not a caching solution, I could explain that there is only one "max object setting" for an API, but I will need different ttl.

@brasseld brasseld added the type: bug label Dec 26, 2017

@brasseld

This comment has been minimized.

Copy link
Member

brasseld commented Dec 26, 2017

It seems to be reproducible for each type of resource, it's not only the fact of the cache resource.

@michelkaeser

This comment has been minimized.

Copy link

michelkaeser commented Jan 10, 2019

Can confirm. We installed the Keycloak adapter and created a resource.

It lead to the same error with an additional Gravitee AM resource (both are OAuth2 resources).
Gravitee AM resource was even disabled.

@brasseld brasseld added this to the APIM - 1.20.13 milestone Feb 28, 2019

brasseld added a commit to gravitee-io/gravitee-gateway that referenced this issue Feb 28, 2019

brasseld added a commit to gravitee-io/gravitee-resource-cache that referenced this issue Mar 1, 2019

@NicolasGeraud NicolasGeraud added this to Done in API Management via automation Mar 1, 2019

NicolasGeraud added a commit to gravitee-io/gravitee-resource-cache that referenced this issue Mar 1, 2019

NicolasGeraud added a commit to gravitee-io/gravitee-gateway that referenced this issue Mar 1, 2019

NicolasGeraud added a commit to gravitee-io/gravitee-resource-cache that referenced this issue Mar 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.