Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 363691

Summary: SQLDataSource for libraries
Product: z_Archived Reporter: Chris Houben <cho>
Component: EDTAssignee: Joseph Vincens <jvincens>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: chenzhh, jspadea, svihovec, xiaobinc
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Chris Houben CLA 2011-11-14 06:13:24 EST
Build Identifier: 20110916-0149 (nighly build)

I turned off javascript generation for my libraries, to use SQL statements in them.
But I have to init my SQLDataSource in every function, otherwise I get in debug:
A null value was used.
java.lang.NullPointerException
	at libraries.customerLib.getCustomerList(customerLib.java:64)
	at server.progtest.main(progtest.java:39)
	at org.eclipse.edt.javart.resources.RunUnitBase.start(RunUnitBase.java:244)
	at server.progtest.main(progtest.java:22)
	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.edt.javart.ide.MainProgramLauncher.main(MainProgramLauncher.java:68)

In Programs, this is not an issue.

Reproducible: Always

Steps to Reproduce:
code example that gives error:
library customerLib
	
//	//connUrl string = "jdbc:derby:NewDerby;create=true;";

	myCustomers CUSTOMER[]{};
	myCustomer CUSTOMER;
	rs SQLResultSet?;
	ds SQLDataSource?{@resource{bindingkey = "NewDerby"}};
	
	function getCustomerList() returns(CUSTOMER[]);
	//connUrl string = "jdbc:derby:NewDerby;create=true;";
	
		open rs from ds with #sql{select * from egl.customer order by customer_id};
		
		while (rs.setNext())
			get myCustomer from rs;
			myCustomers.appendElement(myCustomer);			
		end
		return(myCustomers);
	end	
end

code example that runs OK:
library customerLib
	
//	//connUrl string = "jdbc:derby:NewDerby;create=true;";

	myCustomers CUSTOMER[]{};
	myCustomer CUSTOMER;
	rs SQLResultSet?;
	
	
	function getCustomerList() returns(CUSTOMER[]);
	//connUrl string = "jdbc:derby:NewDerby;create=true;";
		ds SQLDataSource?{@resource{bindingkey = "NewDerby"}};
		open rs from ds with #sql{select * from egl.customer order by customer_id};
		
		while (rs.setNext())
			get myCustomer from rs;
			myCustomers.appendElement(myCustomer);			
		end
		return(myCustomers);
	end	
end
Comment 1 Brian Svihovec CLA 2011-11-14 16:43:58 EST
Just to clarify, is the Library being used from a part that is generated to Java or a part that is generated to JavaScript?
Comment 2 Chris Houben CLA 2011-11-14 17:32:17 EST
(In reply to comment #1)
> Just to clarify, is the Library being used from a part that is generated to
> Java or a part that is generated to JavaScript?

It is used by a little testprogram generated to java & javascript:
program test type BasicProgram {}
	function main()
		customer CUSTOMER[]{} = customerLib.getCustomerList();
	end
end


The java statement that gives the error:
java.sql.PreparedStatement ezeStatement = (java.sql.PreparedStatement)ds.getStatement("libraries.customerLib", 0);
Comment 3 Justin Spadea CLA 2011-11-14 17:38:51 EST
This is a JavaGen problem, not a debug problem. It is not generating anything for the @Resource annotation when it's used on a global field in a library.
Comment 4 Lisa Lasher CLA 2011-11-16 16:07:51 EST
Joe, this is still a candidate for 070 ,if it can be fixed on Monday 11/21.  Let Brian know what you think.
Comment 5 Joseph Vincens CLA 2011-11-21 12:53:23 EST
*** Bug 364263 has been marked as a duplicate of this bug. ***
Comment 6 Joseph Vincens CLA 2011-11-21 16:21:13 EST
fixed