KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to write a REST service in java using Jersey and Glassfish Grizzly. I have a very simple case working internally, but can't seem to call on the server from an external address. I've tried using a variety of different pairs of machines with externally visible IP's, and tried specifying the actual IP address in the server instead of localhost , but nothing works. I'm somewhat loosely following the official user guide here . My resource: package resources; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; @Path("/simpleREST") public class SimpleRESTResource { @GET @Produces("text/plain") public String getMessage() { return "Message from server\n"; } } And the server: import java.io.IOException; import java.net.URI; import javax.ws.rs.core.UriBuilder; import org.glassfish.grizzly.http.server.HttpServer; import com.sun.jersey.api.container.grizzly2.GrizzlyServerFactory; import com.sun.jersey.api.core.PackagesResourceConfig; import com.sun.jersey.api.core.ResourceConfig; public class Main { public static final URI BASE_URI = UriBuilder.fromUri("http://localhost").port(9998).build(); public static void main(String[] args) throws IOException { System.out.println("Starting grizzly..."); ResourceConfig rc = new PackagesResourceConfig("resources"); HttpServer myServer = GrizzlyServerFactory.createHttpServer(BASE_URI, rc); System.out.println(String.format("Jersey app started with WADL available at %s/application.wadl\n" + "Try out %s/simpleREST\nHit enter to stop it...", BASE_URI, BASE_URI)); System.in.read(); myServer.stop(); } } On the same machine, I can successfully in
Tags (comma-separated)
Save Edits
Cancel