resteasy @Consume json fails with java.util.Map -
i have following json structure:
{ "foo" : { "foo1" : { "txt" : "val", "txt1" : "val1", "txt2" : "val2", }, "foo2" : { "txt" : "val", "txt1" : "val1", "txt2" : "val2", } }, "bar" : { "bar1": { "txt" : "val", "txt1" : "val1", "txt2" : "val2", }, "bar2": { "txt" : "val", "txt1" : "val1", "txt2" : "val2", } } }
while have following pojo:
class pojo { string txt; string txt1; string txt2; }
and resteasy method looks like:
@post @produces({ mediatype.application_json }) @consumes({ mediatype.application_json }) @path("/foo") public void bar(@queryparam("jsonobj") map<string,map<string,pojo>> jsonobj);
however while starting server following error:
java.lang.runtimeexception: unable find constructor takes string param or valueof() or fromstring() method javax.ws.rs.queryparam("jsonobj") on public abstract void com.foo.foobar.bar(java.util.map) basetype: java.util.map @ org.jboss.resteasy.core.stringparameterinjector.initialize(stringparameterinjector.java:217) ~[resteasy-jaxrs-3.0.9.final.jar:na] @ org.jboss.resteasy.core.stringparameterinjector.(stringparameterinjector.java:61) ~[resteasy-jaxrs-3.0.9.final.jar:na] @ org.jboss.resteasy.core.queryparaminjector.(queryparaminjector.java:28) ~[resteasy-jaxrs-3.0.9.final.jar:na] @ org.jboss.resteasy.core.injectorfactoryimpl.createparameterextractor(injectorfactoryimpl.java:85) ~[resteasy-jaxrs-3.0.9.final.jar:na] @ org.jboss.resteasy.core.methodinjectorimpl.(methodinjectorimpl.java:42) ~[resteasy-jaxrs-3.0.9.final.jar:na] @ org.jboss.resteasy.core.injectorfactoryimpl.createmethodinjector(injectorfactoryimpl.java:76) ~[resteasy-jaxrs-3.0.9.final.jar:na] @ org.jboss.resteasy.core.resourcemethodinvoker.(resourcemethodinvoker.java:100) ~[resteasy-jaxrs-3.0.9.final.jar:na] @ org.jboss.resteasy.core.resourcemethodregistry.processmethod(resourcemethodregistry.java:280) ~[resteasy-jaxrs-3.0.9.final.jar:na] @ org.jboss.resteasy.core.resourcemethodregistry.register(resourcemethodregistry.java:251) ~[resteasy-jaxrs-3.0.9.final.jar:na] @ org.jboss.resteasy.core.resourcemethodregistry.addresourcefactory(resourcemethodregistry.java:221) ~[resteasy-jaxrs-3.0.9.final.jar:na] @ org.jboss.resteasy.core.resourcemethodregistry.addresourcefactory(resourcemethodregistry.java:193) ~[resteasy-jaxrs-3.0.9.final.jar:na] @ org.jboss.resteasy.core.resourcemethodregistry.addresourcefactory(resourcemethodregistry.java:179) ~[resteasy-jaxrs-3.0.9.final.jar:na] @ org.jboss.resteasy.plugins.spring.springbeanprocessor.onapplicationevent(springbeanprocessor.java:486) ~[resteasy-spring-3.0.9.final.jar:na] @ org.springframework.context.event.simpleapplicationeventmulticaster.multicastevent(simpleapplicationeventmulticaster.java:96) ~[spring-context-3.2.8.release.jar:3.2.8.release] @ org.springframework.context.support.abstractapplicationcontext.publishevent(abstractapplicationcontext.java:334) ~[spring-context-3.2.8.release.jar:3.2.8.release] @ org.springframework.context.support.abstractapplicationcontext.finishrefresh(abstractapplicationcontext.java:948) ~[spring-context-3.2.8.release.jar:3.2.8.release] @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:482) ~[spring-context-3.2.8.release.jar:3.2.8.release] @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:410) ~[spring-web-3.2.8.release.jar:3.2.8.release] @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:306) ~[spring-web-3.2.8.release.jar:3.2.8.release] @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:112) [spring-web-3.2.8.release.jar:3.2.8.release] @ org.jboss.resteasy.plugins.spring.springcontextloaderlistener.contextinitialized(springcontextloaderlistener.java:48) [resteasy-spring-3.0.9.final.jar:na] @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4939) [catalina.jar:7.0.47] @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5434) [catalina.jar:7.0.47] @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150) [catalina.jar:7.0.47] @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1559) [catalina.jar:7.0.47] @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1549) [catalina.jar:7.0.47] @ java.util.concurrent.futuretask.run(futuretask.java:262) [na:1.7.0-45] @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) [na:1.7.0-45] @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) [na:1.7.0-45] @ java.lang.thread.run(thread.java:744) [na:1.7.0-45]
i went through documentation , complex objects says use stringconvertor, shouldn't supported simple types list, map etc...
instead of taking json in map> jsonobj format , can use inputstream , can process input stream objects out of it.
Comments
Post a Comment