Factor Three
Factor Three

Reputation: 2274

Micronaut service not responding to request

I have a (relatively simple) Micronaut service that I am seeking to pass a parameter to. The code for the service is below:

package com.factor3.app;


import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.*;

@Controller("/testserv")
public class TempTestService
{
   public TempTestService()
   {
   }

   @Get("/{?theData}")
   @Produces(MediaType.TEXT_PLAIN)
   public String performService(String theData)
   {
       return("Returning: "+theData));
   }

}

I have set my port to 8090 in the application.yml file:

micronaut:
    application:
        name: TSBroker

#Uncomment to set server port
    server:
        port: 8090

There are no other controllers, beans, or filters.

I have been running this service and attempting to access it from a browser, using the following URI:

http://localhost:8090/testserv?theData=xxx

After several minutes, I get the following failure on Google Chrome:

This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE

Am I missing something? Why does this page not work?

Thanks in advance for any insights...

Upvotes: 1

Views: 1189

Answers (1)

Jeff Scott Brown
Jeff Scott Brown

Reputation: 27200

There are a few things about your code that won't even compile. If you change your class to look like the following it will compile and will respond to http://localhost:8090/testserv?theData=xxx.

package com.factor3.app;

import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.*;
import javax.annotation.Nullable;

@Controller("/testserv")
public class TempTestService
{
    // this empty constructor isn't necessary, but
    // also doesn't cause a problem...
   public TempTestService()
   {
   }

   @Get("/{?theData}")
   @Produces(MediaType.TEXT_PLAIN)
   public String performService(@Nullable String theData)
   {
       return "Returning: "+theData;
   }
}

Upvotes: 1

Related Questions