I'm trying to use JNDI. I followed the JNDI HOWTO on the Tomcat web site, but
I'm getting errors. This is the error message I'm getting.
javax.naming.NamingException: Cannot create resource instance
at
org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:167)
at
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:299)
at org.apache.naming.NamingContext.lookup(NamingContext.java:835)
at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
at lms.core.page.Page.<init>(Page.java:44)
at java.lang.Class.newInstance0(Native Method)
--Page.java (snippet)
public Page()
{
try
{
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
this.setImageServer( (Server)envCtx.lookup( "server/Image" ) );
}
catch( NamingException e)
{
e.printStackTrace( System.err );
}
}
--server.xml
<Context path="/lms" docBase="lms" debug="3" reloadable="true"
crossContext="true">
(snip)
<Resource name="server/Image" auth="Container"
type="lms.core.Server"/>
<ResourceParams name="server/Image">
<parameter>
<name>hostname</name>
<value>localhost</value>
</parameter>
<parameter>
<name>port</name>
<value>80</value>
</parameter>
</ResourceParams>
</Context>
--web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<resource-env-ref>
<description>
Default image server
</description>
<resource-env-ref-name>
server/Image
</resource-env-ref-name>
<resource-env-ref-type>
lms.core.Server
</resource-env-ref-type>
</resource-env-ref>
</web-app>
lms.core.Server is just a bean with two attributes and operators to set and
get them. Very basic.
Now for some debug info. When I start the server I get the following message.
So it's finding it.
XmlMapper: org.apache.catalina.core.StandardContext.addResourceEnvRef(
server/Image, lms.core.Server)
However I also get:
2002-09-01 20:22:14 StandardContext[/lms]: Bind naming operation failed :
javax.naming.NamingException: Name Image is already bound in this Context
What else should I look for?
Thanks,
John
--
John Walstra
[EMAIL PROTECTED]
Workers of the world, arise! You have nothing to lose but your chairs.
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>