You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Allistair Crossley <Al...@QAS.com> on 2003/12/17 12:03:17 UTC

JNDI Error / Servlet Error / Tomcat Admin Error !!!

Hi Guys,

I am tring to use JNDI for an SQL Server database in my Struts/Tomcat 5.0.16 application. The fact is that this has been working until today where I added a few new actions that do not even use the database and yet for some reason mayhem has ensued.

I am using a Servlet that has a load on startup true. In this servlet's init I am callinga method to lookup the resource

    
            try {
                Context ctx = new InitialContext();
                dataSource = (DataSource) ctx.lookup("java:comp/env/jdbc/iqdb");

                if (dataSource == null) {
                    logger.error("initDataSource: database pool was null");
                    throw new ServletException("The database could not be loaded.");
                }
            } catch (NamingException nE) {
                logger.error("initDataSource: " + nE.getMessage());
                throw new ServletException("The database could not be loaded.");
            }

When i boot up Tomcat it manages to find the data source and connections can be obtianed from it. However using the new actions that I created (which I have basically cut all the code out so that they merely "exist" and do nothing) causes my Servlet to re initialise!!!

Why on earth is my init() being called again anyway?

And to add insult to injury I now get

2003-12-17 11:00:00 StandardWrapperValve[iqController]: Allocate exception for servlet iqController

At throws this on another method called by init() that calls

dataSource.getConnection()

And one last thing...I though I would check out the Tomcat Admin app to see if anything was up with my server.xml and it cannot show my resource to the data source ... it throws

javax.servlet.ServletException: Exception retrieving attribute 'driverClassName'
	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
	admin.resources.listDataSources_jsp._jspService(listDataSources_jsp.java:429)

And even removing the whole block out of my server.xml so there is no JNDI resource still  does not stop this error above from occuring

I don't really know where to start with all these issues. I am sure they are all related.


<FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE> 
-------------------------------------------------------
QAS Ltd.
Developers of QuickAddress Software
<a href="http://www.qas.com">www.qas.com</a>
Registered in England: No 2582055
Registered in Australia: No 082 851 474
-------------------------------------------------------
</FONT>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org