Erro ao tentar acessar DATASOURCE....NULLPOINTER

Olá pessoal,

não consigo crar um Data Source no TOMCAT com o nome java:comp/env/jdbc/local

dá erro .

Então criei com o nome local mas não encontra e retorna com erro java.lang.NullPointerException

alguem poderia me ajudar …abs


public class ServiceLocator {

   
	private final static String POOLING_NAME = "local";
	private final static String DRIVER_NAME = "com.mysql.jdbc.Driver";
	private final static String DB_URL = "jdbc:mysql://localhost:3306/prova";
    private final static String DB_USER_NAME = "root";
	private final static String DB_PASSWORD = "pa";
	private boolean usePool = true;

	private static InitialContext initCtx = null;
	
	private static ServiceLocator instance = new ServiceLocator();
		public static ServiceLocator getInstance() {
		return instance;
	}
	
	  public Connection getConnection() throws Exception {
	        if (usePool) {
	        	System.out.println("pool");
	            return getConnectionByPool();
	        } else {
	        	System.out.println("manual");
	            return getConnectionManual();
	        }
	    }

	  public Connection getConnectionManual() throws Exception {
		  Connection conn = null;
			try {
				Class.forName(DRIVER_NAME);
				conn=DriverManager.getConnection(DB_URL,DB_USER_NAME,DB_PASSWORD);
				System.out.println("Conexão Aberta !!!");
			} catch (Exception e) {
				System.out.println("Conexão Não Aberta !!!");
				e.printStackTrace();
			}
			return conn;
	    }

    public Connection getConnectionByPool() throws Exception {
        Connection conn = null;
        DataSource ds = null;
        try {
            if (initCtx == null) {
                initCtx = new InitialContext();
            }
            ds = (DataSource) initCtx.lookup(POOLING_NAME);
            conn = ds.getConnection();
            System.out.println("Conexao Aberta");
        } catch (Exception e) {
            throw new Exception("Erro ao obter conexao via JNDI: " 
                    + POOLING_NAME, e);
        }
        return conn;
    }
    public void setUsePool(boolean usePool) {
        this.usePool = usePool;
    }

}

----
04/07/2008 12:21:21 org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
	at org.apache.jsp.pagina.erro_jsp._jspService(erro_jsp.java:60)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:679)
	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:461)
	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:399)
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
	at br.com.paulo.prova.servlet.ServletAction.service(ServletAction.java:30)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
	at java.lang.Thread.run(Unknown Source)
Erro=org.apache.jasper.JasperException
04/07/2008 12:21:29 org.apache.catalina.core.ApplicationDispatcher 

paribe,

Em qual arquivo de configuração você declarou a conexão?
Como está a propriedade name do resource da conexão no seu arquivo de configuração?