2 Replies Latest reply on Feb 1, 2002 7:42 AM by Janis

    Problem with byte arrays and characters in CMP

    Janis Newbie

      I'm using JBoss 2.4.4 with Tomcat 4.0.1 and SAP database 7.3.
      CMP does not work in the following situations:
      1)I have CMP entity bean with byte[] field and database field is "LONG BYTE".
      2)I have CMP entity bean with primitive character (char) field and database field is CHAR(1).

      It happened in previous JBodss versions as well.
      Maybe there is any workaround?

        • 1. Re: Problem with byte arrays and characters in CMP
          Alexander Lepekhine Newbie

          Could you explain what do you mean under "CMP does not work"? I don't know about SAP database - is CHAR(1) there a Unicode character? As you know characters in Java are Unicode (two-byte) characters.

          • 2. Re: Problem with byte arrays and characters in CMP
            Janis Newbie

            You was right. In SAP CHAR is not unicode character. With CHAR(2) it works fine.
            Regarding byte[] I found, that SAP DB driver returns an input stream as a result of getObject() call on result set.
            table is (id integer, image long byte, status char(2))
            entity EJB fields are: Integer id, byte[] image, char status

            Here is the stack trace
            [14:31:07,126,JAWSPersistenceManager] com.sap.dbtech.jdbc.translators.ConversionExceptionSapDB: Cannot convert SQL VARCHAR to Java byte []
            [14:31:07,136,products] TRANSACTION ROLLBACK EXCEPTION:
            javax.transaction.TransactionRolledbackException: Load failed; nested exception is:
            com.sap.dbtech.jdbc.translators.ConversionExceptionSapDB: Cannot convert SQL VARCHAR to Java byte []; nested exception is:
            java.rmi.ServerException: Load failed; nested exception is:
            com.sap.dbtech.jdbc.translators.ConversionExceptionSapDB: Cannot convert SQL VARCHAR to Java byte []
            java.rmi.ServerException: Load failed; nested exception is:
            com.sap.dbtech.jdbc.translators.ConversionExceptionSapDB: Cannot convert SQL VARCHAR to Java byte []
            com.sap.dbtech.jdbc.translators.ConversionExceptionSapDB: Cannot convert SQL VARCHAR to Java byte []
            at com.sap.dbtech.jdbc.translators.DBTechTranslator.newGetException(DBTechTranslator.java:1084)
            at com.sap.dbtech.jdbc.translators.DBTechTranslator.getBytes(DBTechTranslator.java:161)
            at com.sap.dbtech.jdbc.ResultSetSapDB.getBytes(ResultSetSapDB.java:846)
            at org.jboss.pool.jdbc.ResultSetInPool.getBytes(Unknown Source)
            at org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.getResultObject(JDBCCommand.java:435)
            at org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.getResultObject(JDBCCommand.java:500)
            at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.loadOneEntity(JDBCLoadEntityCommand.java:219)
            at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.handleResult(JDBCLoadEntityCommand.java:176)
            at org.jboss.ejb.plugins.jaws.jdbc.JDBCQueryCommand.executeStatementAndHandleResult(JDBCQueryCommand.java:59)
            at org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.jdbcExecute(JDBCCommand.java:156)
            at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:147)
            at org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.loadEntity(JAWSPersistenceManager.java:156)
            at org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity(CMPPersistenceManager.java:362)
            at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:287)
            at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:197)
            at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:125)
            at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:138)
            at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:347)
            at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:100)
            at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
            at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170)
            at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:428)
            at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:410)
            at java.lang.reflect.Method.invoke(Native Method)
            at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
            at sun.rmi.transport.Transport$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.rmi.transport.Transport.serviceCall(Unknown Source)
            at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
            at java.lang.Thread.run(Unknown Source)