Menu

#371 NullPointerException during execute PreparedStaments

Connection
closed-fixed
nobody
None
5
2016-02-16
2016-01-26
Andreas
No

When our application starts, we refill a simple small table.

CREATE TABLE S3xxx.SYNCHGPROT ( 
    FIRMA NUMERIC(2, 0) DEFAULT NULL , 
    TABELLE CHAR(10) CCSID 1025 DEFAULT NULL , 
    CONSTRAINT S3xxx.Q_S3xxx_SYNCHGPROT_FIRMA_00001 PRIMARY KEY( FIRMA , TABELLE ) )   
    ;   

First step we delete the data with TRANCATE.

TRUNCATE TABLE S3xxx.SYNCHGPROT

Second step we write new data in them, over a PreparedStatement.
There are about 200-300 insert-Statements with the same PreparedStatement.

INSERT INTO S3xxx.SYNCHGPROT (Firma,Tabelle) VALUES(?,?)

Sometimes (not always) we get a NullPointerException during the execute, always on the same line of code!

java.lang.NullPointerException
    at com.ibm.as400.access.JDError.createSQLExceptionSubClass(JDError.java:793)
    at com.ibm.as400.access.JDError.throwSQLException(JDError.java:682)
    at com.ibm.as400.access.AS400JDBCStatement.commonExecute(AS400JDBCStatement.java:1032)
    at com.ibm.as400.access.AS400JDBCPreparedStatement.execute(AS400JDBCPreparedStatement.java:1411)
    at de.gfd.zww.synchrotool2.run.Sammeljobs$Sammeljob.befuelleSYNCHGPROTTabelle(Sammeljobs.java:2483)
    at de.gfd.zww.synchrotool2.run.Sammeljobs$Sammeljob.run(Sammeljobs.java:1078)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)

We get also a NullPointerException, but even rarer within other statements.

java.lang.NullPointerException
    at com.ibm.as400.access.JDError.createSQLExceptionSubClass(JDError.java:793)
    at com.ibm.as400.access.JDError.throwSQLException(JDError.java:682)
    at com.ibm.as400.access.AS400JDBCStatement.commonExecute(AS400JDBCStatement.java:1032)
    at com.ibm.as400.access.AS400JDBCPreparedStatement.executeUpdate(AS400JDBCPreparedStatement.java:1827)
    at de.gfd.zww.synchrotool2.run.Joblaeufe$Joblauf.schreibeInsert(Joblaeufe.java:4370)
    at de.gfd.zww.synchrotool2.run.Joblaeufe$Joblauf.starteSynchroVersorgung(Joblaeufe.java:2075)
    at de.gfd.zww.synchrotool2.run.Joblaeufe$Joblauf.run(Joblaeufe.java:493)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)

If we get this exception, our job (thread) stopped. After restart the job works fine with the same data.
We hope you can help us, we have no idea where the problem is.

System specification:
Java 1.6 Update 45 64Bit on Microsoft Windows Server 2008 R2 Enterprise ServicePack 1
IBM jt400.jar 7.2 on AS400 v7r2m0

1 Attachments

Discussion

  • John Eberhard

    John Eberhard - 2016-01-27

    Are you using the latest JTOpen release?

    Can you recreate the problem with tracing enabled?

    To use tracing for define the properties to the JVM running toolbox

    com.ibm.as400.access.Trace.category=ALL
    com.ibm.as400.access.Trace.file=/tmp/out.txt

    The output of the trace will be in /tmp/out.txt

    If running from the command line, you can specify this using

    java -Dcom.ibm.as400.access.Trace.category=ALL -Dcom.ibm.as400.access.Trace.file=/tmp/out.txt JAVAPROGAM

    Then submit the trace and I can take a look.

     
  • Andreas

    Andreas - 2016-01-28

    We have tried the original IBM jt400 from our i5 system, as well as the version 8.6 and 8.7. All the same problem. Now we use the latest JTOpen 8.7 for java 6!

    A log file have attached. The thread SammeljobThread_0009_S341IT3D got the exception.

    We used the connection properties, these are the same?

    toolbox trace=error
    trace=true
    

    I have now changed toolbox trace to all

    In addition, I try with a small test program recreate the error.

    Thanks for any help!

     
  • John Eberhard

    John Eberhard - 2016-01-28
     
  • John Eberhard

    John Eberhard - 2016-01-28

    I have been able to recreate the error. It looks like you are using multiple threads to do the inserts and each thread is on a separate connection. I am putting together a fix. The fix will only work if each thread truly uses it own connection (that is not shared with other threads).

     
  • John Eberhard

    John Eberhard - 2016-01-28
    • status: open --> closed-fixed
    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -0,0 +1 @@
    +jt400.jar (4.7 MB; application/java-archive)
    
     
  • John Eberhard

    John Eberhard - 2016-01-28

    The fix has been integrated into the CVS repository. It will be included in the next JTOpen release. I've attached a jt400.jar file that was built today that has the fix. Can you test the attached jar file?

    If the fix does not work, I will need a complete toolbox trace, creating by setting the JVM properties previously stated. The last trace provided was partial but had enough information for me to determine the current problem.

     
  • Andreas

    Andreas - 2016-01-29

    I have replaced the jt400.jar and activated the toolbox trace over JVM environment.
    These is only in our development environment possible.

    I'll get back as soon as the problem recurs.

    Many thanks for the quick support, and the provision of jt400.jar!

     
  • Andreas

    Andreas - 2016-02-16

    Now after 2 weeks all works fine. We got no more exceptions!
    Great, thank you!

     

Log in to post a comment.