@Override protected void contextConfig(final Digester digester) { final NamingResourcesImpl resources; if (context != null) { resources = context.getNamingResources(); } else { resources = null; } if (resources instanceof OpenEJBNamingResource) { ((OpenEJBNamingResource) resources).setTomcatResource(true); } super.contextConfig(digester); if (resources instanceof OpenEJBNamingResource) { ((OpenEJBNamingResource) resources).setTomcatResource(false); } if (context instanceof StandardContext) { final StandardContext standardContext = (StandardContext) context; final NamingContextListener namingContextListener = standardContext.getNamingContextListener(); if (null != namingContextListener) { namingContextListener.setExceptionOnFailedWrite(standardContext.getJndiExceptionOnFailedWrite()); } } }
private void enableJndi() { server.addLifecycleListener(new NamingContextListener()); System.setProperty("catalina.useNaming", "true"); String value = "org.apache.naming"; String oldValue = System.getProperty(javax.naming.Context.URL_PKG_PREFIXES); if (oldValue != null) { if (oldValue.contains(value)) { value = oldValue; } else { value = value + ":" + oldValue; } } System.setProperty(javax.naming.Context.URL_PKG_PREFIXES, value); value = System.getProperty (javax.naming.Context.INITIAL_CONTEXT_FACTORY); if (value == null) { System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory"); } this.enableNaming = true; }
/** * Enables JNDI naming which is disabled by default. Server must implement * {@link Lifecycle} in order for the {@link NamingContextListener} to be * used. * */ public void enableNaming() { // Make sure getServer() has been called as that is where naming is // disabled getServer(); server.addLifecycleListener(new NamingContextListener()); System.setProperty("catalina.useNaming", "true"); String value = "org.apache.naming"; String oldValue = System.getProperty(javax.naming.Context.URL_PKG_PREFIXES); if (oldValue != null) { if (oldValue.contains(value)) { value = oldValue; } else { value = value + ":" + oldValue; } } System.setProperty(javax.naming.Context.URL_PKG_PREFIXES, value); value = System.getProperty (javax.naming.Context.INITIAL_CONTEXT_FACTORY); if (value == null) { System.setProperty (javax.naming.Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory"); } }