Search code examples
javanetbeansweblogicjax-rsweblogic12c

JAX-RS Method called once gets invoked multiple times in Weblogic


I wrote a REST class and in it, a method to call query a database table. It worked. I was happy. That was until I realised from the weblogic log that the method was getting invoked more than once, even though I called it once.

I wrote another sample method, and the same thing happened.

Here:

@GET
    @Produces(MediaType.TEXT_PLAIN)
    @Path("all")
    public String getJson(@DefaultValue("Nothing in a") @QueryParam("a") String a,
            @DefaultValue("Nothing in b") @QueryParam("b") String b) {
        System.out.println("CALLED DEFAULT SERVICE");
        return "Test works: " + a + " " + b;
    }

Notice I placed a print out (CALLED DEFAULT SERVICE). I wanted to be sure if the method was being called more than once or if I was seeing things before.

When I call the browser, everything works like a charm, except in the log I see this:

INFO: Instantiated the Application class org.greenpole.webservices_rest.ApplicationConfig
CALLED DEFAULT SERVICE
Mar 22, 2015 11:42:53 AM weblogic.jaxrs.server.portable.JaxRsMonitoringProvider onResourceMethod
WARNING: Monitoring Disabled
<22-Mar-2015 11:42:53 o'clock WAT> <Warning> <weblogic.jaxrs.server.portable.JaxRsMonitoringProvider> <BEA-000000> <Monitoring Disabled> 
CALLED DEFAULT SERVICE
CALLED DEFAULT SERVICE

The method is invoked after the line: "Instantiated the Application class org.greenpole.webservices_rest.ApplicationConfig". Afterwards, watching the log, I notice it gets invoked twice, but by what and why??

Has anyone experienced this before?


Solution

  • After carrying out a bunch of research and extra tests, I found out that this anomaly occurs when I'm using Chrome. I tested my REST service with Firefox and nothing happened.

    I also added a global variable that would increment whenever the method is invoked more than once, and it only incremented to 1, even though the printout appeared multiple times - meaning, it's not actually invoking the method more than once. It invokes it once and just re-prints the log over and over for as long as it deems fit. Strange.

    Anyway, I'm glad!