db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff cox" <J...@cwindustries.net>
Subject NullPointerException ond doSelect
Date Tue, 01 Apr 2003 18:32:39 GMT
Hi,
	I have been trying to get torque running for hours with no luck.
I have scoured the mailing lists to try an figure out what is going on,
but whatI find is that getting a NullPointerException like this can be
the result of any number of things. What I have tried is:

1) I have tried numerous changes in the Torque.properties file. I have
use the "old" pool, I have tried and am currently set up using the
jdbc2pool.

2) I have changed my project-schema.xml file to identify a name, and use
default in the Torque.properties file.

3) I have checked and re-checked that the Torque.properties file has in
fact been loaded.

4) I have changed database password so as to rule out "funky"
characters.

5) I have verified that the postgresql server can be connected to via
jdbc (using an outside source)


Is there any way to determine what is going on behind the scenes with
the database connection? All I get is that the connection object is
null. If the connection failed where is the reason for failure? Is that
accessible? Any help would be greatly appreciated...

jeff


---- Error received ----

Apr 1, 2003 1:09:39 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on port 8080
281 [Thread-4] DEBUG dsfactory.Jdbc2PoolDataSourceFactory  - Starting
initTorqueClassic
313 [Thread-4] DEBUG dsfactory.Jdbc2PoolDataSourceFactory  - Setting
datasource property: defaultMaxActive
328 [Thread-4] DEBUG dsfactory.Jdbc2PoolDataSourceFactory  - Setting
datasource property: testOnBorrow
328 [Thread-4] DEBUG dsfactory.Jdbc2PoolDataSourceFactory  - Setting
datasource property: validationQuery
516 [Thread-7] DEBUG oid.IDBroker  - IDBroker thread was started.
594 [Thread-4] WARN oid.IDBroker  - IDBroker is being used with db
'default', which does not support transactions. IDBroker attempts to use
transactions to limit the possibility of duplicate key generation.
Without transactions, duplicate key generation is possible if multiple
JVMs are used or other means are used to write to the database.
StandardWrapperValve[camp_planner]: Servlet.service() for servlet
camp_planner threw exception
java.lang.NullPointerException: Connection object was null. This could
be due to a misconfiguration of the DataSourceFactory. Check the logs
and Torque.properties to better determine the cause.
java.lang.NullPointerException: Connection object was null. This could
be due to a misconfiguration of the DataSourceFactory. Check the logs
and Torque.properties to better determine the cause.
	at
org.apache.torque.util.Transaction.rollback(Transaction.java:179)
	at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1333)
	at
net.cwindustries.casc.core.BaseCASC_ERRORPeer.doSelectVillageRecords(Bas
eCASC_ERRORPeer.java:364)
	at
net.cwindustries.casc.core.BaseCASC_ERRORPeer.doSelectVillageRecords(Bas
eCASC_ERRORPeer.java:331)
	at
net.cwindustries.casc.core.BaseCASC_ERRORPeer.doSelect(BaseCASC_ERRORPee
r.java:300)
	at
net.cwindustries.casc.servlet.CAMP_PLANNER.errorResponse(CAMP_PLANNER.ja
va:167)
	at
net.cwindustries.casc.servlet.CAMP_PLANNER.doGet(CAMP_PLANNER.java:65)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:247)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:193)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
e.java:260)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.java:191)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:239
6)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:180)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherVa
lve.java:170)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:172)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:641)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
java:174)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
nvokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
80)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:40
5)
	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC
onnection(Http11Protocol.java:380)
	at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:50
8)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
.java:533)
	at java.lang.Thread.run(Thread.java:536)
Stopping service Tomcat-Standalone
StandardHost[localhost]: Removing web application at context path 
WebappLoader[]: Error tracking modifications
java.lang.NullPointerException
java.lang.NullPointerException
	at java.lang.String.startsWith(String.java:1030)
	at java.lang.String.startsWith(String.java:1061)
	at
org.apache.naming.resources.FileDirContext.file(FileDirContext.java:893)
	at
org.apache.naming.resources.FileDirContext.getAttributes(FileDirContext.
java:487)
	at
org.apache.naming.resources.BaseDirContext.getAttributes(BaseDirContext.
java:797)
	at
