JNDI Configuration in embedded Jetty 11

35 Views Asked by At

How to configure JNDI in embedded jetty 11 version

HTTP ERROR 503 Service Unavailable

// 1.We are creating the service Server server = new Server(8080);

        // 2.We are enabling Jetty-plus configuration


        // 3.We are creating the web-application context
        WebAppContext ctx = new WebAppContext();
        ctx.setResourceBase("src/main/webapp");
        ctx.setContextPath("/jetty-jndi-example");

        //ctx.setConfigurations( new Configuration[]{new FragmentConfiguration(),new EnvConfiguration(),new PlusConfiguration()});
        
        // 4.We are creating the data-source here
        PGSimpleDataSource dataSource = new PGSimpleDataSource();
        dataSource.setUrl("jdbc:postgresql://localhost:5432/HOSKSADB?currentSchema=\"FTHOS\"");
        dataSource.setUser("postgres");
        dataSource.setPassword("admin123");
        
        // 5.Here we are registring the datasource for our server
        new Resource(server, "jdbc/jcgDS1", dataSource);

        // 6.Handler setting and application registration code
        server.setHandler(ctx);
        server.start();
        server.join();
0

There are 0 best solutions below