This discussion is archived
7 Replies Latest reply: Oct 26, 2012 6:42 AM by 679068 RSS

Using Coherence POF inside Oracle CEP

679068 Newbie
Currently Being Moderated
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?

Thanks
Daniel
  • 1. Re: Using Coherence POF inside Oracle CEP
    calvinIsMe Newbie
    Currently Being Moderated
    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="11.1.0.0",
    com.bea.wlevs.cache.spi.coherence;version="11.1.1.4_0",
    com.tangosol.io.pof;version="3.6.0.4",
    com.tangosol.net.cache;version="3.6.0.4",

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


    Regards
    Arijit
  • 2. Re: Using Coherence POF inside Oracle CEP
    679068 Newbie
    Currently Being Moderated
    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.

    Thanks
    Daniel
  • 3. Re: Using Coherence POF inside Oracle CEP
    alexalves Explorer
    Currently Being Moderated
    Hi Daniel,

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

    Here is an example:

    <replicated-scheme>
    <scheme-name>new-replicated</scheme-name>
    <service-name>ReplicatedCache</service-name>
    <backing-map-scheme>
    <class-scheme>
    <scheme-ref>my-local-scheme</scheme-ref>
    </class-scheme>
    </backing-map-scheme>
    </replicated-scheme>

    <replicated-scheme>
    <scheme-name>pof-replicated</scheme-name>
    <service-name>ReplicatedPofCache</service-name>

    <serializer>
    <class-name>com.tangosol.io.pof.ConfigurablePofContext</class-name>
    <init-params>
    <init-param>
    <param-type>string</param-type>
    <param-value>/META-INF/wlevs/coherence/pof-config.xml</param-value>
    </init-param>
    </init-params>

    pof-config.xml:

    <pof-config>
    <user-type-list>
    <user-type>
    <type-id>12000</type-id>
    <class-name>com.bea.wlevs.test.cachecql.SymbolBean</class-name>
    </user-type>
    </user-type-list>
    </pof-config>

    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.

    Rgds,
    Alex
  • 4. Re: Using Coherence POF inside Oracle CEP
    calvinIsMe Newbie
    Currently Being Moderated
    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.

    Regards
  • 5. Re: Using Coherence POF inside Oracle CEP
    679068 Newbie
    Currently Being Moderated
    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:

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

         @Override
         public void beforeResume() throws Exception {
              cpc = new ConfigurablePofContext(<POF-CONFIG-PATH>);
              cpc.setContextClassLoader(this.getClass().getClassLoader());
         }

    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
    alexalves Explorer
    Currently Being Moderated
    Hi,

    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:

    this.getClass().getClassLoader()

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

    Cheers
    Alex
  • 7. Re: Using Coherence POF inside Oracle CEP
    679068 Newbie
    Currently Being Moderated
    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.

    Thanks

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points