• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

javax.naming.NameNotFoundException:Name comp is not bound in this Context

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am getting the following error:
Can anyone resolve my problem.

Feb 11, 2011 10:21:23 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\TortoiseSVN\bin
Feb 11, 2011 10:21:23 AM org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8008
Feb 11, 2011 10:21:23 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 357 ms
Feb 11, 2011 10:21:23 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Feb 11, 2011 10:21:23 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.17
Feb 11, 2011 10:21:23 AM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Feb 11, 2011 10:21:23 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Project\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\hrhelpdesk\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Feb 11, 2011 10:21:24 AM org.apache.commons.modeler.Registry registerComponent
SEVERE: Null component Catalina:type=DataSource,path=/hrhelpdesk,host=localhost,class=javax.sql.DataSource,name="jdbc/btt"
Feb 11, 2011 10:21:24 AM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8008
Feb 11, 2011 10:21:24 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Feb 11, 2011 10:21:24 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/31 config=null
Feb 11, 2011 10:21:24 AM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
Feb 11, 2011 10:21:24 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 511 ms
javax.naming.NameNotFoundException: Name java:comp is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:769)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.btt.bms.dal.DALBroker.<init>(DALBroker.java:114)
at com.btt.bms.dal.DALBroker.<clinit>(DALBroker.java:68)
at com.btt.bms.om.ObjectManager.getObject(ObjectManager.java:94)
at com.btt.bms.core.security.SecurityManager.isAuthorisedUserToLogon(SecurityManager.java:798)
at com.btt.bms.controller.Login.perform(Login.java:36)
at com.btt.bms.controller.Action.execute(Action.java:54)
at com.btt.bms.controller.HTTPController.doGet(HTTPController.java:184)
at com.btt.bms.controller.HTTPController.doPost(HTTPController.java:147)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
javax.naming.NameNotFoundException: Name java:comp is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:769)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.btt.bms.dal.DALBroker.getConnection(DALBroker.java:150)
at com.btt.bms.om.ObjectManager.getObject(ObjectManager.java:98)
at com.btt.bms.core.security.SecurityManager.isAuthorisedUserToLogon(SecurityManager.java:798)
at com.btt.bms.controller.Login.perform(Login.java:36)
at com.btt.bms.controller.Action.execute(Action.java:54)
at com.btt.bms.controller.HTTPController.doGet(HTTPController.java:184)
at com.btt.bms.controller.HTTPController.doPost(HTTPController.java:147)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
com.btt.bms.dal.DALException: Name java:comp is not bound in this Context
at com.btt.bms.dal.DALBroker.getConnection(DALBroker.java:162)
at com.btt.bms.om.ObjectManager.getObject(ObjectManager.java:98)
at com.btt.bms.core.security.SecurityManager.isAuthorisedUserToLogon(SecurityManager.java:798)
at com.btt.bms.controller.Login.perform(Login.java:36)
at com.btt.bms.controller.Action.execute(Action.java:54)
at com.btt.bms.controller.HTTPController.doGet(HTTPController.java:184)
at com.btt.bms.controller.HTTPController.doPost(HTTPController.java:147)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
javax.naming.NameNotFoundException: Name java:comp is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:769)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.btt.bms.dal.DALBroker.getConnection(DALBroker.java:150)
at com.btt.bms.om.ObjectManager.getObject(ObjectManager.java:98)
at com.btt.bms.core.security.SecurityManager.isAuthorisedUserToLogon(SecurityManager.java:798)
at com.btt.bms.controller.Login.perform(Login.java:36)
at com.btt.bms.controller.Action.execute(Action.java:54)
at com.btt.bms.controller.HTTPController.doGet(HTTPController.java:184)
at com.btt.bms.controller.HTTPController.doPost(HTTPController.java:147)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
com.btt.bms.dal.DALException: Name java:comp is not bound in this Context
at com.btt.bms.dal.DALBroker.getConnection(DALBroker.java:162)
at com.btt.bms.om.ObjectManager.getObject(ObjectManager.java:98)
at com.btt.bms.core.security.SecurityManager.isAuthorisedUserToLogon(SecurityManager.java:798)
at com.btt.bms.controller.Login.perform(Login.java:36)
at com.btt.bms.controller.Action.execute(Action.java:54)
at com.btt.bms.controller.HTTPController.doGet(HTTPController.java:184)
at com.btt.bms.controller.HTTPController.doPost(HTTPController.java:147)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
javax.naming.NameNotFoundException: Name java:comp is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:769)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.btt.bms.dal.DALBroker.getConnection(DALBroker.java:150)
at com.btt.bms.om.ObjectManager.getObject(ObjectManager.java:98)
at com.btt.bms.core.security.SecurityManager.isAuthorisedUserToLogon(SecurityManager.java:798)
at com.btt.bms.controller.Login.perform(Login.java:36)
at com.btt.bms.controller.Action.execute(Action.java:54)
at com.btt.bms.controller.HTTPController.doGet(HTTPController.java:184)
at com.btt.bms.controller.HTTPController.doPost(HTTPController.java:147)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
com.btt.bms.dal.DALException: Name java:comp is not bound in this Context
at com.btt.bms.dal.DALBroker.getConnection(DALBroker.java:162)
at com.btt.bms.om.ObjectManager.getObject(ObjectManager.java:98)
at com.btt.bms.core.security.SecurityManager.isAuthorisedUserToLogon(SecurityManager.java:798)
at com.btt.bms.controller.Login.perform(Login.java:36)
at com.btt.bms.controller.Action.execute(Action.java:54)
at com.btt.bms.controller.HTTPController.doGet(HTTPController.java:184)
at com.btt.bms.controller.HTTPController.doPost(HTTPController.java:147)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
javax.naming.NameNotFoundException: Name java:comp is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:769)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.btt.bms.dal.DALBroker.getConnection(DALBroker.java:150)
at com.btt.bms.om.ObjectManager.getObject(ObjectManager.java:98)
at com.btt.bms.core.security.SecurityManager.isAuthorisedUserToLogon(SecurityManager.java:798)
at com.btt.bms.controller.Login.perform(Login.java:36)
at com.btt.bms.controller.Action.execute(Action.java:54)
at com.btt.bms.controller.HTTPController.doGet(HTTPController.java:184)
at com.btt.bms.controller.HTTPController.doPost(HTTPController.java:147)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
com.btt.bms.dal.DALException: Name java:comp is not bound in this Context
at com.btt.bms.dal.DALBroker.getConnection(DALBroker.java:162)
at com.btt.bms.om.ObjectManager.getObject(ObjectManager.java:98)
at com.btt.bms.core.security.SecurityManager.isAuthorisedUserToLogon(SecurityManager.java:798)
at com.btt.bms.controller.Login.perform(Login.java:36)
at com.btt.bms.controller.Action.execute(Action.java:54)
at com.btt.bms.controller.HTTPController.doGet(HTTPController.java:184)
at com.btt.bms.controller.HTTPController.doPost(HTTPController.java:147)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)

