0 Replies Latest reply on Feb 7, 2006 2:15 PM by belingueres

    Problem with the InformixDS mapping?

    belingueres Newbie

      Hi,

      I'm using JBoss 4.0.2 running on Java 1.5. Database and JDBC driver information is:

      Informix Dynamic Server 9.21.HC4
      IBM Informix JDBC Driver for IBM Informix Dynamic Server 3.00.JC3

      I want to install the EJBCA Certificate Authority and I'm in the task of porting the Entity beans to Informix, but I found that the default datatype mappings on the file standardjbosscmp-jdbc.xml to be not quite precise (I'm posting this to see if someone can tell me if I'm doing something wrong or not).

      First, I changed the default Informix BLOB mapping that is:


      <java-type>java.lang.Object</java-type>
      <jdbc-type>BLOB</jdbc-type>
      <sql-type>BLOB</sql-type>


      to this:


      <java-type>java.lang.Object</java-type>
      <jdbc-type>VARBINARY</jdbc-type>
      <sql-type>BLOB</sql-type>


      because it throwed me NPE when trying read the data from database. This worked but now I have a CMP entity bean that has a boolean property but it throws me an exception when I want to Create it:

      2006-02-07 14:49:37,027 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.AccessRulesData] Executing SQL: INSERT INTO accessrulesdata (pK, accessRule, rule, isRecursive, AdminGroupData_accessRules) VALUES (?, ?, ?, ?, ?)
      2006-02-07 14:49:37,177 ERROR [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.AccessRulesData] Could not create entity
      java.sql.SQLException: No cast from boolean to smallint.
      at com.informix.jdbc.IfxSqli.a(IfxSqli.java:3204)
      at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3518)
      at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2353)
      at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2269)
      at com.informix.jdbc.IfxSqli.executeCommand(IfxSqli.java:775)
      at com.informix.jdbc.IfxResultSet.b(IfxResultSet.java:291)
      at com.informix.jdbc.IfxStatement.c(IfxStatement.java:1253)
      at com.informix.jdbc.IfxPreparedStatement.executeUpdate(IfxPreparedStatement.java:408)
      at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:316)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.executeInsert(JDBCAbstractCreateCommand.java:352)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.performInsert(JDBCAbstractCreateCommand.java:308)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.execute(JDBCAbstractCreateCommand.java:138)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:572)
      at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:222)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:266)
      at org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:612)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1113)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:90)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:192)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:212)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:90)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:117)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:61)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:28)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:41)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:109)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:146)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:116)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:121)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
      at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:508)
      at org.jboss.ejb.Container.invoke(Container.java:894)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:342)
      at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:118)
      at $Proxy121.create(Unknown Source)
      at se.anatom.ejbca.authorization.AdminGroupDataBean.createAccessRule(AdminGroupDataBean.java:410)
      at se.anatom.ejbca.authorization.AdminGroupDataBean.addAccessRules(AdminGroupDataBean.java:176)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1174)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:72)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:273)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:111)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:242)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:53)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:139)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:514)
      at org.jboss.ejb.Container.invoke(Container.java:873)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:413)
      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:50)
      at $Proxy172.addAccessRules(Unknown Source)
      at se.anatom.ejbca.authorization.LocalAuthorizationSessionBean.addAccessRules(LocalAuthorizationSessionBean.java:718)
      at se.anatom.ejbca.authorization.LocalAuthorizationSessionBean.initialize(LocalAuthorizationSessionBean.java:321)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:130)
      at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:139)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
      at org.jboss.ejb.Container.invoke(Container.java:873)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:595)
      Caused by: java.sql.SQLException
      at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:373)
      at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3523)
      ... 108 more

      Viewing that current default mapping for Boolean is:


      <java-type>java.lang.Boolean</java-type>
      <jdbc-type>BIT</jdbc-type>
      <sql-type>SMALLINT</sql-type>


      I suspect that this may need to change too, maybe mapping to a char(1):


      <java-type>java.lang.Boolean</java-type>
      <jdbc-type>BIT</jdbc-type>
      <sql-type>CHAR(1)</sql-type>


      Note that I say char(1) and not the Informix BOOLEAN datatype since it is available only for version 9.x and above.

      Now the question is:

      Is the default Informix mapping wrong? or it is just not compatible with version 9.x or newer but IT IS compatible with previous versions of Informix? (If so we should need different mappings for the different database versions, such as Oracle have.

      Regards,
      Gabriel