Pool de Conexão Tomcat

Fala Galera,

sou novato em java e estou tentando seguir um tutorial para criar um pool de conexões no tomcat e busca-lo com jndi só que estou me deparando com um NullPointerException pelo que diz meu log de erro no tomca e não consigo achar uma soluçao para o problema, o código e o stacktrace seguem abaixo:

context.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/TesteJndi" auth="Container">
    <ResourceLink
        name="jdbc/testeThiago"
        type="javax.sql.DataSource"
        url="jdbc:mysql://localhost:3306/testesThiago"
        driverClassName="com.mysql.jdbc.Driver"
        username="root"
        password="isquare"
        maxActive="300"
        maxIdle="30"
        />
</Context>

web.xml

    <resource-ref>
        <res-ref-name>jdbc/testeThiago</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

ServiceLocator

[code]
public class ServiceLocator {
public static Connection getConexao() throws Exception {
Connection conn = null;
try {
Context initCtx = new InitialContext();
DataSource ds =(DataSource)initCtx.lookup(“java:comp/env/jdbc/testeThiago”);
// ou
// Context envContext = (Context)initCtx.lookup(“java:comp/env”);
// DataSource ds = (DataSource) envContext.lookup(“jdbc/postgres”);
try {
conn = ds.getConnection();
} catch (SQLException e1) {
System.out.println(“ERRO: Nao conseguiu conectar”);
}
} catch (NamingException e) {
System.out.println(“Falha ao conectar”);
}
return conn;
}
}

meu arquivo para poder fazer o teste

public class ServiceLocator {
    public static Connection getConexao() throws Exception {
        Connection conn = null;
         try {
                Context initCtx = new InitialContext();
                DataSource ds =(DataSource)initCtx.lookup("java:comp/env/jdbc/testeThiago");
                // ou
                // Context envContext = (Context)initCtx.lookup("java:comp/env");
                // DataSource ds = (DataSource) envContext.lookup("jdbc/postgres");
                try {
                    conn = ds.getConnection();
                } catch (SQLException e1) {
                    System.out.println("ERRO: Nao conseguiu conectar");
                }
            } catch (NamingException e) {
                System.out.println("Falha ao conectar");
            }
        return conn;
    }
}

e enfm o stacktrace do erro

10/05/2011 14:12:28 org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
        at com.testejndi.teste.testeJndi.processRequest(testeJndi.java:53)
        at com.testejndi.teste.testeJndi.doGet(testeJndi.java:77)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
        at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:706)
        at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:677)
        at org.apache.jsp.index_jsp._jspService(index_jsp.java:54)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
        at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
        at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
        at java.lang.Thread.run(Thread.java:662)

pelo que entendi foi lançada um NullPointerException quando é tentado executar a linha
conn = ds.getConnection();
mas não encontrei uma solução ainda, se alguem souber e puder me dar uma luz, agradeço desde já

Att,

Tenta o seu assim:

context.xml

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;Context auth="Container"&gt; &lt;Resource name="jdbc/testeThiago" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/testesThiago" driverClassName="com.mysql.jdbc.Driver" username="root" password="isquare" maxActive="300" maxIdle="30" /&gt; &lt;/Context&gt;

fala,

tentei desse jeito mas continuo com erros, e código era para exibir uma lista de livros para um teste mas nada acontece ainda e percebi esse problema agora em outra guia do netbenas para o tomcat

GRAVE: Error starting static Resources
java.lang.IllegalArgumentException: Document base C:\Users\Thiago\Documents\TesteHibernateJsf\build\web does not exist or is not a readable directory
        at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:142)
        at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4086)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4255)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
        at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:519)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)