caelum / vraptor4

A web MVC action-based framework, on top of CDI, for fast and maintainable Java development.
http://vraptor.org
Apache License 2.0
350 stars 333 forks source link

Method not allowed (405) in forwardTo(anotherClass.class).method(arg) #1107

Open cesarjhony opened 6 years ago

cesarjhony commented 6 years ago

Error on update Vraptor from 4.2.0-RC2 to 4.2.0.Final. The method called not have any annotation. The header response is HTTP/1.1 405 Method Not Allowed Date: Sat, 10 Feb 2018 16:26:06 GMT Server: Apache Logado: true Location: https://192.168.0.69:443/operacaocaixa/0 Allow: OPTIONS Content-Type: text/html;charset=windows-1252 Content-Language: en Content-Length: 1020 Keep-Alive: timeout=5, max=200 Connection: Keep-Alive

On the code: @Transactional @Put("/entrega/{cod}/{entregue}") public void entrega(Long cod, Boolean entregue){ ...some logic code... result.forwardTo(Another.class).myNotAnnotedMethod(data); } The method is completely executed with any errors, the problem is the response 405.

Obs: I am working with CORS by Interceptor.

Turini commented 6 years ago

what about adding @\options? or any other required method. does that make your request work?

could you provide some code sample to help us reproduce this?

cesarjhony commented 6 years ago

My apologies, this occurs on call forwardTo: result.forwardTo(Another.class).myNotAnnotedMethod(data);

@Transactional @Put("/entrega/{cod}/{entregue}") public void entrega(Long cod, Boolean entregue){ ...some logic code... result.forwardTo(Another.class).myNotAnnotedMethod(data); } I updated the first post.

IvoSestren commented 6 years ago

Maybe because of his method being Put and he can not do the forward?

cesarjhony commented 6 years ago

I don't know about http rules, Turini could answer. Maybe this behavior is fully expected.

Turini commented 6 years ago

the method you’re forwarding the request also accepts the PUT method? It might be the reason. Does that work If you use a result#redirectTo instead?

romulotorres commented 6 years ago

+1 If I use redirectTo instead it works fine, but I can not send my errors list to my ErrorController. The same error occours when I use validator.onErrorForwardTo (ErrorController.class) .erro500 (). Before, I used that to get the list of errors from validator and send to JSON with that to client.

Any help?