Whilst recently connecting to an IBM DB2 through an App Connect Enterprise (ACE) bar file following (parts of) this tutorial on developer works - https://developer.ibm.com/integration/blog/2019/01/15/connecting-integrations-to-jdbc-endpoints-on-app-connect/ I hit a couple of issues due to using different naming standards and from (naughtily) plucking specific parts from the article but not following it properly.
I have been using IBM Cloud Private where both an ACE helm chart (11.0.0.4) and DB2 are both deployed with different names and data models than those defined in the example. If, like me, you bypassed parts of the example here are some issues you might have seen.
1. In containerised ACE deployment the JDBC Driver JAR should be loaded into the project to be packaged with the bar (as decribed in the article above)
a. In the ACE Toolkit go to Window -> Show View-> Java
b. Drag and drop the db2jcc4 JAR file into Project window
c. Right Click (double finger click on the MAC) on the Java Project Folder and select Properties -> Java Build Path -> Click Add JARs -> Select db2jcc4 jar file -> Click OK
d. Ensure the Java Project is included in the bar file
e. Ensure “User JAR files that have been deployed in a .bar file” is set to true in the JDBC Policy as defined in the tutorial and that the policy is included in the bar file build
2. After the deployment there was still an error that persisted;
"com.ibm.broker.classloading.JarsURLClassLoader.findClass(JarsURLClassLoader.java:104)"
I was able to find greater debug logs in ICP in the following file, in the following file;
/home/aceuser/ace-server/log/integration_server.<servername>.events.txt
6231E: An error occurred in node: Broker 'integration_server';
Node Type 'DeleteProducts_JavaCompute Exception details: message: com.ibm.db2.jcc.DB2XADataSource stack trace: java.net.URLClassLoader.findClass(URLClassLoader.java:610) \ncom.ibm.broker.classloading.JavaResourceClassLoader.findClass(JavaResourceClassLoader.java:180) \ncom.ibm.broker.classloading.SharedClassLoader.findClass(SharedClassLoader.java:209) \njava.lang.ClassLoader.loadClassHelper(ClassLoader.java:937
The error looks like the jar has not been correctly loaded, to check we can;
- Looking in the bar file on the toolkit in the ‘Manage’ tab which should show the jar file in the REST API Application.
- Convert the bar file into a zip and unzip it to see the files inside where the jar should be visible.
If that all looks good, next you should check the JDBC connection in the Java Compute Node.
Connection conn= getJDBCType4Connection("BLUDB", JDBC_TransactionType.MB_TRANSACTION_AUTO);
The example makes it look like BLUDB should match the name of the policy since the policy, database name and connection definition are all the same. The error also doesn’t point very well at what the issue is.
The connection should refer to the Database name being connected to. In my personal view, I would follow the example and call the policy the same name as the database being connected to which can be referred to in getJDBCType4Connection.
Hopefully this has helped you with your development!