environment.setType("java.lang.String");
environment.setName("globalTest");
environment.setValue("Tomcat User");
tomcat.getServer().getGlobalNamingResources().addEnvironment(environment);
ContextResourceLink link = new ContextResourceLink();
link.setGlobal("globalTest");
link.setName(HelloWorldJndi.JNDI_ENV_NAME);
ctx.getNamingResources().addResourceLink(link);
Tomcat.addServlet(ctx, "jndiServlet", new HelloWorldJndi());
ctx.addServletMapping("/", "jndiServlet");