org.apache.naming.resources.ProxyDirContext.revalidate(ProxyDirContext.j
ava:1430)
	at
org.apache.naming.resources.ProxyDirContext.cacheLookup(ProxyDirContext.
java:1391)
	at
org.apache.naming.resources.ProxyDirContext.getAttributes(ProxyDirContex
t.java:828)
	at
org.apache.catalina.loader.WebappClassLoader.modified(WebappClassLoader.
java:803)
	at
org.apache.catalina.loader.WebappLoader.run(WebappLoader.java:1348)
	at java.lang.Thread.run(Thread.java:536)

----- Torque.properties ----

torque.database.default = default
torque.database.default.adapter=postgresql

## Using Jdbc2Pool
torque.dsfactory.default.factory=org.apache.torque.dsfactory.Jdbc2PoolDa
taSourceFactory
torque.dsfactory.default.pool.defaultMaxActive=10
torque.dsfactory.default.pool.testOnBorrow=true
torque.dsfactory.default.pool.validationQuery=SELECT 1
torque.dsfactory.default.connection.driver = org.postgresql.Driver
torque.dsfactory.bookstore.connection.url =
jdbc:postgresql://mcgonagle.cwindustries.net:5432/RANSBURGBSA_DEV
torque.dsfactory.bookstore.connection.user = casc
torque.dsfactory.bookstore.connection.password = password

--- schema.xml ---

<!DOCTYPE database SYSTEM
"http://jakarta.apache.org/turbine/dtd/database_3_1.dtd">
<database defaultIdMethod="native">
	<table name="T_REQUIREMENT" javaName="REQUIREMENT">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="NAME" type="VARCHAR" size="50"/>
		<column name="DESCRIPTION" type="VARCHAR" size="255"/>
		<column name="ACTIVITY_ID" type="INTEGER"/>
		<foreign-key foreignTable="T_ACTIVITY">
			<reference local="ACTIVITY_ID" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_GROUP_MEMBER" javaName="GROUP_MEMBER">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="TITLE" type="VARCHAR" size="50"/>
		<column name="TYPE" type="INTEGER"/>
		<column name="LAST_NAME" type="VARCHAR" size="50"/>
		<column name="FIRST_NAME" type="VARCHAR" size="50"/>
		<column name="EMAIL" type="VARCHAR" size="150"/>
		<column name="GENDER" type="VARCHAR" size="1"/>
		<column name="ADDRESS_1" type="VARCHAR" size="255"/>
		<column name="ADDRESS_2" type="VARCHAR" size="255"/>
		<column name="CITY" type="VARCHAR" size="150"/>
		<column name="STATE" type="VARCHAR" size="2"/>
		<column name="ZIPCODE" type="INTEGER"/>
		<column name="HOME_PHONE" type="INTEGER"/>
		<column name="WORK_PHONE" type="INTEGER"/>
		<column name="ARRIVAL" type="DATE"/>
		<column name="DEPARTURE" type="DATE"/>
		<column name="RANK" type="INTEGER"/>
		<column name="GROUP_ID" type="INTEGER"/>
		<foreign-key foreignTable="T_GROUP">
			<reference local="GROUP_ID" foreign="ID"/>
		</foreign-key>
		<foreign-key foreignTable="T_MEMBER_TYPE">
			<reference local="TYPE" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_GROUP" javaName="GROUP">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="GROUP_NUMBER" type="INTEGER"/>
		<column name="TYPE" type="INTEGER"/>
		<column name="CITY_OF_ORIGIN" type="VARCHAR"
