This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 237978 - NPE problem when submitting a query to an MDR developed with the toolkit.
Summary: NPE problem when submitting a query to an MDR developed with the toolkit.
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Cosmos (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P1 normal (vote)
Target Milestone: ---   Edit
Assignee: Sheldon Lee-Loy CLA
QA Contact:
URL:
Whiteboard: toolkit
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-20 15:09 EDT by Sheldon Lee-Loy CLA
Modified: 2012-01-03 13:54 EST (History)
1 user (show)

See Also:


Attachments
Screen shot showing error (266.16 KB, image/jpeg)
2008-06-20 15:11 EDT, Sheldon Lee-Loy CLA
no flags Details
patch that fixes the bug (6.78 KB, patch)
2008-08-27 09:29 EDT, Sheldon Lee-Loy CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sheldon Lee-Loy CLA 2008-06-20 15:09:37 EDT
I created an MDR by following the steps outlined under http://cmdbf.org/schema/1-0-0/datamodel

I then run the MDR on the apache server.  This will bring up the COSMOS UI in the internal browser.  

The MDR is shown in the navigation tree.  At this point I submit the following query.

<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright (c) 2007 IBM Corporation.
 All rights reserved.   This program and the accompanying materials
 are made available under the terms of the Eclipse Public License v1.0
 which accompanies this distribution, and is available at
 http://www.eclipse.org/legal/epl-v10.html
 
 Contributors: 
 IBM - Initial API and implementation
-->

<!-- This query selects all students -->
<s:query xmlns:s="http://cmdbf.org/schema/1-0-0/datamodel">
	<s:itemTemplate id="items">
		<s:recordConstraint>
			<s:recordType namespace="" localName="student"/>			
		</s:recordConstraint>
	</s:itemTemplate>
</s:query>


Afterwards I get the following exception:

[ERROR] CSMS0118E Error occurred while executing operation.  Incoming SOAP message is: 
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><s:query xmlns:s="http://cmdbf.org/schema/1-0-0/datamodel">
	<s:itemTemplate id="items">
		<s:recordConstraint>
			<s:recordType localName="student" namespace="" />			
		</s:recordConstraint>
	</s:itemTemplate>
</s:query></soapenv:Body></soapenv:Envelope>
java.lang.NullPointerException
	at org.eclipse.cosmos.dc.provisional.cmdbf.services.query.service.impl.CMDBfQueryOperation.processItemTemplates(CMDBfQueryOperation.java:165)
	at org.eclipse.cosmos.dc.provisional.cmdbf.services.query.service.impl.CMDBfQueryOperation.execute(CMDBfQueryOperation.java:135)
	at org.eclipse.cosmos.dc.provisional.cmdbf.services.query.service.impl.CMDBfQueryOperation.execute(CMDBfQueryOperation.java:122)
	at org.eclipse.cosmos.dc.provisional.cmdbf.query.AbstractQueryService.GraphQuery(AbstractQueryService.java:81)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.cosmos.dc.provisional.cmdbf.receiver.CosmosMessageReceiver.invokeBusinessLogic(CosmosMessageReceiver.java:134)
	at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
	at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:96)
	at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)
	at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
	at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:120)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
	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:151)
	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)
Comment 1 Sheldon Lee-Loy CLA 2008-06-20 15:11:33 EDT
Created attachment 105537 [details]
Screen shot showing error
Comment 2 Sheldon Lee-Loy CLA 2008-08-25 18:39:03 EDT
I traced the problem and found out that it may not be a bug.  The NPE is due to the fact that the generated code for the QueryHandlerFactory contains methods that return null.

	protected IItemTemplateHandler createItemHandler() throws CMDBfServiceException
	{
		return null;
	}

I suppose the developer should implement this method before trying to submit a query.

David can you comment on this?
Comment 3 David Whiteman CLA 2008-08-26 09:09:24 EDT
That must mean we need to generate more code.  For some reason when I implemented it, I had thought I only needed to implement the one method, but apparently the framework ends up calling this method as well.  

I think we need to do one of two things here... either we need to change the toolkit so that it generates the minimum necessary for this method as well, or we should change the framework to be able to more gracefully handle a null being returned.
Comment 4 Sheldon Lee-Loy CLA 2008-08-26 10:22:11 EDT
(In reply to comment #3)

The generated code could throw a message exception instead of returning null such as throwing "method not implemented" exception.  This is similar to what the abstract class is doing

throw unsupportedHandler(IQueryTransformerConstants.RECORD_CONSTRAINT_ELEMENT);

If we do this then AbstractQueryHandlerFactory.unsupportedHandler has to be protected instead of private.
Comment 5 Sheldon Lee-Loy CLA 2008-08-26 17:05:41 EDT
Added default implementation for the QueryHandlerFactory methods.  The methods return "Hello World" records.    This will allow the user to submit a query and see a simple item in the COSMOS UI.
Comment 6 Sheldon Lee-Loy CLA 2008-08-27 09:29:57 EDT
Created attachment 111066 [details]
patch that fixes the bug
Comment 7 David Whiteman CLA 2008-10-15 16:39:45 EDT
Sheldon, why did you mark that patch for the IPLog?  I had thought we only needed to do that if the person attaching the patch was not a committer at the time.
Comment 8 David Whiteman CLA 2008-11-05 14:58:15 EST
closing to cleanup bugzilla