在Tomcat LifecycleListener中访问jndi环境变量
我正在使用tomcat中的LifecycleListener初始化web服务器中上下文所需的一些对象。在LifecycleListener中,我希望能够访问GlobalNamingResources环境变量,以便将服务器的配置保存在server.xml文件中。尝试各种方法时,我会出现以下错误:在Tomcat LifecycleListener中访问jndi环境变量,tomcat,Tomcat,我正在使用tomcat中的LifecycleListener初始化web服务器中上下文所需的一些对象。在LifecycleListener中,我希望能够访问GlobalNamingResources环境变量,以便将服务器的配置保存在server.xml文件中。尝试各种方法时,我会出现以下错误: javax.naming.NameNotFoundException: Name java:comp is not bound in this Context 我假设jndi没有在服务器启动过程的这个阶
javax.naming.NameNotFoundException: Name java:comp is not bound in this Context
我假设jndi没有在服务器启动过程的这个阶段初始化。有没有办法解决这个问题 JNDI也在LifecycleListener中设置,但NamingContextListener是最后一个。我认为你无法改变这一点 解决方案是在ServletContextListener中初始化应用程序。这总是在所有LifecycleListener启动后初始化 您可以使用
将所有全局JNDI上下文导入webapp