size="150"/>
		<column name="STATE_OF_ORIGIN" type="VARCHAR" size="2"/>
		<column name="DISTRICT_ID" type="INTEGER"/>
		<column name="SESSION_ID" type="INTEGER"/>
		<foreign-key foreignTable="T_DISTRICT">
			<reference local="DISTRICT_ID" foreign="ID"/>
		</foreign-key>
		<foreign-key foreignTable="T_CAMP_SESSION">
			<reference local="SESSION_ID" foreign="ID"/>
		</foreign-key>
		<foreign-key foreignTable="T_GROUP_TYPE">
			<reference local="TYPE" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_EQUIPMENT_REQUEST" javaName="EQUIPMENT_REQUEST">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="QUANTITY" type="INTEGER"/>
		<column name="GROUP_ID" type="INTEGER"/>
		<column name="ITEM_ID" type="INTEGER"/>
		<foreign-key foreignTable="T_GROUP">
			<reference local="GROUP_ID" foreign="ID"/>
		</foreign-key>
		<foreign-key foreignTable="T_EQUIPMENT_ITEM">
			<reference local="ITEM_ID" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_EQUIPMENT_ITEM" javaName="EQUIPMENT_ITEM">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="NAME" type="VARCHAR" size="150"/>
		<column name="TYPE" type="INTEGER"/>
		<column name="REQUESTABLE" type="BOOLEANINT"/>
		<column name="SEASON_ID" type="INTEGER"/>
		<foreign-key foreignTable="T_CAMP_SEASON">
			<reference local="SEASON_ID" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_DISTRICT" javaName="DISTRICT">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="NAME" type="VARCHAR" size="50"/>
		<column name="ABBREVIATION" type="VARCHAR" size="5"/>
		<column name="CITY" type="VARCHAR" size="150"/>
		<column name="STATE" type="VARCHAR" size="2"/>
		<column name="ZIPCODE" type="INTEGER"/>
		<column name="DISTRICT_EXECUTIVE" type="VARCHAR"
size="50"/>
		<column name="COUNCIL_ID" type="INTEGER"/>
		<foreign-key foreignTable="T_COUNCIL">
			<reference local="COUNCIL_ID" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_COUNCIL" javaName="COUNCIL">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="NAME" type="VARCHAR" size="50"/>
		<column name="ABBREVIATION" type="VARCHAR" size="5"/>
		<column name="ADDRESS" type="VARCHAR" size="150"/>
		<column name="CITY" type="VARCHAR" size="150"/>
		<column name="STATE" type="VARCHAR" size="2"/>
		<column name="ZIPCODE" type="INTEGER"/>
		<column name="SEASON_ID" type="INTEGER"/>
		<foreign-key foreignTable="T_CAMP_SEASON">
			<reference local="SEASON_ID" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_CASC_ERROR" javaName="CASC_ERROR">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="DESCRIPTION" type="VARCHAR" size="255"/>
	</table>
	<table name="T_CAMP_SESSION" javaName="CAMP_SESSION">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="NAME" type="VARCHAR" size="50"/>
		<column name="BEGIN_DATE" type="DATE"/>
		<column name="END_DATE" type="DATE"/>
		<column name="SEASON_ID" type="INTEGER"/>
		<foreign-key foreignTable="T_CAMP_SEASON">
			<reference local="SEASON_ID" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_CAMP_SEASON" javaName="CAMP_SEASON">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="NAME" type="VARCHAR" size="50"/>
		<column name="BEGIN_DATE" type="DATE"/>
		<column name="END_DATE" type="DATE"/>
		<column name="CAMP_ID" type="INTEGER"/>
		<foreign-key foreignTable="T_CAMP">
			<reference local="CAMP_ID" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_CAMP_LOCATION" javaName="CAMP_LOCATION">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="NAME" type="VARCHAR" size="50"/>
		<column name="CAMP_ID" type="INTEGER"/>
		<foreign-key foreignTable="T_CAMP">
			<reference local="CAMP_ID" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_CAMP_AREA" javaName="CAMP_AREA">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="NAME" type="VARCHAR" size="50"/>
		<column name="LOCATION_ID" type="INTEGER"/>
		<foreign-key foreignTable="T_CAMP_LOCATION">
			<reference local="LOCATION_ID" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_CAMP" javaName="CAMP">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="NAME" type="VARCHAR" size="50"/>
	</table>
	<table name="T_AUTHENTICATION" javaName="AUTHENTICATION">
		<column name="USERNAME" type="VARCHAR" size="8"
primaryKey="true" required="true"/>
		<column name="PASSWORD" type="VARCHAR" size="64"
