Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI lookup

 
N Goldsmith
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
N Goldsmith
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ah, thanks. I got it working. Sorry about not replying sooner.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic