Java EE异常:此上下文中未绑定名称java:comp [英] Java EE Exception: Name java:comp is not bound in this Context

查看:421
本文介绍了Java EE异常:此上下文中未绑定名称java:comp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Netbeans 7.2.1中拥有Java EE应用程序.尝试部署它(构建结束正常),我在Tomcat日志中收到错误:

I have the Java EE app in Netbeans 7.2.1. Trying to deploy it (building ends OK), I get the error in Tomcat log:

Caused by: 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(InitialContext.java:392)
    at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
    at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
    at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
    at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
    at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)
    at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1454)

寻找导致此错误的代码,我发现以下内容:

Looking for code, that causes this error I found the follow:

public Object lookup(String name) throws NamingException {
    return getURLOrDefaultInitCtx(name).lookup(name);
    }

这是怎么引起的,我该如何解决?

How is this caused and how can I solve it?

推荐答案

如果出于某些原因丢弃了任意servlet容器特定的JAR(例如jsp-api.jarservlet-api.jarcatalina.jar,等等在webapp的/WEB-INF/lib中.您应该从那里删除所有特定于servletcontainer的JAR,但它们不属于那里.另外,请确保这些JAR不会嵌套在WEB-INF/lib内部的其他JAR中.

That will in case of Tomcat happen when you have for some reason dropped arbitrary servletcontainer-specific JARs such as jsp-api.jar, servlet-api.jar, catalina.jar, etc in webapp's /WEB-INF/lib. You should remove all servletcontainer-specific JARs from there, they do not belong there. Also, make sure those JARs are not nested within other JARs you have inside WEB-INF/lib.

这是一个常见的入门错误,是为了修复" JSP/Servlet库上的编译错误,而这些错误应该以不同的方式解决.即通过将IDE项目配置为与Netbeans中的目标服务器"或Eclipse中的目标运行时"关联.然后,IDE将在编译期间自动包含服务器的库.

This is a common starter's mistake in order to "fix" compilation errors on JSP/Servlet libraries which should have been solved differently; namely by configuring the IDE project to be associated with a "Target server" in Netbeans or "Target runtime" in Eclipse. The IDE will then automagically include the server's libraries during compiletime.

这篇关于Java EE异常:此上下文中未绑定名称java:comp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