名称java:comp未绑定在此上下文中javax.naming.NameNotFoundException

时间:2017-11-08 16:02:45

标签: java tomcat6

这是我的代码:

   Context ctx  = new InitialContext();
   Context envCtx = (Context)ctx.lookup("java:comp/env");

它通常可以正常工作,但有时会抛出此错误:

Name java:comp is not bound in this Context
javax.naming.NameNotFoundException: Name java:comp is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at javax.naming.InitialContext.lookup(Unknown Source)

这是我的context.xml:

<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>

   <Environment name="fileLocation" value="dev" type="java.lang.String" override="false"/>

   <Environment name="log4JFileLocation" override="false" type="java.lang.String" value="dev"/>

对于发生了什么的任何想法?

谢谢:)

0 个答案:

没有答案