Thursday, May 10, 2007

Today I am working with tomcat trying to create a dao using jndi and then writing a test. For those of you that don't know this Tomcat does not allow access from outside the container to the jndi in the way that JBoss does. In order to do this you will need to use a third party tool like Simple-jndi and can be found at:

Fairly simple to use for the most part add it into your project classpath, and set up your jndi for Tomcat in the way the doc says. To make it work correctly you will need to create a few folders and files. One of which is a file. Add the following into this file.

The last line is very important to keep just like it is. If you get the following error when trying to connect this is probably where your issue is.

at com.yourcompany.util.ServiceLocator.......

Also I am using eclipse and in the root of my project I created a folder I created a folder structure that looks like this [project root]/config/jdbc/

Within that folder I then place a properties file named [jndiName].properties The jndiName is important because Simple-jndi uses the name to look up the properties file. Also for jdbc structure it is important to have the folder structure setup the way I have shown above to ensure it works correctly.

Have fun and it actually works very slick!

No comments: