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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:24:56+00:00 2026-06-09T23:24:56+00:00

I have implemented this example into my application: https-clientserver-grizzly Here is Server.java from that

  • 0

I have implemented this example into my application:

https-clientserver-grizzly

Here is Server.java from that link:

public class Server {

    private static HttpServer webServer;

    public static final URI BASE_URI = getBaseURI();
    public static final String CONTENT = "JERSEY HTTPS EXAMPLE\n";

    private static URI getBaseURI() {
        return UriBuilder.fromUri("https://localhost/").port(getPort(4463)).build();
    }

    private static int getPort(int defaultPort) {
        String port = System.getProperty("jersey.test.port");
        if (null != port) {
            try {
                return Integer.parseInt(port);
            } catch (NumberFormatException e) {
            }
        }
        return defaultPort;
    }

    protected static void startServer() {

        // add Jersey resource servlet
        WebappContext context = new WebappContext("context");
        ServletRegistration registration = 
                context.addServlet("ServletContainer", ServletContainer.class);
        registration.setInitParameter("com.sun.jersey.config.property.packages",
                "com.sun.jersey.samples.https_grizzly.resource;com.sun.jersey.samples.https_grizzly.auth");

        // add security filter (which handles http basic authentication)
        registration.setInitParameter(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS,
                SecurityFilter.class.getName());

        // Grizzly ssl configuration
        SSLContextConfigurator sslContext = new SSLContextConfigurator();

        // set up security context
        sslContext.setKeyStoreFile("./keystore_server"); // contains server keypair
        sslContext.setKeyStorePass("asdfgh");
        sslContext.setTrustStoreFile("./truststore_server"); // contains client certificate
        sslContext.setTrustStorePass("asdfgh");

        try {

            webServer = GrizzlyServerFactory.createHttpServer(
                    getBaseURI(),
                    null,
                    true,
                    new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(true)
            );

            // start Grizzly embedded server //
            System.out.println("Jersey app started. Try out " + BASE_URI + "\nHit CTRL + C to stop it...");
            context.deploy(webServer);
            webServer.start();

        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
    }

    protected static void stopServer() {
        webServer.stop();
    }

    public static void main(String[] args) throws InterruptedException, IOException {
        startServer();

        System.in.read();
    }
}

However I decided to enable just Basic Authentication (not SSl authentication needed)

I changed that part:

UriBuilder.fromUri("http://localhost/").port(getPort(4463)).build();

and I commented the part from that line:

SSLConfig sslConfig = new SSLConfig();

until that line:

System.out.println("Jersey app started. Try out " + BASE_URI + "\nHit CTRL + C to stop it...");    

However I get that error:

com.sun.grizzly.DefaultProtocolChain executeProtocolFilter
SEVERE: ProtocolChain exception
java.lang.NullPointerException
    at com.sun.grizzly.filter.SSLReadFilter.newSSLEngine(SSLReadFilter.java:331)
    at com.sun.grizzly.filter.SSLReadFilter.obtainSSLEngine(SSLReadFilter.java:378)
    at com.sun.grizzly.filter.SSLReadFilter.execute(SSLReadFilter.java:147)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:136)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

How can I write a code that just needs basic authentication at grizzly?

  • 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-09T23:24:57+00:00Added an answer on June 9, 2026 at 11:24 pm

    It was about a bug at grizzly. Any ideas about to overcome that bug is welcome. However a tricky solution is here:

    http://grizzly.1045725.n5.nabble.com/Grizzly-2-Guice-Jersey-tp5709778p5709787.html

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

Sidebar

Related Questions

So, I have implemented this method to add a footer to my table view:
I have a collection class MyCollection<T> . I have implemented T this[string name] ,
I have a singleton implemented like this: class Test123(object): _instance = None def __new__(cls,
I have implemented correctly bump's api, and added this code: - (void) configureBump {
Looking at this article: http://www.galloway.me.uk/tutorials/singleton-classes/ I have implemented a singleton, my question is the
I haven't yet implemented this, I'm still in the thinking stage, but I have
This is related to OpenId authentication. I have implemented the google and yahoo openId
This is regarding AES algorithm. Suppose i have implemented a AES algorithm and encrypt
I was wondering how other people implemented this scenario. I have an internal rails
I have this code implemented and I like how straight forward it is because

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.