IBM / JTOpen

IBM Toolbox for Java, an IBM i communications library
https://ibm.github.io/JTOpen/
Other
60 stars 28 forks source link

Latest JDBC driver in Spring Boot app fails on startup (NegativeArraySizeException) #165

Closed casey1111 closed 5 months ago

casey1111 commented 7 months ago

I'm currently having issues using the latest (and just later than 7.1 version) JTOpen JDBC driver in our Spring Boot application. On app startup, I see the following stack trace in the logs:

java.lang.NegativeArraySizeException: -186369 at [com.ibm.as400.access.AS400XChgRandSeedReplyDS.read](http://com.ibm.as400.access.as400xchgrandseedreplyds.read/)([AS400XChgRandSeedReplyDS.java:59](http://as400xchgrandseedreplyds.java:59/)) ~[jt400-20.0.6.jar:JTOpen 20.0.6] at com.ibm.as400.access.AS400ImplRemote.getConnection([AS400ImplRemote.java:1596](http://as400implremote.java:1596/)) ~[jt400-20.0.6.jar:JTOpen 20.0.6] at com.ibm.as400.access.AS400ImplRemote.connect([AS400ImplRemote.java:622](http://as400implremote.java:622/)) ~[jt400-20.0.6.jar:JTOpen 20.0.6] at com.ibm.as400.access.AS400.connectService([AS400.java:1669](http://as400.java:1669/)) ~[jt400-20.0.6.jar:JTOpen 20.0.6] at com.ibm.as400.access.AS400JDBCConnectionImpl.setProperties([AS400JDBCConnectionImpl.java:3538](http://as400jdbcconnectionimpl.java:3538/)) ~[jt400-20.0.6.jar:JTOpen 20.0.6] at com.ibm.as400.access.AS400JDBCDriver.prepareConnection([AS400JDBCDriver.java:1528](http://as400jdbcdriver.java:1528/)) ~[jt400-20.0.6.jar:JTOpen 20.0.6] at com.ibm.as400.access.AS400JDBCDriver.initializeConnection([AS400JDBCDriver.java:1362](http://as400jdbcdriver.java:1362/)) ~[jt400-20.0.6.jar:JTOpen 20.0.6] at com.ibm.as400.access.AS400JDBCDriver.connect([AS400JDBCDriver.java:510](http://as400jdbcdriver.java:510/)) ~[jt400-20.0.6.jar:JTOpen 20.0.6]

This exception isn't shutting down the application, but when trying to do a DB call, the same error is being thrown.

I'm not sure how to debug this error. If it's related to configuration issue, our database version is incompatible, or something else. Again, we have no issues with the 7.1 version, but when upgraded our application for JDK21 and Spring Boot 3, we were also trying to use latest JTOpen driver.

Any thoughts or suggestions on how to remedy this?

Thanks for any help..

jeber-ibm commented 5 months ago

The exception that you are seeing seems to indicate that you might be connecting to the wrong port. Older versions of the JTOpen driver did not utilize the port number if it was specified. It could be that the port number is being used and you are attempting to connect to the wrong port. Can you check your JDBC URL to make sure it doesn't include a port specification.

I see the same exception if I try to connect to port 23. java.lang.NegativeArraySizeException: -186369 at com.ibm.as400.access.AS400XChgRandSeedReplyDS.read(AS400XChgRandSeedReplyDS.java:81) at com.ibm.as400.access.AS400ImplRemote.getConnection(AS400ImplRemote.java:1668) at com.ibm.as400.access.AS400ImplRemote.connect(AS400ImplRemote.java:636) at com.ibm.as400.access.AS400.connectService(AS400.java:1765) at com.ibm.as400.access.AS400JDBCConnectionImpl.setProperties(AS400JDBCConnectionImpl.java:3547) at com.ibm.as400.access.AS400JDBCDriver.prepareConnection(AS400JDBCDriver.java:1540) at com.ibm.as400.access.AS400JDBCDriver.initializeConnection(AS400JDBCDriver.java:1374) at com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java:511)

casey1111 commented 5 months ago

Fantastic! Removing the port from JDBC URL worked perfectly. Thanks a lot for the reply!