Source Code:
--------------
context.xml
-------------
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/hrhelpdesk">
<Resource driverClassName="org.postgresql.Driver" maxActive="100" maxIdle="50" maxWait="5000" name="jdbc/btt" password="password" type="javax.sql.DataSource" url="jdbc:postgresql://127.0.0.1:5432/BTS" username="postgres"/>
<ResourceLink global="jdbc/btt" name="jdbc/btt" type="javax.sql.DataSource"/>
</Context>

web.xml
---------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>HTTPController</servlet-name>
<servlet-class>com.btt.bms.controller.HTTPController</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet>
<servlet-name>AJAXController</servlet-name>
<servlet-class>com.btt.bms.controller.AJAXController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HTTPController</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>AJAXController</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
<resource-ref>
<description>postgreSQL connection</description>
<res-ref-name>jdbc/btt</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>


DALBroker.java
-----------------
/*
* DALBroker.java
*
* Created on 25 feb 2004, 10:57
*/

package com.btt.bms.dal;

import javax.xml.parsers.*;
import org.xml.sax.*;
import org.w3c.dom.*;
import java.util.*;
import java.io.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
import java.net.URL;
import com.btt.bms.controller.*;
import com.btt.bms.util.Constants;

/**
*
*

Title: btt


*

Description: Bug Tracking Tool


*

Copyright: Copyright (c) 2004


*

Company: Magic Software Pvt Ltd


* @author Ajayk
* @version 1.0
*/

