java - Tomcat JNDI Resouce Not Accessible -
i have gone through posts on above subject have not been able resolve this. situation this:
1) have defined set of resources in conf/server.xml (globalnamingresources) of tomcat 8.0.20 2) have declared resourcelink in tomcat conf/context.xml 3) web application getting name not bound exception.
as per understanding, resources declared in server.xml accessible context if mapped in resourcelink, conf/context.xml loaded web applications , resources should available not. missing something.
below files:
the exception
javax.naming.namenotfoundexception: name [comp/env] not bound in context . unable find [comp]. @ org.apache.naming.namingcontext.lookup(namingcontext.java:818) @ org.apache.naming.namingcontext.lookup(namingcontext.java:166) @ org.apache.naming.selectorcontext.lookup(selectorcontext.java:157) @ javax.naming.initialcontext.lookup(initialcontext.java:417) @ com.hm.vigil.platform.db.databaseconnectionmanager.<init>(databaseconnectionmanager.java:40) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method)
the server.xml
<server port="8005" shutdown="shutdown"> <listener classname="org.apache.catalina.startup.versionloggerlistener" /> <!-- security listener. documentation @ /docs/config/listeners.html <listener classname="org.apache.catalina.security.securitylistener" /> --> <!--apr library loader. documentation @ /docs/apr.html --> <listener classname="org.apache.catalina.core.aprlifecyclelistener" sslengine="on" /> <!-- prevent memory leaks due 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 @ /docs/jndi-resources-howto.html --> <globalnamingresources> <!-- editable user database can used userdatabaserealm authenticate users --> <resource name="userdatabase" auth="container" type="org.apache.catalina.userdatabase" description="user database can updated , 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> <!-- "service" collection of 1 or more "connectors" share single "container" note: "service" not "container", may not define subcomponents such "valves" @ level. documentation @ /docs/config/service.html --> <service name="catalina"> <!--the connectors can use shared executor, can define 1 or more named thread pools--> <!-- <executor name="tomcatthreadpool" nameprefix="catalina-exec-" maxthreads="150" minsparethreads="4"/> --> <!-- "connector" represents endpoint requests received , responses returned. documentation @ : 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 non-ssl/tls http/1.1 connector on port 8080 --> <connector port="8080" protocol="http/1.1" connectiontimeout="20000" redirectport="8443" /> <!-- "connector" using shared thread pool--> <!-- <connector executor="tomcatthreadpool" port="8080" protocol="http/1.1" connectiontimeout="20000" redirectport="8443" /> --> <!-- define ssl/tls http/1.1 connector on port 8443 connector uses nio implementation requires jsse style configuration. when using apr/native implementation, openssl style configuration required described in 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 ajp 1.3 connector on port 8009 --> <connector port="8009" protocol="ajp/1.3" redirectport="8443" /> <!-- engine represents entry point (within catalina) processes every request. engine implementation tomcat stand alone analyzes http headers included request, , passes them on appropriate host (virtual host). documentation @ /docs/config/engine.html --> <!-- should set jvmroute support load-balancing via ajp ie : <engine name="catalina" defaulthost="localhost" jvmroute="jvm1"> --> <engine name="catalina" defaulthost="localhost"> <!--for clustering, please take @ documentation at: /docs/cluster-howto.html (simple how to) /docs/config/cluster.html (reference documentation) --> <cluster classname="org.apache.catalina.ha.tcp.simpletcpcluster"/> <!-- use lockoutrealm prevent attempts guess user passwords via brute-force attack --> <realm classname="org.apache.catalina.realm.lockoutrealm"> <!-- realm uses userdatabase configured in global jndi resources under key "userdatabase". edits performed against userdatabase available use 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 example. documentation at: /docs/config/valve.html note: pattern used equivalent 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>
the context.xml
<context> <!-- default set of monitored resources. if 1 of these changes, --> <!-- web application 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 disable session persistence across tomcat restarts --> <manager pathname="" /> <!-- uncomment enable comet connection tacking (provides events on session expiration webapp lifecycle) --> <!-- <valve classname="org.apache.catalina.valves.cometconnectionmanagervalve" /> --> </context>
thanks
i shall post findings above problems.
the problem one/more of resources have internal reference resource bound jndi tree. during creation of resources attempt made other resources resolve jndi tree common resource. now, @ tis time of context loading jndi tree context not exist, above error.
the way round declare factory method on common resource , other resources reference common resource through factory method.
so, general principal, feel, resources must not resolve other resources jndi.
Comments
Post a Comment