cancel
Showing results for 
Search instead for 
Did you mean: 

router.attach(String, Class<? extends ServerResource>)

gilbertoblue
Champ in-the-making
Champ in-the-making
I am unable to get router.attach() to work properly 

Server server = new Server(Protocol.HTTP, 8182, new TestServerApplication());
  server.start()

  Here's the code that's in the client
  ClientResource clientResource = new ClientResource(
            "http://localhost:8182/contacts/123");
The following code does NOT work

router.attach("/contacts/123", ContactServerResource.class);
Exception in thread "main" Not Found (404) - Not Found
The following code does NOT work

router.attach("/contacts/123", ContactServerResource.class, Router.MODE_BEST_MATCH);
Exception in thread "main" Not Found (404) - Not Found
* using attachDefault results in the call being handled properly

// success!
router.attachDefault(ContactServerResource.class);
I also tried something different rather than using a Server.

Component component = new Component();

// Add a new HTTP server listening on port 8182.
component.getServers().add(Protocol.HTTP, 8182);

// Attach the sample application.
component.getDefaultHost().attach("/contacts/123",
        new TestServerApplication());

component.start();
In this case router.attach("/contacts/123", ContactServerResource.class) is still called and it still fails to work. You have to attachDefault() to get it to work

I can't think of anything else to try. Anybody have any ideas? thank you
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
Where does this code live? Are you extending the activiti-rest app? Seems to be more of a restlet-problem rather than an activiti one…