3 Replies Latest reply on Nov 23, 2009 5:37 AM by ejb3workshop

    Crashing DB2 9.5 FP4 with Jboss 4.2.3GA and 5.1.0GA

    ejb3workshop

      I am trying to get JBoss (4.2.3GA and 5.1.0GA) working with DB2 9.5 FP4. My application consists of a servlet and a stateless session bean. When the servlet is invoked it calls the session bean and performs the following tasks:

      public void performInsert() {
       byte[] payload = new byte[size];
       for (int index = 0; index < size; index++) {
       payload[index] = 2;
       }
       int count = 0;
       for (int index = 1; index <= 5; index++) {
       DemoBlob demoBlob = new DemoBlob();
       demoBlob.setContent(payload);
       entityManager.persist(demoBlob);
       count++;
       }
       System.out.println("Stored :" + count + " Blob(s)");
      }
      
      public void performFind() {
       Query query = entityManager.createQuery("Select d from DemoBlob d ORDER BY d.id DESC");
       query.setFirstResult(0);
       query.setMaxResults(10);
       List<DemoBlob> blobs = query.getResultList();
       System.out.println("Found:" + blobs.size() + " Blob(s)");
       for (DemoBlob blob : blobs) {
       byte[] received = blob.getContent();
       if (received.length != size) {
       System.err.println("Too short");
       continue;
       }
       for (byte singleByte : received) {
       if (singleByte != 2) {
       System.err.println("Broken");
       break;
       }
       }
       }
      }
      


      Initially I didn't set the driver type in my datasource configuration and was using a type 2 driver. This caused by application to fail on the insert when the byte array exceeded about 1Mb. I figured this is caused by a bug in the JDBC driver and set the driver type to 4 using

      <xa-datasource-property name="DriverType">4</xa-datasource-property>


      This allowed my application to work correctly, but caused DB2 to stop without any obvious error message in any of the log files.

      Has anybody else experienced these or similar issues ? I am rather concerned since as you can see from the above code section, it doesn't do much.

      Any pointers on how to correctly configure and tune DB2 to work correctly with JBoss would be appreciated. Unless I missed something, please don't refer me to the JBoss datasource configuration section in the WIKI.

      Thanks in advance.