3 Replies Latest reply on Nov 9, 2005 6:59 AM by manik

    JBossCache-1.2.4 & Weblogic 8.1 SP4 (ClassCastException)

    rajs1

      JBossCache-1.2.4 & Weblogic 8.1 SP4 (ClassCastException)




      I have managed to insert the TreeCache object into the JNDI tree following the example given in the wiki:

      http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossCacheAndWebLogic

      But when I try and retreive the TreeCache object in my stateless session bean

       weblogic.jndi.Environment env = new weblogic.jndi.Environment();
       Context wctx = env.getInitialContext();
       Object obj = wctx.lookup(JNDIConstInterface.CACHE_BIND_NAME);
       org.jboss.cache.TreeCache c = (org.jboss.cache.TreeCache)obj;
      
      


      I get the following:




      java.lang.ClassCastException
      at service.staticdata.StaticDataServiceBeanImpl.setSessionContext(StaticDataServiceBeanImpl.java:277)
      at service.staticdata.StaticDataService_jti2xc_Impl.setSessionContext(StaticDataService_jti2xc_Impl.java:111)
      at weblogic.ejb20.manager.StatelessManager.createBean(StatelessManager.java:268)
      at weblogic.ejb20.pool.StatelessSessionPool.createBean(StatelessSessionPool.java:168)
      at weblogic.ejb20.pool.StatelessSessionPool.getBean(StatelessSessionPool.java:110)
      at weblogic.ejb20.manager.StatelessManager.preInvoke(StatelessManager.java:140)
      at weblogic.ejb20.internal.BaseEJBObject.preInvoke(BaseEJBObject.java:137)
      at weblogic.ejb20.internal.StatelessEJBObject.preInvoke(StatelessEJBObject.java:69)


      I have examined the "obj" Object on line 3 (of the above code snippet) and Eclipse tells me that it IS A org.jboss.cache.TreeCache.

      It shows up as a

      Object To String: org.jboss.cache.TreeCache [0 nodes, 0 locks]


      in the JNDI browser.

      I am baffled.

      Any help would be much appreciated.

      Cheers
      -raj


        • 1. Re: JBossCache-1.2.4 & Weblogic 8.1 SP4 (ClassCastException)
          manik

          I don't think that's where your class cast exception comes from. Looking at your stack trace, it seems to be something internal when setting your session context.

          Perhaps there is something in your session context that is causing this? Your stack trace says nothing about the JNDI service or TreeCache...

          • 2. Re: JBossCache-1.2.4 & Weblogic 8.1 SP4 (ClassCastException)
            rajs1

            Well, as it turns out it was a "jar" problem.

            I had a servlet that created the cache, started it and inserted the TreeCache object in JNDI. I made sure that this servlet always ran first (in WebLogic). The war file had the jboss-cache related jars in its WEB-INF/lib dir

            My ear's also had the jboss-cache related jars in its APP-INF/lib dir.

            However the JNDI (in WebLogic) would not allow a TreeCache object inserted by the servlet to be cast to a TreeCache object for the EJB because of the two seperate jars.

            I therefore took them out of the war and ear files and put them in the (WebLogic) server's path.

            All seems hunky dory now.

            Strange JNDI behaviour, but I suspect this is a WebLogic rather than a JNDI issue per se.

            Cheers
            -raj

            • 3. Re: JBossCache-1.2.4 & Weblogic 8.1 SP4 (ClassCastException)
              manik

              Yes, I'd think so - I would not expect JNDI to attempt any casting! :)