Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGL Development Tools » JDBC driver error message from EGL on Tomcat 6 on iSeries(Deploying the EGL tutorial to Tomcat on iSeries produces "cannot create JDBC driver..." message)
JDBC driver error message from EGL on Tomcat 6 on iSeries [message #919248] Fri, 21 September 2012 20:51 Go to next message
Jeffrey Gardner is currently offline Jeffrey GardnerFriend
Messages: 20
Registered: August 2012
Junior Member
Problem:
When the exported war file for the "Access a Database with EGL Rich UI" tutorial is deployed on Tomcat 6 on the iSeries, the following runtime error message is produced:

Failure: An exception occurred during a service call. Service:services.SQLService, Function:services.SQLService
Detail 1:
Detail 2:
Detail 3: Exception: SQLService, getAllPayments, SQLSTATE = , message = Cannot create JDBC driver of class '' for connect URL 'null': [sqlstate:null][sqlcode:0]


Background:
I worked back through the tutorial changing database access from the Derby database to the DB2 database on my iSeries. I set up the connection profile to access the iSeries with my userid and password. I qualified all references to the file/table on the iSeries (pending my default schema and library list question elsewhere in this forum).

- The application functions without errors, correctly accessing the file on the iSeries using the Preview tab.
- Copying the jt400.jar file from the EDT program files directory to the "Tomcat6.0.20/lib" directory on my PC allowed the application to "Run as/Run on server" within the IDE.
- I exported the application to a war and deployed it into Tomcat running on my PC. It runs correctly.
- I copied the jt400Native.jar from the QIBM directory into the "Tomcat6.0.20/lib" in the IFS of the iSeries and deployed the same war file to that Tomcat installation. (That installation directory is a copy of what is on my PC with a few modifications to configuration files to make Tomcat run on the iSeries). When I run the application from that server, it produces the error.

I tried using jt400.jar instead (just to make sure) and the error message is the same. Even with neither jar file in the lib directory, the same message.

The iSeries java version is the new /QOpenSys/QIBM/ProdData/JavaVM/jdk60/32bit

Any ideas?
Re: JDBC driver error message from EGL on Tomcat 6 on iSeries [message #920109 is a reply to message #919248] Sat, 22 September 2012 18:57 Go to previous messageGo to next message
Nikola StanacevFriend
Messages: 2
Registered: December 2011
Junior Member
I guess the driver class was not properly loaded, try to add ,/QIBM/ProdData/OS400/jt400/lib/jt400Native.jar at the end of the line where it says common.loader in conf/catalina.properties. Also you should never copy the license program installed jt400Native.jar somewhere else because that one will not get patched and could get incompatible over time.

[Updated on: Sat, 22 September 2012 19:03]

Report message to a moderator

Re: JDBC driver error message from EGL on Tomcat 6 on iSeries [message #920805 is a reply to message #920109] Sun, 23 September 2012 13:18 Go to previous messageGo to next message
Jeffrey Gardner is currently offline Jeffrey GardnerFriend
Messages: 20
Registered: August 2012
Junior Member
Tried that and got the same (bad) result.

However, I did see this message in the catalina.[date].log file:

INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /QSYS.LIB/WAYSYS.LIB:/QSYS.LIB:/QSYS.LIB/QSYS2.LIB:/QSYS.LIB/QHLPSYS.LIB:/QSYS.LIB/QUSRSYS.LIB:/QSYS.LIB/RBTSYSLIB.LIB:/QSYS.LIB/QSHELL.LIB:/QSYS.LIB/QTEMP.LIB:/QSYS.LIB/QGPL.LIB:/QSYS.LIB/PRODPGM.LIB:/QSYS.LIB/PRODDSPF.LIB:/QOpenSys/QIBM/ProdData/JavaVM/jdk60/32bit/jre/lib/ppc:/QOpenSys/QIBM/ProdData/JavaVM/jdk60/32bit/jre/lib/ppc/classic

Is that complaining about the missing jt400Native.jar?
Where is java.library.path set?
Re: JDBC driver error message from EGL on Tomcat 6 on iSeries [message #921996 is a reply to message #920805] Mon, 24 September 2012 16:25 Go to previous messageGo to next message
Dan Darnell is currently offline Dan DarnellFriend
Messages: 145
Registered: November 2011
Location: Arkansas
Senior Member
The APR not found message means nothing when running on the IBM i. Ignore it.

For starters, try keeping the configuration the same (using the same jt400.jar that you use on the PC).

Here's my suggestion:

Undo what you've done with regard to jt400Native.jar. Take it out of /lib and undo whatever you did with catalina.properties.

Drop jt400.jar (same one you are using on the PC) into /lib.

Run your app. Did this correct the error?

If so, we'll revisit using jt400Native.jar. If not, let's figure out what else might be at play.

--Dan

p.s. Question: Are you using JNDI resources? Did you configure them in your server.xml and context.xml files in Tomcat on the IBM i?

Example from server.xml:
<Resource
name="jdbc/myresource"
type="javax.sql.DataSource"
password="mypassword"
driverClassName="com.ibm.as400.access.AS400JDBCDriver"
maxIdle="5"
maxWait="5000"
username="xxxxxxxxxx" 
url="jdbc:as400:www.xxxxxxxxxxxx.com;libraries=lib1 lib2 lib3;prompt=false"
maxActive="10"/>

And from context.xml:
<ResourceLink global="jdbc/myresource" name="jdbc/myresource" type="javax.sql.DataSource"/> 


[Updated on: Mon, 24 September 2012 21:33]

Report message to a moderator

Re: JDBC driver error message from EGL on Tomcat 6 on iSeries [message #922114 is a reply to message #921996] Mon, 24 September 2012 18:57 Go to previous messageGo to next message
Jeffrey Gardner is currently offline Jeffrey GardnerFriend
Messages: 20
Registered: August 2012
Junior Member
I had tried jt400.jar, but I gave it one more try. Same message. I get the same message even with neither of the two jar files in the /lib directory. Here's the common.loader line from the catalina.properties file (it is the same in my PC's Tomcat configuration.):

common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar

I appended a specific ",${catalina.home}/lib/jt400.jar" to the end which still did not work.


Just for jollies I copied jt400Native.jar to my PC's Tomcat (and got rid of the jt400.jar). It works fine there...(?!) Then, I took both jt400*.jar out of /lib on my PC and I get a completely different message when I run the application:

Failure: An exception occurred during a service call. Service:services.SQLService, Function:services.SQLService
Detail 1:
Detail 2:
Detail 3: Exception: SQLService, getAllPayments, SQLSTATE = , message = Cannot load JDBC driver class 'com.ibm.as400.access.AS400JDBCDriver': [sqlstate:null][sqlcode:0]

So, somehow my iSeries Tomcat is not getting the information it needs (from the EGL application?) to look for a driver named 'com.ibm.as400.access.AS400JDBCDriver' because the message says it is trying to create one. This seems especially so since the class name is blank and the url is null. (But, what do I know...)


And JNDI? I don't know. I don't see anything like your code sample in any of the /conf files, nor do I see it in the files on my PC. So both my installations are at least set up the same.


I don't know if it is material or not (since it has no database access), but the EGL HellowWorld tutorial does indeed work on the iSeries.
Re: JDBC driver error message from EGL on Tomcat 6 on iSeries [message #922143 is a reply to message #922114] Mon, 24 September 2012 19:36 Go to previous messageGo to next message
Dan Darnell is currently offline Dan DarnellFriend
Messages: 145
Registered: November 2011
Location: Arkansas
Senior Member


All right. Let's talk application configuration. What does the data source definition and binding look like in your application?

--Dan
Re: JDBC driver error message from EGL on Tomcat 6 on iSeries [message #922163 is a reply to message #922143] Mon, 24 September 2012 20:02 Go to previous messageGo to next message
Jeffrey Gardner is currently offline Jeffrey GardnerFriend
Messages: 20
Registered: August 2012
Junior Member
I'm not sure I know where this all is, but from the EGL application directory under /webapps, here's the contents of the context.xml file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Context>
<Resource auth="Container" driverClassName="com.ibm.as400.access.AS400JDBCDriver" maxActive="4" maxIdle="2" maxWait="5000" name="jdbc/WayAS400" password="xxxxxxx" type="javax.sql.DataSource" url="jdbc:as400:WayAS400;prompt=false" username="jeffg"/>
</Context>

If that isn't it, can you direct me to where I might find it? (Sorry, I am very ignorant on this stuff... )

OK, here's a few others:

Paymenttutorial.egldd file:
<?xml version="1.0" encoding="UTF-8"?>
<egl:deployment xmlns:egl="http://www.eclipse.org/xmlns/edt/deployment/1.0">
<bindings>
<binding name="WayAS400" type="edt.binding.sql" uri="workspace://WayAS400" useURI="true">
<parameters>
<parameter name="deployAsJndi" value="true"/>
<parameter name="jndiName" value="jdbc/WayAS400"/>
</parameters>
</binding>
</bindings>
<egl:target.project name="db2PaymentWeb"/>
</egl:deployment>


Paymenttutorial-bnd.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<egldd>
<bindings>
<binding name="WayAS400" type="edt.binding.sql" uri="jndi://jdbc/WayAS400" useURI="true">
</binding>
</bindings>
<includes>
</includes>
</egldd>


Do these help? (Sorry about n my initial "didn't find the code" message. Apparently, Windows does a terrible job of searching for strings in these types of files.)

[Updated on: Mon, 24 September 2012 20:28]

Report message to a moderator

Re: JDBC driver error message from EGL on Tomcat 6 on iSeries [message #922251 is a reply to message #922163] Mon, 24 September 2012 21:51 Go to previous messageGo to next message
Dan Darnell is currently offline Dan DarnellFriend
Messages: 145
Registered: November 2011
Location: Arkansas
Senior Member
Well, bummer. I don't know what to tell you.

I happen to have a clean Tomcat 7 install here (on an IBM i server) so, just for grins, I walked through creating a new EDT project and deployed it...going for the simplest working example. The only setup I did on the Tomcat server was to drop jt400.jar into my tomcat/lib directory on the IBM i server.

Here's the EGL code (using EDT 0.8.1):

package com.dandarnell.client;

// ^ This package is JavaScript generation only.

import org.eclipse.edt.rui.widgets.*;
import com.dandarnell.common.*;
import com.dandarnell.server.HelloDatabaseService;

handler HelloDatabase type RUIhandler{initialUI =[ui], onConstructionFunction = start, cssFile = "css/HelloDatabase.css", title = ""}

    ui GridLayout{columns = 3, rows = 4, cellPadding = 4, children = [ l1, t1, l2, l3, b1 ]};
    b1 Button{ layoutData = new GridLayoutData{ row = 4, column = 1 }, text = "Say Hello", onClick ::= b1_onClick };
    t1 TextField{ layoutData = new GridLayoutData{ row = 1, column = 2 }};
    l1 TextLabel{ layoutData = new GridLayoutData{ row = 1, column = 1 }, text = "ID:" };
    l2 TextLabel{ layoutData = new GridLayoutData{ row = 2, column = 2 }, text="" };
    l3 TextLabel{ layoutData = new GridLayoutData{ row = 3, column = 2 }, text="" };

    function start()
    end
    
    function b1_onClick(event Event in)
    	
    	call HelloDatabaseService.getCustomerWithStatus(t1.text as int)
    		returning to myCallBackFunction
			onException myExceptionHandler;
    end
    
    function myCallBackFunction(retResult CustomerWithStatus in)
		
		if(retResult.status.succeeded)
    		l2.text = "Hello, " + retResult.data.firstname;
    	end
    	
    	l3.text = "DB Status: " + retResult.status.message;
    end
    
    function myExceptionHandler(exp AnyException in)
		SysLib.writeStdOut(exp.messageID + " " + exp.message);
 
		if(exp isa ServiceInvocationException)
			SysLib.writeStdOut((exp as ServiceInvocationException).detail1);
			SysLib.writeStdOut((exp as ServiceInvocationException).detail2);
			SysLib.writeStdOut((exp as ServiceInvocationException).detail3);
		end

	end

end


package com.dandarnell.common;

// ^ This package is Java and JavaScript generation.

Record Status
	succeeded boolean;
	message string?;
end
record Customer type Entity { @table { name="CUSTOMER" } }
	id int{ @id };
	firstname string(40);
end
Record CustomerWithStatus
	status Status;
	data Customer?;
end


package com.dandarnell.server;

// ^ This package is Java generation only.

import com.dandarnell.common.*;

service HelloDatabaseService

	dataSource SQLDataSource? { @Resource{uri = "binding:dbbinding"}};  

	function getCustomerWithStatus(id int in) returns (CustomerWithStatus)

		ret CustomerWithStatus{};
		rec Customer?;
		ret.status.succeeded = false;
		ret.status.message = "Unknown error";
		
		try
			get rec from dataSource using(id);
 			
			if(rec == null)
				ret.status.message = "Record not found";
			else
				ret.status.succeeded = true;
		                ret.status.message = "Ok";
				ret.data = rec;
			end

		onException (exception SQLException)
			ret.status.message = exception.message;
		end
		
		return (ret);
	end
	
end


Attached screen shot is of my deployment descriptor. I did no manual JNDI/JDBC resource config on the Tomcat side ... just went with the context.xml as generated by the EDT tool in my deployable web project.

Table setup in DB2 looks like this:
CREATE TABLE DDARNELLDT/CUSTOMER (
  ID INT NOT NULL WITH DEFAULT,    
  FIRSTNAME VARCHAR ( 40) NOT NULL WITH DEFAULT,
  CONSTRAINT ID_KEY   
  PRIMARY KEY (ID))                                                  

INSERT INTO DDARNELLDT/CUSTOMER VALUES(1, 'Dan')    
INSERT INTO DDARNELLDT/CUSTOMER VALUES(2, 'Joe')    


On the UI you enter a user ID number (an integer) and then press the "Say Hello" button. The service is used to retrieve the user's name from a database table so that it can be helloed.

I don't know if this will help you or not...hope it does.

--Dan


  • Attachment: db1.PNG
    (Size: 43.82KB, Downloaded 106 times)

[Updated on: Mon, 24 September 2012 22:03]

Report message to a moderator

Re: JDBC driver error message from EGL on Tomcat 6 on iSeries [message #922918 is a reply to message #922251] Tue, 25 September 2012 13:03 Go to previous messageGo to next message
Jeffrey Gardner is currently offline Jeffrey GardnerFriend
Messages: 20
Registered: August 2012
Junior Member
Thanks for the test project. I'll work on it, but first, a couple of quick questions:

Do you find it better to specify all the connection properties instead of using a Connection Profile? The Connection Profiles seem to have a more limited capability with connection properties (as I discuss in my other forum topic "Default schema is not used by iSeries DB2 connection profile")

Also, I noticed you entered a local path on your PC for the "Class Locations" field. How is that used, and should I change it to the iSeries location when deploying to the iSeries?

Thanks much for you help and hand-holding.
Re: JDBC driver error message from EGL on Tomcat 6 on iSeries [message #923169 is a reply to message #922918] Tue, 25 September 2012 17:06 Go to previous messageGo to next message
Dan Darnell is currently offline Dan DarnellFriend
Messages: 145
Registered: November 2011
Location: Arkansas
Senior Member

I work with EGL in RBD every day but I am still finding my way with EDT.

I learned from your earlier post that the global Connection Profile doesn't seem to honor the full JDBC URL so I am using the connection information in the deployment descriptor for now. I haven't spent enough time with this piece of it though to figure out whether or not this needs a bug report.

Meanwhile, I use JNDI/JDBC data source configuration in Tomcat to adjust to different target databases in deployed applications. For example, although my deployment descriptor has a JDBC URL like this:

jdbc:as400:www.myserver.com;libraries=ddarnelldt;prompt=false

...the URL in my data source configuration in Tomcat might look this like:

jdbc:as400:www.myserver.com;libraries=proddata;prompt=false

The configuration for a data source in Tomcat looks like this:

[code]
In server.xml:
<Resource
name="jdbc/myresource"
type="javax.sql.DataSource"
password="mypassword"
driverClassName="com.ibm.as400.access.AS400JDBCDriver"
maxIdle="5"
maxWait="5000"
username="xxxxxxxxxx"
url="jdbc:as400:www.xxxxxxxxxxxx.com;libraries=proddata;prompt=false"
maxActive="10"/>

In context.xml:
<ResourceLink global="jdbc/myresource" name="jdbc/myresource" type="javax.sql.DataSource"/>
[code]

So, to recap, I'm using the connection information in the deployment descriptor while testing in the IDE or with a local (PC-based) Tomcat server but potentially overriding it for deployed apps by setting up a data source in Tomcat on the IBM i server.

--Dan
Re: JDBC driver error message from EGL on Tomcat 6 on iSeries [message #923207 is a reply to message #922918] Tue, 25 September 2012 18:00 Go to previous messageGo to next message
Dan Darnell is currently offline Dan DarnellFriend
Messages: 145
Registered: November 2011
Location: Arkansas
Senior Member
Jeffrey Gardner wrote on Tue, 25 September 2012 08:03

Also, I noticed you entered a local path on your PC for the "Class Locations" field. How is that used, and should I change it to the iSeries location when deploying to the iSeries?


Shouldn't have to change the "class locations" entry for deployment. It's not part of what makes it to "context.xml" in the web project. Seems to only be used when running in the IDE.

As long as you drop jt400.jar into /lib under Tomcat on the IBM i then Tomcat should be happy when you deploy.

--Dan

[Updated on: Tue, 25 September 2012 18:00]

Report message to a moderator

Re: JDBC driver error message from EGL on Tomcat 6 on iSeries [message #923370 is a reply to message #923207] Tue, 25 September 2012 21:30 Go to previous messageGo to next message
Jeffrey Gardner is currently offline Jeffrey GardnerFriend
Messages: 20
Registered: August 2012
Junior Member
Whew! I feel like I've been through the wringer...

Tomcat 6 and your sample project
I set this up under a single project with multiple packages. (Don't know if that is the normal way to do it.)

In the workbench, it ran and accessed the iSeries database in both the Preview and the Run on server, but it always produced this error:

CRRUI3655E [CRRUI3655E] An error occurred while processing response object: 'Object expected'
200

{"result" : {"status" : {"succeeded" : true, "message" : "Ok"}, "data" : {"id" : 1, "firstname" : "Dan"}}}

The dialog with the record did not display. As you can see, it did get the correct record before the error.

When I deployed to my PC Tomcat, it produced only a blank page when testing in Firefox (I thought that very odd). After much checking and redeploying, I tried IE. It it produced the same error message and results as the workbench.

I then deployed to the iSeries. Firefox behaved the same (blank page). IE produced the following error:

CRRUI3655E [CRRUI3655E] An error occurred while processing response object: 'Object expected'
200

{"result" : {"status" : {"succeeded" : false, "message" : "Cannot create JDBC driver of class '' for connect URL 'null': [sqlstate:null][sqlcode:0]"}, "data" : null}}

essentially the same JDBC error as the tutorial code produces.


Tomcat 7.0
So after a bit more messing around, I got a copy of Tomcat 7.0.30 and installed it on my PC and the iSeries.

The tutorial finally worked correctly on the PC and on the iSeries in Firefox (yeah!).

In IE 7 the oddity was that it correctly retrieves the data, but the 'Payment Record' grid is missing. And no error message...?

And get this, the tutorial even worked in Opera!

So, IE7 was the bad boy there (I know I'm behind on that one, but I don't use it much...)

Your sample project still showed a blank page in Firefox and Opera. In IE 7 it acted the same as under TC 6.0.20, seemingly getting the record but sending the error message before displaying the dialog.


jt400.jar
When I installed TC 7 and got the first success on the tutorial, I suddenly remembered that I had not copied the jt400.jar to the Tomcat /lib...that was weird. I discovered that the workbench is exporting the jt400.jar into the war file so it gets deployed in each app's WEB-INF/lib directory.

I did some more testing and found that TC 7 will run the apps correctly with jt400.jar in /lib or in WEB-INF/lib or in both (on both the iSeries and the PC). In fact, all of my tests on the PC and the iSeries returned the same results -- nice to see some consistency!

It seems the "Class locations" field in the Binding properties not only is used for classes in the IDE, it causes the jt400.jar file specified to be deployed to the web project and exported to the war file. I discovered that because I had different paths in the two projects pointing to two different versions of the jt400.jar, one left over from WDSc and the other supplied in EDT.

Leaving that field blank caused no jt400.jar to be deployed to the project or war. I like this as it lets the app server handle the jar file. However, is it better to have it in each app to avoid compatibility issues?

Leaving it blank causes problems with the connection in the IDE. Is there another setting to cause it to not be deployed and exported?


Well, thanks for your help and suggestions that got me this far. I can now move on to the next tutorial.

P.S. Once it was all working, I deleted all the jt400.jars and put the loader path in Tomcat to jt400Native. That worked too!

[Updated on: Tue, 25 September 2012 21:43]

Report message to a moderator

Re: JDBC driver error message from EGL on Tomcat 6 on iSeries [message #923417 is a reply to message #923370] Tue, 25 September 2012 22:39 Go to previous message
Dan Darnell is currently offline Dan DarnellFriend
Messages: 145
Registered: November 2011
Location: Arkansas
Senior Member
Woo hoo! Glad you are functional now.

Not sure why my example didn't work for you. On the surface it seems like some strange mismatch between the JSON data being returned and the Customer record definition used by the JavaScript client. Might try a Project->Clean on the project and run it again. (Not that you actually need my example to work now that you've cleared your hurdles with the tutorial.)

Also, good find on the jt400.jar being included in the target project when it is indicated in class locations in the DD. That's actually not desirable in my case (makes the WAR file larger for one thing) but some might prefer it. As you note, leaving it blank then causes runtime issue in the IDE (and trying to use the connection profile without overriding it doesn't seem to honor the full JDBC URL). Guess I will live with jt400.jar riding along with each WAR for now but this whole area is something the project team might want to think more about (or maybe they can weigh in with an existing solution that addresses all scenarios).

Feeling like you've been through the wringer is par for the course. They don't call it the bleeding edge for nothing! Smile

--Dan

[Updated on: Tue, 25 September 2012 22:41]

Report message to a moderator

Previous Topic:Default schema is not used by iSeries DB2 connection profile
Next Topic:Library From Database problem
Goto Forum:
  


Current Time: Thu Dec 18 10:39:27 GMT 2014

Powered by FUDForum. Page generated in 0.02140 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software