File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Creating A File Resource Using Tomcat JNDI    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Creating A File Resource Using Tomcat JNDI    " Watch "Creating A File Resource Using Tomcat JNDI    " New topic

Creating A File Resource Using Tomcat JNDI

Jaz Chana
Ranch Hand

Joined: Feb 19, 2008
Posts: 34
Hi guys,

My problem is that I am creating a web service and I cannot get to a properties file without creating an absolute reference to that file. If I was creating a servlet I would simple use getServletContext() method to get a relative reference to it. However since it is an axis web service i have to deploy my applications in the WEB-INF/services directory, and because it does not interact with the axis servlet I cannot use getServletContext(). So i thought I could create a JNDI file resource reference in the tomcatHome/conf/context.xml file, similar to how I created a JNDI connection pool. The resouce definition looks like this;

now I tried to access the resource in my code like this;

However I get a NamingException; 'Cannot create resource instance'

I don't understand why I cant create a file resource in JNDI, it seems like a simple enough thing to do. Am I doing something wrong or missing something? Any help would be greatly appreciated.

[ October 07, 2008: Message edited by: Jaz Chana ]
jQuery in Action, 2nd edition
subject: Creating A File Resource Using Tomcat JNDI
Similar Threads
Accessing a file under WEB-INF using getResource()
Problem with service-ref & jndi
regarding JNDI
Reading external XML file from an Axis Web Service
Deploying a servlet to a Tomcat server I don't own