- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经浏览了关于上述主题的所有帖子,但未能解决这个问题。情况是这样的:
1)我在Tomcat 8.0.20的conf/server.xml(GlobalNamingResources)中定义了一组资源2) 我已经在 tomcat conf/context.xml 中声明了 ResourceLink3) 从 Web 应用程序中我得到名称未绑定(bind)异常。
根据我的理解,如果 server.xml 中声明的资源被映射到 ResourceLink 中,则可以从上下文访问它,现在 conf/context.xml 已为所有 Web 应用程序加载并且资源应该可用但是他们不是。我错过了什么吗?
以下是文件:
异常
javax.naming.NameNotFoundException: Name [comp/env] is not bound in this Context
. Unable to find [comp].
at org.apache.naming.NamingContext.lookup(NamingContext.java:818)
at org.apache.naming.NamingContext.lookup(NamingContext.java:166)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:157)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at com.hm.vigil.platform.db.DatabaseConnectionManager.<init>(DatabaseConnectionManager.java:40)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
服务器.xml
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
<Resource name="pool/LDAP"
auth="Container"
type="com.hm.vigil.platform.ldap.LDAPConnectionManager"
factory="com.hm.vigil.platform.ldap.LDAPConnectionManager"
singleton="true"
closeMethod="closeLDAPConnectionManager"/>
<Resource name="platform/ZOOKEEPER"
auth="Container"
type="com.hm.vigil.platform.config.PlatformConfigManager"
factory="com.hm.vigil.platform.config.PlatformConfigManager"
singleton="true"
closeMethod="closeZookeeperConfigRetriever"/>
<Resource name="pool/DB_CLIENT"
auth="Container"
type="javax.sql.Datasource"
factory="com.hm.vigil.platform.db.DatabaseConnectionManager"
singleton="true"
closeMethod="closeDatabaseConnectionManager"/>
<Resource name="platform/client/CONFIG_MANAGER"
auth="Container"
type="com.hm.vigil.platform.config.ClientConfigManager"
factory="com.hm.vigil.platform.config.ClientConfigManager"
singleton="true"
closeMethod="closeClientConfigManager"/>
<Environment name="zooKeeperHost"
type="java.lang.String"
value="localhost"
override="false"/>
<Environment name="zookeeperPort"
type="java.lang.String"
value="2181"
override="false"/>
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
This connector uses the NIO implementation that requires the JSSE
style configuration. When using the APR/native implementation, the
OpenSSL style configuration is required as described in the APR/native
documentation -->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<!-- <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/> -->
<Realm className="org.apache.catalina.realm.JNDIRealm"
connectionURL="ldap://localhost:10389"
connectionName="uid=admin,ou=system"
connectionPassword="secret"
userBase="cn=PLATFORM_CLIENTS,cn=PLATFORM_CONFIG,dc=example,dc=com"
userSubtree="true"
userSearch="(&(objectClass=user)(email={0})(userClass=ACTIVE))"
userRoleName="userRole"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> -->
<Valve className="org.apache.catalina.ha.authenticator.ClusterSingleSignOn" />
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<!-- <Context>
<Environment name="zooKeeperHost"
type="java.lang.String"
value="localhost"
override="false"/>
<Environment name="zookeeperPort"
type="java.lang.String"
value="2181"
override="false"/>
</Context> -->
</Host>
</Engine>
</Service>
</Server>
context.xml
<Context>
<!-- Default set of monitored resources. If one of these changes, the -->
<!-- web application will be reloaded. -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<!-- <Environment name="zooKeeperHost"
type="java.lang.String"
value="localhost"
override="false"/> -->
<ResourceLink name="zooKeeperHost"
global="zooKeeperHost"
type="java.lang.String"/>
<!-- <Environment name="zookeeperPort"
type="java.lang.String"
value="2181"
override="false"/> -->
<ResourceLink name="zookeeperPort"
global="zookeeperPort"
type="java.lang.String"/>
<!-- <Resource name="pool/LDAP"
auth="Container"
type="com.hm.vigil.platform.ldap.LDAPConnectionManager"
factory="com.hm.vigil.platform.ldap.LDAPConnectionManager"
singleton="true"
closeMethod="closeLDAPConnectionManager"/> -->
<ResourceLink name="pool/LDAP"
global="pool/LDAP"
type="com.hm.vigil.platform.ldap.LDAPConnectionManager"/>
<!-- <Resource name="platform/ZOOKEEPER"
auth="Container"
type="com.hm.vigil.platform.config.PlatformConfigManager"
factory="com.hm.vigil.platform.config.PlatformConfigManager"
singleton="true"
closeMethod="closeZookeeperConfigRetriever"/> -->
<ResourceLink name="platform/ZOOKEEPER"
global="platform/ZOOKEEPER"
type="com.hm.vigil.platform.config.ZookeeperConfigRetriever"/>
<!-- <Resource name="pool/DB_CLIENT"
auth="Container"
type="javax.sql.Datasource"
factory="com.hm.vigil.platform.db.DatabaseConnectionManager"
singleton="true"
closeMethod="closeDatabaseConnectionManager"/> -->
<ResourceLink name="pool/DB_CLIENT"
global="pool/DB_CLIENT"
type="javax.sql.Datasource"/>
<!-- <Resource name="platform/client/CONFIG_MANAGER"
auth="Container"
type="com.hm.vigil.platform.config.ClientConfigManager"
factory="com.hm.vigil.platform.config.ClientConfigManager"
singleton="true"
closeMethod="closeClientConfigManager"/> -->
<ResourceLink name="platform/client/CONFIG_MANAGER"
global="platform/client/CONFIG_MANAGER"
type="com.hm.vigil.platform.config.ClientConfigManager"/>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<Manager pathname="" />
<!-- Uncomment this to enable Comet connection tacking (provides events
on session expiration as well as webapp lifecycle) -->
<!--
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
-->
</Context>
谢谢
最佳答案
我将发布我对上述问题的发现。
问题是一个/多个资源具有对绑定(bind)到 JNDI 树的另一个资源的内部引用。因此,在创建资源期间,其他资源会尝试解析公共(public)资源的 JNDI 树。现在,在加载上下文时,该上下文的 JNDI 树实际上并不存在,因此出现上述错误。
解决方法是在公共(public)资源上声明一个工厂方法,并通过工厂方法从其他资源获取对公共(public)资源的引用。
因此,作为一般原则,我认为资源不能从 JNDI 解析其他资源。
关于java - Tomcat JNDI 资源不可访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29875188/
我正在编写一个具有以下签名的 Java 方法。 void Logger(Method method, Object[] args); 如果一个方法(例如 ABC() )调用此方法 Logger,它应该
我是 Java 新手。 我的问题是我的 Java 程序找不到我试图用作的图像文件一个 JButton。 (目前这段代码什么也没做,因为我只是得到了想要的外观第一的)。这是我的主课 代码: packag
好的,今天我在接受采访,我已经编写 Java 代码多年了。采访中说“Java 垃圾收集是一个棘手的问题,我有几个 friend 一直在努力弄清楚。你在这方面做得怎么样?”。她是想骗我吗?还是我的一生都
我的 friend 给了我一个谜语让我解开。它是这样的: There are 100 people. Each one of them, in his turn, does the following
如果我将使用 Java 5 代码的应用程序编译成字节码,生成的 .class 文件是否能够在 Java 1.4 下运行? 如果后者可以工作并且我正在尝试在我的 Java 1.4 应用程序中使用 Jav
有关于why Java doesn't support unsigned types的问题以及一些关于处理无符号类型的问题。我做了一些搜索,似乎 Scala 也不支持无符号数据类型。限制是Java和S
我只是想知道在一个 java 版本中生成的字节码是否可以在其他 java 版本上运行 最佳答案 通常,字节码无需修改即可在 较新 版本的 Java 上运行。它不会在旧版本上运行,除非您使用特殊参数 (
我有一个关于在命令提示符下执行 java 程序的基本问题。 在某些机器上我们需要指定 -cp 。 (类路径)同时执行java程序 (test为java文件名与.class文件存在于同一目录下) jav
我已经阅读 StackOverflow 有一段时间了,现在我才鼓起勇气提出问题。我今年 20 岁,目前在我的家乡(罗马尼亚克卢日-纳波卡)就读 IT 大学。足以介绍:D。 基本上,我有一家提供簿记应用
我有 public JSONObject parseXML(String xml) { JSONObject jsonObject = XML.toJSONObject(xml); r
我已经在 Java 中实现了带有动态类型的简单解释语言。不幸的是我遇到了以下问题。测试时如下代码: def main() { def ks = Map[[1, 2]].keySet()
一直提示输入 1 到 10 的数字 - 结果应将 st、rd、th 和 nd 添加到数字中。编写一个程序,提示用户输入 1 到 10 之间的任意整数,然后以序数形式显示该整数并附加后缀。 public
我有这个 DownloadFile.java 并按预期下载该文件: import java.io.*; import java.net.URL; public class DownloadFile {
我想在 GUI 上添加延迟。我放置了 2 个 for 循环,然后重新绘制了一个标签,但这 2 个 for 循环一个接一个地执行,并且标签被重新绘制到最后一个。 我能做什么? for(int i=0;
我正在对对象 Student 的列表项进行一些测试,但是我更喜欢在 java 类对象中创建硬编码列表,然后从那里提取数据,而不是连接到数据库并在结果集中选择记录。然而,自从我这样做以来已经很长时间了,
我知道对象创建分为三个部分: 声明 实例化 初始化 classA{} classB extends classA{} classA obj = new classB(1,1); 实例化 它必须使用
我有兴趣使用 GPRS 构建车辆跟踪系统。但是,我有一些问题要问以前做过此操作的人: GPRS 是最好的技术吗?人们意识到任何问题吗? 我计划使用 Java/Java EE - 有更好的技术吗? 如果
我可以通过递归方法反转数组,例如:数组={1,2,3,4,5} 数组结果={5,4,3,2,1}但我的结果是相同的数组,我不知道为什么,请帮助我。 public class Recursion { p
有这样的标准方式吗? 包括 Java源代码-测试代码- Ant 或 Maven联合单元持续集成(可能是巡航控制)ClearCase 版本控制工具部署到应用服务器 最后我希望有一个自动构建和集成环境。
我什至不知道这是否可能,我非常怀疑它是否可能,但如果可以,您能告诉我怎么做吗?我只是想知道如何从打印机打印一些文本。 有什么想法吗? 最佳答案 这里有更简单的事情。 import javax.swin
我是一名优秀的程序员,十分优秀!