File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes JNDI lookup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "JNDI lookup" Watch "JNDI lookup" New topic
Author

JNDI lookup

N Goldsmith
Greenhorn

Joined: May 18, 2004
Posts: 22
We have a custom JNDI lookup (Tomcat 5.0) that finds a global object that all of our servlets share. I've got everything configured, except when I go to do a lookup, it is unable to find my JNDI factory.

I think my problem is the definition of my factory in my server.xml. I added it to
<!-- Global JNDI resources -->
<GlobalNamingResources>

It looks like the following:
<Resource name="bean/SocketFactory" auth="Container"
type="com.mycompany.SocketServer">
</Resource>
<ResourceParams name="bean/SocketFactory">
<parameter>
<name>factory</name>
<value>com.mycompany.SocketFactory</value>
</parameter>
</ResourceParams>

My lookup looks like this:
try{
initCtx = new InitialContext();
envCtx = (Context) initCtx.lookup("java:/comp/env");
ss = (SocketServer) envCtx.lookup("bean/SocketFactory");
}catch(NamingException e){
writer.println(e.getMessage());
}

The exception keeps coming back with "Cannot create resource Instance" when I attempt the lookup.

My concern is the server.xml is setup incorrectly. Any ideas?

thanks
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
I'm a little unfamiliar (well, completely unfamiliar really) with JavaBean factories, but if you post a stacktrace, it might help me and some others help you out more.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
N Goldsmith
Greenhorn

Joined: May 18, 2004
Posts: 22
ah, thanks. I got it working. Sorry about not replying sooner.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JNDI lookup