Hello everyone,
I was wondering if anyone had success with JNDI functionality
under Tomcat 4.0, because I'm desperate. The only thing I would
like to do is have a bean initialized and populated with values taken
from server.xml file and as respond I always get:
javax.naming.NamingException: Cannot create resource instance
Here is my configuration:
web.xml:
<resource-env-ref>
<resource-env-ref-name>
bean/ConfirurationBean
</resource-env-ref-name>
<resource-env-ref-type>
com.upsideweb.wis.web.ConfigurationBean
</resource-env-ref-type>
</resource-env-ref>
server.xml:
<Host name="value" appBase="webapps" unpackWARs="true" debug="1">
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="value" prefix="value" suffix=".txt"
pattern="combined" resolveHosts="true"/>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="value" prefix="value" suffix=".txt"
timestamp="true"/>
<Context path="" docBase="/value" debug="1"
reloadable="true">
<Resource name="bean/ConfigurationBean"
type="com.ConfigurationBean"/>
<ResourceParams name="bean/ConfirurationBean">
<parameter>
<name>bannerFileLocation</name>
<value>banners.xml</value>
</parameter>
</ResourceParams>
</Context>
</Host>
In a custom tag I have a code like this:
try {
Context initialContext = new InitialContext();
ConfigurationBean confBean =
(ConfigurationBean)
initialContext.lookup("java:comp/env/bean/ConfigurationBean");
fileLocation = confBean.getBannerFileLocation();
} catch (NamingException e) {
e.printStackTrace();
}
In the second line of try block I always get an exception.
Propably I'm missing something but so far I have no clue
exactly what.
Thank you for your time.
Best of luck,
Yuriy Zubarev