7 Replies Latest reply on Oct 26, 2012 1:42 PM by Daniel Amadei-Oracle

    Using Coherence POF inside Oracle CEP

    Daniel Amadei-Oracle
      Hi All,

      I'm trying to configure coherence pof inside Oracle CEP however seems that the classloader used by the coherence which runs inside CEP can't see the classes of my application.

      I get the following error of coherence trying to load a class which is in the same jar of classes which started coherence (com.acme.*):

      Caused By: java.lang.ClassNotFoundException: com.acme.MyClass
           at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
           at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
           at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
           at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:109)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
           at java.lang.Class.forName0(Native Method)
           at java.lang.Class.forName(Class.java:169)
           at com.tangosol.util.ExternalizableHelper.loadClass(ExternalizableHelper.java:3164)
           at com.tangosol.io.pof.ConfigurablePofContext.loadClass(ConfigurablePofContext.java:1223)
           at com.tangosol.io.pof.ConfigurablePofContext.createPofConfig(ConfigurablePofContext.java:976)
           at com.tangosol.io.pof.ConfigurablePofContext.initialize(ConfigurablePofContext.java:797)
           at com.tangosol.io.pof.ConfigurablePofContext.setContextClassLoader(ConfigurablePofContext.java:322)
           at com.acme.pof.MySerializerImpl.deserialize(MySerializerImpl.java:37)
           at com.acme.cep.MyInboundMessageConverter.convert(MyInboundMessageConverter.java:32)
           at com.bea.wlevs.adapters.jms.InboundJmsAdapter.onMessage(InboundJmsAdapter.java:247)

      Any ideas?

        • 1. Re: Using Coherence POF inside Oracle CEP
          Hi Daniel

          Seems like a classpath issue as it cannot load your class.

          Also check your Manifest.MF file with the following details
          Import-Package: com.bea.wlevs.cache.spi;version="",

          Thirdly check if you have kept coherence-cache-config.xml and tangosol-coherence-override.xml in the proper directory

          • 2. Re: Using Coherence POF inside Oracle CEP
            Daniel Amadei-Oracle
            Hi Arijit,

            Coherence is working fine. My classes are in classpath of my bundle, however when I need coherence to load my class with POF, I get the CNF. Maybe coherence is loaded using a different classloader that can't see my classes.

            • 3. Re: Using Coherence POF inside Oracle CEP
              Hi Daniel,

              How is your POF configuration done? Note the init-params.

              Here is an example:






              Finally, note that you may need to export your package (e.g. com.bea.wlevs.test.cachecql) so that it is seen by the coherence bundle.

              • 4. Re: Using Coherence POF inside Oracle CEP
                Hi Daniel

                I just happen to notice that you are using a separate serializer in your code (com.acme.pof.MySerializerImpl). From where is it getting loaded into JVM?
                I think you can check that angle as well.

                • 5. Re: Using Coherence POF inside Oracle CEP
                  Daniel Amadei-Oracle
                  Hi all,

                  I was able to make this work with some help of Manju James.

                  Yes, I'm using a custom serializer. Actually, I'm just using POF to deserialize JMS message bytes, not coherence cache itself. I'm just leveraging POF optimizations for serialization. In my case, a java object serialized into POF is being set as 250bytes while being serialized via Java Serialization it's getting a size of 1.3kb.

                  Steps to make it work:

                  a) Import coherence packages via OSGi.

                  b) In your InboundMessageConverter implement ResumableBean, SuspendableBean

                  c) Implemented the lifecycle methods as:

                       public void suspend() throws Exception {
                            cpc = null;

                       public void beforeResume() throws Exception {
                            cpc = new ConfigurablePofContext(<POF-CONFIG-PATH>);

                  That's it. After that, I was able to use this cpc reference and deserialize by binary payload to an object representing my events.
                  • 6. Re: Using Coherence POF inside Oracle CEP

                    Great news.

                    One thing to keep in mind is that in OSGi you must use the CL of the bundle, which can be retrieved from a class that is part of a bundle, like in the case here:


                    Don't assume that the thread context's class-loader is the right one, as generally it will not be.

                    • 7. Re: Using Coherence POF inside Oracle CEP
                      Daniel Amadei-Oracle
                      Hi Alex,

                      Yes, that was my case. I first tried with Thread's Context CL and did not work and switching to the class' cl did the trick.