/** When an application starts only one instance of DALBroker class will be
* created, providing a global print of access to it. The Singleton pattern
* will be used to create an instance of DALbroker class. The instance will
* read the query.xml file. The query.xml file will contain all the queries
* that are required by the application to retrieve, insert, update and delete
* records. It also instantiate a collection having the mapping of DALQuery
* objects with query name.*/

public class DALBroker
{

/** File path of the queries.xml file
*/
String XMLQUERIESPATH = Constants.getConfigXMLPath()+"queries.xml";
/** File path of the queries.xml file
*/
String XMLOBJECTSPATH = Constants.getConfigXMLPath()+"objects.xml";

/** JNDI name for the data source
*/
final String JNDICONTEXT = "java:comp/env/jdbc/btt";

/** Map of query names and DALQuery objects.
*/
private HashMap _mapQueries = new HashMap();

/** Map of query names and DALQuery objects.
*/
private HashMap _mapObjects = new HashMap();

/** Datasource to the underlying RDBMS.
*/
private DataSource _objDataSource;

/** Single instance of the object to be used across the application.
*/
private final static DALBroker _objInstance = new DALBroker();

/**
* Creates new DalBroker object. It instantiates a map, which stores the
* mapping of the query name with the DALQueryobjects and also initiaizes
* the datasource, using JNDI, to the underlying RDBMS.
*
*/

private DALBroker()
{
try
{

XMLQUERIESPATH = Constants.getConfigXMLPath()+"queries.xml";

XMLOBJECTSPATH = Constants.getConfigXMLPath()+"objects.xml";
DocumentBuilderFactory objFactory = DocumentBuilderFactory.newInstance();
objFactory.setIgnoringElementContentWhitespace(true);
DocumentBuilder objDomBuilder = objFactory.newDocumentBuilder();

File objFile = new File(XMLOBJECTSPATH);

Document objDoc = objDomBuilder.parse(objFile);

Element objElement = objDoc.getDocumentElement();
NodeList objChildren = objElement.getElementsByTagName("object");
for (int i = 0; i < objChildren.getLength(); i++)
{
DALObject objObject = new DALObject(objChildren.item(i));
_mapObjects.put(objObject.getObjectName(), objObject);
}

//objFile = new File(strPath, XMLQUERIESPATH);
objFile = new File(XMLQUERIESPATH);
objDoc = objDomBuilder.parse(objFile);

objElement = objDoc.getDocumentElement();
objChildren = objElement.getElementsByTagName("query");
for (int i = 0; i < objChildren.getLength(); i++)
{
DALQuery objQuery = new DALQuery(objChildren.item(i), _mapObjects);
_mapQueries.put(objQuery.getQueryName(), objQuery);
}

Context objContext = new InitialContext();
_objDataSource = (DataSource) objContext.lookup(JNDICONTEXT);


}
catch (Exception e)
{
e.printStackTrace();
}
}

/** Fetches the single refrence to the global object to be shared throughout the
* application.
* @return DALBroker Refrence to a global instance of DALBroker class.
*/
public static DALBroker getInstance()
{
return _objInstance;
}

/** Initializes and returns a refrence to the underlying JDBC datasource.
*
* @throws DALException Thrown in case if there is an error in connecting to the datasource.
* @return Initialized DALConnection object.
*/
public DALConnection getConnection()
throws DALException
{
try
{
if(_objDataSource!= null)
{
return new DALConnection(_objDataSource.getConnection());
}
else
{
Context objContext = new InitialContext();
_objDataSource = (DataSource) objContext.lookup(JNDICONTEXT);
if(_objDataSource!= null)
{
return new DALConnection(_objDataSource.getConnection());
}
return null;
}
}
catch (Exception e)
{

e.printStackTrace();
throw new DALException(e.getMessage());
}
}

/** Retrieves the refrence to a DALQuery object form the initialized set.
* @param strQueryName Name of the query to retrieve.
* @throws QueryNotFoundException Thrown if the query was not found in the initialized query map.
* @return Refrence to the DALQquery object.
*
*/
public DALQuery getQuery(String strQueryName)
throws QueryNotFoundException
{

DALQuery objQuery = (DALQuery) _mapQueries.get(strQueryName);
if (objQuery == null)
{
throw new QueryNotFoundException("The query name was not found.");
}
else
{
return objQuery;
}
}


/** Retrieves the refrence to a DALObject object form the initialized set.
* @param strObjectName Name of the object to retrieve.
* @throws ObjectNotFoundException Thrown if the object was not found in the initialized object map.
* @return Refrence to the DALQObject object.
*
*/

public DALObject getObject(String strObjectName)
throws ObjectNotFoundException
{
DALObject objObject = (DALObject) _mapObjects.get(strObjectName);
if (objObject == null)
{
throw new ObjectNotFoundException("The object name was not found.");
}
else
{
return objObject;
}
}

/** Retrieves all the query names in th current context.
*
* @return Collection containing all the query names in the current context.
*/
public Collection getQueryNames()
{
return _mapQueries.keySet();
}

/** Retrieves all the object names in th current context.
*
* @return Collection containing all the object names in the current context.
*/
public Collection getObjectNames()
{
return _mapObjects.keySet();
}

/* public static void main(String args[])
{
}*/
}