primaryKey="true" required="true"/>
		<column name="GROUP_ID" type="INTEGER"/>
		<column name="SEASON_ID" type="INTEGER"/>
		<foreign-key foreignTable="T_GROUP">
			<reference local="GROUP_ID" foreign="ID"/>
		</foreign-key>
		<foreign-key foreignTable="T_CAMP_SEASON">
			<reference local="SEASON_ID" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_ACTIVITY_SECTION" javaName="ACTIVITY_SECTION">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="SUNDAY" type="BOOLEANINT"/>
		<column name="MONDAY" type="BOOLEANINT"/>
		<column name="TUESDAY" type="BOOLEANINT"/>
		<column name="WEDNESDAY" type="BOOLEANINT"/>
		<column name="THURSDAY" type="BOOLEANINT"/>
		<column name="FRIDAY" type="BOOLEANINT"/>
		<column name="SATURDAY" type="BOOLEANINT"/>
		<column name="START_TIME" type="TIME"/>
		<column name="END_TIME" type="TIME"/>
		<column name="MAX_SEATS" type="INTEGER"/>
		<column name="ACTIVITY_ID" type="INTEGER"/>
		<foreign-key foreignTable="T_ACTIVITY">
			<reference local="ACTIVITY_ID" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_ACTIVITY" javaName="ACTIVITY">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="NAME" type="VARCHAR" size="100"/>
		<column name="SESSION_ID" type="INTEGER"/>
		<foreign-key foreignTable="T_CAMP_SESSION">
			<reference local="SESSION_ID" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_ENROLLMENT" javaName="ENROLLMENT">
		<column name="SECTION_ID" type="INTEGER"
primaryKey="true" required="true"/>
		<column name="MEMBER_ID" type="INTEGER"
primaryKey="true" required="true"/>
		<foreign-key foreignTable="T_ACTIVITY_SECTION">
			<reference local="SECTION_ID" foreign="ID"/>
		</foreign-key>
		<foreign-key foreignTable="T_GROUP_MEMBER">
			<reference local="MEMBER_ID" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_AREA_EQUIPMENT" javaName="AREA_EQUIPMENT">
		<column name="AREA_ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="EQUIPMENT_ID" type="INTEGER"
primaryKey="true" required="true"/>
		<foreign-key foreignTable="T_CAMP_AREA">
			<reference local="AREA_ID" foreign="ID"/>
		</foreign-key>
		<foreign-key foreignTable="T_EQUIPMENT_ITEM">
			<reference local="EQUIPMENT_ID" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_GROUP_QUARTERS" javaName="GROUP_QUARTERS">
		<column name="AREA_ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="GROUP_ID" type="INTEGER" primaryKey="true"
required="true"/>
		<foreign-key foreignTable="T_CAMP_AREA">
			<reference local="AREA_ID" foreign="ID"/>
		</foreign-key>
		<foreign-key foreignTable="T_GROUP">
			<reference local="GROUP_ID" foreign="ID"/>
		</foreign-key>
	</table>
	<table name="T_MEMBER_TYPE" javaName="MEMBER_TYPE">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="TEXT" type="VARCHAR" size="50"/>
	</table>
	<table name="T_GROUP_TYPE" javaName="GROUP_TYPE">
		<column name="ID" type="INTEGER" primaryKey="true"
required="true"/>
		<column name="TEXT" type="VARCHAR" size="50"/>
	</table>
</database>

---- Code where Exception is thrown ---

	private static final String CONTENT_TYPE = "text/xml";
	private	PropertiesConfiguration CONFIG = new
PropertiesConfiguration();

	public void init()
		throws ServletException
	{
		try
		{
			ClassLoader theLoader =
this.getClass().getClassLoader();
	
CONFIG.load(theLoader.getResourceAsStream("/net/cwindustries/casc/core/T
orque.properties"));
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}

.
.
.
.

	private void errorResponse(String errorNum, HttpServletRequest
request,
	
HttpServletResponse response)
	{
		try
		{
			Torque.init(CONFIG);
			PrintWriter out = response.getWriter();
			Criteria crit = new Criteria();
			crit.add(CASC_ERRORPeer.ID, errorNum);
			List errorList = CASC_ERRORPeer.doSelect(crit);
			if (errorList != null)
			{
				CASC_ERROR error = (CASC_ERROR)
errorList.get(0);
				out.println(error.toXML());
			}
			else
			{
				String xmlResponse =
	
"<error><id>0</id><description>Unknown Error!</description></error>";
				out.println(xmlResponse);
			}
		}
		catch (TorqueException e)
		{
		    e.printStackTrace();
		}
		catch (IOException e)
		{
		    e.printStackTrace();
		}
	}



Mime
View raw message