2 Replies Latest reply on Jun 3, 2003 9:21 AM by weiqingh

    LinkageError caused by user defined interceptor

    weiqingh

      hi there,

      i am integrating hibernate with jboss. i deployed hibernate as a service and then my ejbs can jndi look up hibernate session and every thing works. my ears depend on the hibernate sar and i can hot redeploy them at will. (of course if sar is redeployed, ears have to be redeployed.)

      then i wrote an interceptor for my SLSB so that i can automatically bind a hibernate session to the thread local of my SLSB. i can then easily access the session anywhere in my SLSB and don't need to worry about getting, flushing or closing the session in the finally block (all done by the interceptor).

      my interceptor needs access to the hibernate session classe. currently it's obtained from the hibernate sar. however if i hot redeploy my sar and ears, since the interceptor is not (and cannot be?) hot redeloyed, the redeployed ejb will get a run time exception when it's accessing a hibernate session:

      java.lang.LinkageError: loader constraints violated when linking net/sf/hibernate/Session class

      what is the best approach to this kind of deployment issue? is there a work around? i really want to be able to hot redeploy the hibernate service. is there any way the interceptor can be hot redeployed too?

      thanks in advance.

        • 1. Re: LinkageError caused by user defined interceptor

          Why do you need to recycle the hibernate
          classes? Can't you just add them to
          server/default/lib?

          If you are recycling the hibernate classess,
          you'll need to redeploy the interceptor
          and all the applications that use it.

          Alternatively, use reflection to load the
          session class on every request (much slower)

          Regards,
          Adrian

          • 2. Re: LinkageError caused by user defined interceptor
            weiqingh

            Adrian,

            thanks for the reply. well, i can deploy hibernate to jboss lib like you said. then i won't get the class linkage error. the problem is that i am getting a hibernate session in the interceptor, which in turn is linked to the session factory, which is like the central repository of all the persistent classes. now if i hot redeploy my persistent classes, (as part of my application), the session factory won't be able to find the new classes anymore. (reflection won't help at all, unless hibernate is re-written.)

            given that interceptors cannot be redeployed, one just needs to be careful with what classes are used in the interceptor and deal with the consequence. in my situation, i may just need to restart jboss in some circumstances.