DALConnection.java
----------------------
package com.btt.bms.dal;

import java.util.*;
import java.sql.*;

/**
*

Title: btt


*

Description: Bug Tracking Tool


*

Copyright: Copyright (c) 2004


*

Company: Magic Software Pvt Ltd


* @author Ajayk
* @version 1.0
*/
/** DALConnection class defines functions used to maintain a transaction and
* execute queries. All methods related to transaction are specified here such
* as BeginTransaction, CommitTransaction and RollBackTransaction. It also has
* a method called ExecuteQuery, which executes a query and returns a DALResultset
* object.*/
public class DALConnection {
/** connection to the data source.
*/
private Connection _objCon;

/** Creates a new instance of Class.
* @param objCon Connection to the datasource
*/
DALConnection(Connection objCon) {
_objCon = objCon;
}

/** It takes the field names and DALQuery object as a parameter and returns
* a DALResultset. The field names are the parameters required for the
* execution of parameterized query.
* @return DALResultSet object encapsulating the resultset obtained by
* executing the query.
* @param colParameters Collection of parameters
* @param objDALQuery Query to execute.
* @throws DALException Generic exception while executing the query.
*/
public synchronized DALResultSet executeQuery(DALQuery objDALQuery,Collection colParameters) throws DALException
{

try
{
String strSql;
ResultSet objResultSet = null;
PreparedStatement objStatement = null;
// Returns the sql parameterized query
strSql = objDALQuery.getSQL();

objStatement = _objCon.prepareStatement(strSql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);

if(strSql.indexOf("?") != -1 )
{
for(int i=0;i<colParameters.size ();i++)
{
Object objStParam = ((ArrayList)colParameters).get (i);
objStatement.setObject (i+1,objStParam);
}
/*Iterator objIterator = colParameters.iterator();
int iCount = 1;

while (objIterator.hasNext())
{
Object objParam = objIterator.next();
objStatement.setObject(iCount, objParam);
iCount++;
}*/
}

if (objDALQuery.getObjectNames().size() > 0 || objDALQuery.getAttributeNames().size() > 0)
{
objResultSet = objStatement.executeQuery();
}
else
{
objStatement.executeUpdate();
}

DALResultSet objDALResultSet = new DALResultSet(objResultSet, objDALQuery,
objStatement);
objStatement.clearParameters();
return objDALResultSet;
}
catch (Exception e) {
e.printStackTrace();

throw new DALException(e.getMessage());
}
}

public void execute(String strSql)throws DALException
{
try
{
Statement objStatement = null;
objStatement = _objCon.createStatement ();
objStatement.execute(strSql);
objStatement.close ();

}
catch(Exception e){e.printStackTrace ();}
finally
{
if(_objCon != null)
{
try
{
if(!_objCon.isClosed ())
{
_objCon.close ();

}
_objCon=null;
}
catch(Exception e1){e1.printStackTrace ();}
}
}
}

public void execute(String strSql, DALConnection objDALConnection)throws DALException
{
try
{
Statement objStatement = null;
objStatement = objDALConnection._objCon.createStatement ();
objStatement.execute(strSql);
objStatement.close ();

}
catch(Exception e){e.printStackTrace ();}
}


public double getQueryResultCount(String strCountQuery) throws Exception
{
Statement objStatement = null;
ResultSet objResultset = null;
try
{

objStatement = _objCon.createStatement ();
objResultset = objStatement.executeQuery (strCountQuery);
while (objResultset.next ())
{
return objResultset.getDouble (1);
}
}
catch(Exception e){e.printStackTrace ();}
finally
{
if(_objCon != null)
{
try
{
if(!_objCon.isClosed ())
{
_objCon.close ();

}
_objCon=null;
}
catch(Exception e1){e1.printStackTrace ();}
}
}
return 0;
}

/** Represents a point at which the data referenced by DAL Connection is
* logically and physically consistent. If errors are encountered, all data
* modifications made after the beginTransaction can be rolled back to
* return the data to this known state of consistency
* @throws DALException Generic exception while executing the query
*/
public void beginTransaction() throws DALException {
try {
_objCon.setAutoCommit(false);
}
catch (Exception e) {
e.printStackTrace();
throw new DALException(e.getMessage());
}
}

/** Makes all changes made since the previous commit/rollback permanent and
* releases any database locks currently held by the Connection
* @throws DALException Generic exception while executing the query
*/
public void commitTransaction() throws DALException {
try {
_objCon.commit();
}
catch (Exception e) {
e.printStackTrace();
throw new DALException(e.getMessage());
}
}

/** Drops all changes made since the previous commit/rollback and releases
* any database locks currently held by this Connection.
* @throws DALException Generic exception while executing the query
*/
public void rollbackTransaction() throws DALException {
try {
_objCon.rollback();
}
catch (Exception e) {
e.printStackTrace();
throw new DALException(e.getMessage());
}
}

/** Closes the underlying JDBC connection if it is open. DALConnection once closed
* cannot be reused.
* @throws DALException Generic exception while executing the query.
*/
public void close() throws DALException {
try {
if (_objCon != null) {
if(!_objCon.isClosed ())
{
_objCon.close();
}
_objCon = null;
}
}
catch (SQLException e) {
e.printStackTrace();
throw new DALException(e.getMessage());
}
}

/** finalization closes the underlying JDBC connection if it is open.
*/
protected void finalize() {
try {
close();
}
catch (DALException e) {
e.printStackTrace();
}
}

public void setTransactionIsolation(int iTransactionIsolation) throws SQLException
{
_objCon.setTransactionIsolation (iTransactionIsolation);
}
}

Regards,
Naveen.
 
Sheriff
Posts: 22082
113
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Off to the Tomcat forum with this thread!
 
Beauty is in the eye of the tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic