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 8641023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:25:15+00:00 2026-06-12T11:25:15+00:00

We are building web services using Grizzly and Jersey and learning along the way

  • 0

We are building web services using Grizzly and Jersey and learning along the way by doing web searches. We noticed two distinct way of launching a grizzly webserver, but do not see whether one way is better than the other. Can anyone help, please?

1 – using GrizzlyWebContainerFactory:

 public static void main(String[] args) throws IOException {
 Map initParams = new HashMap();
 initParams.put( "com.sun.jersey.config.property.packages", "net.gilstraps.server" );
 SelectorThread selector = GrizzlyWebContainerFactory
 .create( "http://localhost:9998/", initParams ); //noinspection ResultOfMethodCallIgnored
 System.in.read();
 threadSelector.stopEndpoint();
 System.exit(0);
 }
}

2 – using GrizzlyWebServer

 GrizzlyWebServer gws = new GrizzlyWebServer(8080, "/var/www");

// Jersey web resources
 ServletAdapter jerseyAdapter = new ServletAdapter();
 jerseyAdapter.addInitParameter("com.sun.jersey.config.property.packages",
 "com.example");
 jerseyAdapter.setContextPath("/jersey");
 jerseyAdapter.setServletInstance(new ServletContainer());

// Another non-Jersey servlet
 ServletAdapter simpleServletAdapter = new ServletAdapter();
 simpleServletAdapter.setContextPath("/simple");
 simpleServletAdapter.setServletInstance(new SimpleServlet());

// register all above defined adapters
 gws.addGrizzlyAdapter(jerseyAdapter, new String[] {"/jersey"});
 gws.addGrizzlyAdapter(simpleServletAdapter, new String[] {"/simple"});

// let Grizzly run
 gws.start();

So which way is better?

Thanks
–Alex

  • 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-12T11:25:17+00:00Added an answer on June 12, 2026 at 11:25 am

    At first I was using your method #1, but then once I needed to provide a more complex configuration, I found that i needed method #2 to have access to the GrizzlyWebServer object.

    For example using GrizzlyWebServer you can control the size of the worker thread pool. (I should note Grizzly docs only recommend doing this is you have IO bound work to be done).

    grizzlyWebServer.setCoreThreads(30);
    grizzlyWebServer.setMaxThreads(50);
    

    I could not find a way to adjust the thread pool size with method #1, therefore I’d recommend method #2 for improved configurability.

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

Sidebar

Related Questions

I've been learning and building JSONP Web services using WCF on fx3.5. You can
I am using Jersey Framework (JAX-RS implementation) for building RESTful Web Services. I'm not
I am building a RESTful web service in java using JAX-RS and jersey and
We're building a set of external web services to be consumed client-side (using jquery/AJAX)
I am considering building some services using the new Web API that's introduced in
I'm building a RESTful web service using Jersey that relies on MongoDB for persistence.
I am building a web application with RESTful web services using Spring MVC 3.
I am building a Web service using WCF as a way to provide access
I'm building a web service client using vb .net. The web service is secured
I'm building a restful web-service based on Spring. I'm using Spring Security. It will

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.