0

I've faced with problem when I'm trying to call service method and check before that some condition

@Path("service")
public class MyService {

    @POST
    @Path("process")
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    @Produces(MediaType.TEXT_PLAIN)
    public static Response process(@Context HttpServletRequest request, @FormParam("text") final String text) throws JSONException, IOException {
        boolean someCondition =  true; // for example
        System.out.println("I'm here"); //*
        if (!someCondition) {
            return MyClass1.process(request, text);
        } else {
            return MyClass2.process(request, text);
        }
    }

In class MyClass1 and MyClass2 I have next method signature

public static Response process(@Context HttpServletRequest request, @FormParam("text") final String text) throws JSONException, IOException 

I get not found response on calling this method service, and even row with * comment wasn't printed.

How I can resolve this problem?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ray
  • 1,788
  • 7
  • 55
  • 92
  • your service might not have been registered. You need to check the logs when starting the server to make sure your MyService class gets registered. – rochb Feb 18 '14 at 09:42

1 Answers1

0

I made very stupid mistake static method:

 public static Response process(@Context HttpServletRequest request, @FormParam("text") final String text) throws JSONException, IOException {
Ray
  • 1,788
  • 7
  • 55
  • 92