Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8933695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:36:24+00:00 2026-06-15T09:36:24+00:00

I am running a JSE application with Restlet 2.1. I am attempting to use

  • 0

I am running a JSE application with Restlet 2.1. I am attempting to use the application context, and am finding that it is always null in my application. Because it is null, I cannot seem to access anything — including any attributes that I pass when I invoke the resource.

The code for the restlet application class is below:

package net.factor3.mailapp;

import net.factor3.mailapp.impl.PageServerImpl;

import org.restlet.Application;
import org.restlet.Context;
import org.restlet.Request;
import org.restlet.Response;
import org.restlet.Restlet;
import org.restlet.Server;
import org.restlet.data.MediaType;
import org.restlet.data.Protocol;
import org.restlet.routing.Router;
import org.restlet.routing.Template;

public class MyServer extends Application
{
   public MyServer()
   {
      setName("Test Application");
      setDescription("Testing use of Restlets");
   }

  @Override
  public Restlet createInboundRoot()
  {
      Context ctx = getContext();
      Router route = new Router(ctx);

      route.setDefaultMatchingMode(Template.MODE_EQUALS);
      route.attach("http://localhost:8100/",PageServerImpl.class);
      route.attach("http://localhost:8100/{page}",PageServerImpl.class);

      return(route);
   }

   public static void main(String[] args) throws Exception
   {
      Server asrv = new Server(Protocol.HTTP,8100);
      asrv.setNext(new MyServer());
      asrv.start();
   }

}

Note that the PageServerImpl is a ServerResource. In createInboundRoot(), I use getContext() to get the application’s context and put it into ctx. ctx is always null, and I believe for that reason parameters and attributes are lost in the ServerResource.

Is this a bug in the JRE version of Restlet 2.1? If it is, where do I go to report it? There is no clear link to bug reports on the Restlet website.

If it is not a bug, then how do I get a decent context in an application of this kind???

Someone please advise.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:36:27+00:00Added an answer on June 15, 2026 at 9:36 am

    Using Component Class you can create statisfy your need:

     public class MyServer extends Application
     {
        public MyServer()
        {
           setName("Test Application");
           setDescription("Testing use of Restlets");
        }
    
        public static void main(String[] args) throws Exception
        {
            // Create a new Restlet component and add a HTTP server connector to it
            Component component = new Component();
            component.getServers().add(Protocol.HTTP, 8182); 
            // Then attach it to the local host
            component.getDefaultHost().attach("/trace", GenericResource.class); 
            // Now, let's start the component!
            // Note that the HTTP server connector is also automatically started.
            component.start();
        }
    }
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Running my script through Devel::NYTProf showed that the following portion of code took up
Running SQL Server 2008 (not R2). I have a few reports that have URLs
Running Rails 3.1.3... I'll use a simple example of nested associations (not sure if
running: ruby 1.9.3p0 with Rails 3.2.1 Trying to use rspec but when I try
Running the ASP.NET webforms run the application works fine. When the application is idle
Running this in python will result in a WindowsError stating it cannot find the
Running an MVC web site that calls a WCF service. Site and service on
Running Windows PHP 4.4.2 \cli\php.exe fails with an error Cannot find php4ts.dll if the
Running Rails 3.2.8, devise 2.1.2. I noticed that the migration contains blank defaults: class
Running CodeSniffer PHP style tests gave me the following error: The use of function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.