Le 2014-05-12 09:37, Tony Chemit a écrit :
On Fri, 09 May 2014 10:31:34 +0200 a.garandel@dralagen.fr wrote:
Bonjour,
Le serveur n'arrive pas a récupérer les données avec la méthode PUT
---------------------------------------------------------- Caused by: java.lang.NullPointerException at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:213) at org.chorem.pollen.services.service.PollenServiceSupport.checkNotNull(PollenServiceSupport.java:232) at org.chorem.pollen.services.service.PollService.editPoll(PollService.java:159) at org.chorem.pollen.rest.api.v1.PollApi.editPoll(PollApi.java:95) -----------------------------------------------------------
Si je change dans le mapping : ----------------------------------------------------------- ligne 74: - PUT /v1/polls/{pollId} PollApi.editPoll + POST /v1/polls/{pollId} PollApi.editPoll
ligne 77 - POST /v1/polls/{pollId} PollApi.clonePoll + PUT /v1/polls/{pollId} PollApi.clonePoll -----------------------------------------------------------
du coup ça marche. Mais il me demande d'envoyer les choix mais je sais que ça c'est pas important.
Normal, car en faisant ça tu utilises en fait le /v1/polls/{pollId} PollApi.createPoll :)
On avait essayé rapidemment mercredi et ça fonctionnait. Peux-tu bien valider et fournir ce que tu envoies au serveur.
De manière générale pour résoudre un problème il faut un maximum d'info; dans notre cas (appel REST), il faut :
- la cause (la requête envoyée) - la failure (l'exception obtenue)
Adrien.
PS : je sais pas si je dois poster ça sur redmine pour un meilleur suivis ?
Je ne pense pas que ça soit la peine, tout n'est pas encore figé, mieux vaut éviter de poster des bugs sur des développements non encore terminées ;)
merci,
tony.
Bonjour, je refais avec tous les détails : mapping par défaut, (ajout en POST, modification en PUT) Création fonctionne très bien, modification : method put a l'adresse : http://localhost:8080/pollen-rest-api/v1/polls/org.chorem.pollen.persistence... donc /v1/polls/{{pollId}}?permission={{creator.permission.token}} donnée envoyé sous ce format : poll=%7B%22beginDate%22%3A1399883282518%2C%22commentVisibility%22%3A%22EVERYBODY%22%2C%22pollType%22%3A%22FREE%22%2C%22title%22%3A%22edit%22%2C%22topiaCreateDate%22%3A1399883297783%2C%22topiaId%22%3A%22org.chorem.pollen.persistence.entity.Poll_286b6836-7c1c-4a7b-9325-b92862d131ce%22%2C%22topiaVersion%22%3A1%2C%22voteCountingType%22%3A1%2C%22voteVisibility%22%3A%22EVERYBODY%22%2C%22choice%22%3A%5B%7B%22choiceType%22%3A%22TEXT%22%2C%22name%22%3A%22azezrra%22%2C%22topiaCreateDate%22%3A1399883297808%2C%22topiaId%22%3A%22org.chorem.pollen.persistence.entity.Choice_f78c4a4f-59e9-480a-ae89-e22668964f36%22%7D%5D%7D traduction : poll = {"beginDate":1399883282518,"commentVisibility":"EVERYBODY","pollType":"FREE","title":"edit","topiaCreateDate":1399883297783,"topiaId":"org.chorem.pollen.persistence.entity.Poll_286b6836-7c1c-4a7b-9325-b92862d131ce","topiaVersion":1,"voteCountingType":1,"voteVisibility":"EVERYBODY","choice":[{"choiceType":"TEXT","name":"azezrra","topiaCreateDate":1399883297808,"topiaId":"org.chorem.pollen.persistence.entity.Choice_f78c4a4f-59e9-480a-ae89-e22668964f36"}]} Stack trace de lors de l'edition : mai 12, 2014 10:36:57 AM org.apache.catalina.core.StandardWrapperValve invoke Grave: Servlet.service() for servlet [default] in context with path [/pollen-rest-api] threw exception org.debux.webmotion.server.WebMotionException: Error during invoke method for action org.chorem.pollen.rest.api.v1.PollApi on method editPoll at org.debux.webmotion.server.handler.ExecutorMethodInvokerHandler$RunnableHandler.processAction(ExecutorMethodInvokerHandler.java:283) at org.debux.webmotion.server.handler.ExecutorMethodInvokerHandler$RunnableHandler.handle(ExecutorMethodInvokerHandler.java:225) at org.debux.webmotion.server.WebMotionFilter.doProcess(WebMotionFilter.java:73) at org.debux.webmotion.server.WebMotionFilter.doProcess(WebMotionFilter.java:61) at org.chorem.pollen.rest.api.PollenRestApiRequestFilter.inject(PollenRestApiRequestFilter.java:57) at sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.debux.webmotion.server.handler.ExecutorMethodInvokerHandler$RunnableHandler.processFilter(ExecutorMethodInvokerHandler.java:310) at org.debux.webmotion.server.handler.ExecutorMethodInvokerHandler$RunnableHandler.handle(ExecutorMethodInvokerHandler.java:222) at org.debux.webmotion.server.handler.ExecutorMethodInvokerHandler.handle(ExecutorMethodInvokerHandler.java:120) at org.debux.webmotion.server.WebMotionMainHandler.chainHandlers(WebMotionMainHandler.java:270) at org.debux.webmotion.server.WebMotionMainHandler.handleExecutors(WebMotionMainHandler.java:260) at org.debux.webmotion.server.WebMotionMainHandler.handle(WebMotionMainHandler.java:196) at org.debux.webmotion.server.WebMotionServer.doAction(WebMotionServer.java:159) at org.debux.webmotion.server.WebMotionServer.doFilter(WebMotionServer.java:136) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.nuiton.web.filter.TypedTopiaTransactionFilter.doFilter(TypedTopiaTransactionFilter.java:248) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.debux.webmotion.server.handler.ExecutorMethodInvokerHandler$RunnableHandler.processAction(ExecutorMethodInvokerHandler.java:255) ... 34 more Caused by: java.lang.NullPointerException at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:213) at org.chorem.pollen.services.service.PollenServiceSupport.checkNotNull(PollenServiceSupport.java:232) at org.chorem.pollen.services.service.PollService.editPoll(PollService.java:159) at org.chorem.pollen.rest.api.v1.PollApi.editPoll(PollApi.java:99) ... 39 more Si je fais le changement sur le mapping pour faire l’édition en POST et depuis angular l'envoie en POST et non en PUT alors il fait bien l’édition du sondage en passant en paramètre la bonne permission (il faut que je passe les choix sinon ça bug il me semble) pour vérifier j'ai ajouter un log.info('edit poll') dans la méthode d’édition et le serveur m'affiche : INFO (PollApi.java:98) EDIT POLL Dernier test : J'ai inversé le put et le post (donc modification en POST, et ajout en PUT) lors de l'ajout : paramètre form : poll={"beginDate":1399885050591,"commentVisibility":"EVERYBODY","pollType":"FREE","topiaCreateDate":1399885050591,"voteCountingType":1,"voteVisibility":"EVERYBODY","title":"zertyu","choice":[{"name":"azert","date":"2014-05-12T08:57:30.515Z","choiceType":"TEXT"}]} Stack d'erreur : 10:57:58 INFO (PollApi.java:90) Create POLL mai 12, 2014 10:57:58 AM org.apache.catalina.core.StandardWrapperValve invoke Grave: Servlet.service() for servlet [default] in context with path [/pollen-rest-api] threw exception org.debux.webmotion.server.WebMotionException: Error during invoke method for action org.chorem.pollen.rest.api.v1.PollApi on method createPoll at org.debux.webmotion.server.handler.ExecutorMethodInvokerHandler$RunnableHandler.processAction(ExecutorMethodInvokerHandler.java:283) at org.debux.webmotion.server.handler.ExecutorMethodInvokerHandler$RunnableHandler.handle(ExecutorMethodInvokerHandler.java:225) at org.debux.webmotion.server.WebMotionFilter.doProcess(WebMotionFilter.java:73) at org.debux.webmotion.server.WebMotionFilter.doProcess(WebMotionFilter.java:61) at org.chorem.pollen.rest.api.PollenRestApiRequestFilter.inject(PollenRestApiRequestFilter.java:57) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.debux.webmotion.server.handler.ExecutorMethodInvokerHandler$RunnableHandler.processFilter(ExecutorMethodInvokerHandler.java:310) at org.debux.webmotion.server.handler.ExecutorMethodInvokerHandler$RunnableHandler.handle(ExecutorMethodInvokerHandler.java:222) at org.debux.webmotion.server.handler.ExecutorMethodInvokerHandler.handle(ExecutorMethodInvokerHandler.java:120) at org.debux.webmotion.server.WebMotionMainHandler.chainHandlers(WebMotionMainHandler.java:270) at org.debux.webmotion.server.WebMotionMainHandler.handleExecutors(WebMotionMainHandler.java:260) at org.debux.webmotion.server.WebMotionMainHandler.handle(WebMotionMainHandler.java:196) at org.debux.webmotion.server.WebMotionServer.doAction(WebMotionServer.java:159) at org.debux.webmotion.server.WebMotionServer.doFilter(WebMotionServer.java:136) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.nuiton.web.filter.TypedTopiaTransactionFilter.doFilter(TypedTopiaTransactionFilter.java:248) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.debux.webmotion.server.handler.ExecutorMethodInvokerHandler$RunnableHandler.processAction(ExecutorMethodInvokerHandler.java:255) ... 35 more Caused by: java.lang.NullPointerException at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:213) at org.chorem.pollen.services.service.PollenServiceSupport.checkNotNull(PollenServiceSupport.java:232) at org.chorem.pollen.services.service.PollService.createPoll(PollService.java:142) at org.chorem.pollen.rest.api.v1.PollApi.createPoll(PollApi.java:91) ... 40 more J'en conclus que le problème vient de la récupération des données avec la methode PUT. Adrien.