4 Replies Latest reply on Mar 16, 2006 2:21 PM by asack

    EJB3, iBatis, and CGLIB

    asack

      Hi,

      I'm working on a big project that is going to be completely EJB3/JBoss based (great work guys) and I'm running into an odd problem that the Wiki/FAQ and numerous Search tries are not resolving. I'm using JBoss 4.0.3SP1-EJB3RC5, JDK1.5_06 and iBatis 2.1.7-597 (latest).

      My issue is that I've had to inherit some iBatis stuff that is dying with essentially the stack trace at the end of this post. It occurs when I try to use a complex query in iBatis, i.e.:

      #
      # <result property="prop1" column="prop1_column" nullable="false"
      # select="some_sub_query"/>
      #

      So I'm trying to map a field to a subquery via the "select" clause which should ultimately return a Boolean. The "some_sub_query" should return a "java.lang.Boolean" as its resultClass.

      What I have found is that the cglib shipped with JBoss and/or EJB3 seems to break iBatis (it could be pilot error but my map file is most certainly valid). If I remove cglib from both default/lib and the ejb3.deployer, everything works.

      I realize this is not an iBatis forum, but can someone explain to me what might be going on AND more importantly, is CGLIB required for EJB3 deployment? I removed all CGLIB jars, restarted JBoss, and EJB3 seems to still work fine but I might be living very dangerously.

      Any info would come much appreciated!

      -aps

      15:50:58,546 INFO [STDOUT] java.lang.IllegalArgumentException: Cannot subclass final class boolean
      15:50:58,546 INFO [STDOUT] at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:446)
      15:50:58,546 INFO [STDOUT] at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
      15:50:58,546 INFO [STDOUT] at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
      15:50:58,546 INFO [STDOUT] at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
      15:50:58,546 INFO [STDOUT] at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
      15:50:58,546 INFO [STDOUT] at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:660)
      15:50:58,546 INFO [STDOUT] at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.loadResult(EnhancedLazyResultLoader.java:104)
      15:50:58,546 INFO [STDOUT] at com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader.loadResult(EnhancedLazyResultLoader.java:59)
      15:50:58,546 INFO [STDOUT] at com.ibatis.sqlmap.engine.mapping.result.loader.ResultLoader.loadResult(ResultLoader.java:53)
      15:50:58,546 INFO [STDOUT] at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getNestedSelectMappingValue(BasicResultMap.java:455)
      15:50:58,546 INFO [STDOUT] at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getResults(BasicResultMap.java:315)
      15:50:58,546 INFO [STDOUT] at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:394)
      15:50:58,546 INFO [STDOUT] at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:185)
      15:50:58,546 INFO [STDOUT] at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
      15:50:58,546 INFO [STDOUT] at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
      15:50:58,546 INFO [STDOUT] at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
      15:50:58,546 INFO [STDOUT] at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:561)
      15:50:58,546 INFO [STDOUT] at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:536)
      15:50:58,546 INFO [STDOUT] at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:93)
      15:50:58,546 INFO [STDOUT] at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:70)
      ...started from an EJB3 invoke on my Proxy object...

        • 1. Re: EJB3, iBatis, and CGLIB
          asack

          BUMP and at least can someone explain to me the ramifications of removing cglib or replace it with respect to the EJB3 deployer?

          Thanks!

          • 2. Re: EJB3, iBatis, and CGLIB
            maxandersen

            hibernate 3.1 is dependent on cglib and the latest cglib contain bugfixes regarding memory leaks afaik.

            the ibatis issue is better solved via their ibatis mailing list (which i do not think is caused by a wrong cglib version)

            • 3. Re: EJB3, iBatis, and CGLIB
              asack

              Thanks Max for the CGLIB explanation.

              Update:
              Well, if I use CGLIB 2.1 it works. Its only with the latest CGLIB it fails. This has to be an iBatis bug...sorry...

              • 4. Re: EJB3, iBatis, and CGLIB
                asack

                 

                "asack" wrote:
                Thanks Max for the CGLIB explanation.

                Update:
                Well, if I use CGLIB 2.1 it works. Its only with the latest CGLIB it fails. This has to be an iBatis bug...sorry...


                In case anyone was wondering, you have to turn off the lazy loader in iBatis for it to work properly under JBoss if you use subquery (via "select") result mapfiles. (in your config map <settings enhancementEnabled="false"). I initially tried that but it seems you have to turn it off on ANY reference to that mapfile (again seems like a bug which I have reported).

                Again, sorry for the confusion...at least I can keep CGLIB around!!!

                -aps