6 Replies Latest reply on Oct 20, 2012 5:54 PM by adobe30022

    How to get Coherence 3.7.1 to work with CQ5.5 ?

    adobe30022

      We have been trying to get Coherence working with CQ5.5.  We have read the steps given in an earlier thread cq5.4 & Coherence 3.7.1 and tried to follow them but none of the approaches work with CQ5.5 and Coherence 3.7.   This is what we have tried so far.

       

      We created plugin-jar containing coherence.jar using Eclipse and then deployed/installed in my local CQ5 author installation using CQ5 Web Console Bundles - install/update. The bundle was installed and started without any errors.

       

      Created a simple jsp using CQ5.5's geometrixx content page and modified it as given in the above thread to just test coherence.

       

       

      <%-- Sample jsp--%>
      <%@include file="/libs/foundation/global.jsp" %> 
      
      <%@ page import="com.tangosol.net.CacheFactory,com.tangosol.net.NamedCache" %>
       <%         String key = "k2";
                  String value = "Hello World from cq!";
      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
      ClassLoader newLoader = com.tangosol.net.CacheFactory.class.getClassLoader();
      Thread.currentThread().setContextClassLoader(newLoader);
      
             CacheFactory.ensureCluster();
             NamedCache cache = CacheFactory.getCache("hello-example");
             cache.put(key, value);
             out.println((String)cache.get(key));
             CacheFactory.shutdown();
             Thread.currentThread().setContextClassLoader(oldLoader);
      
               %>
      <div id="main">
          <div class="container_16">
      Hello, my name is 1.1
              <div class="grid_16">
                  <cq:include path="carousel" resourceType="foundation/components/carousel"/>
              </div>
              <div class="grid_12 body_container">
                  <cq:include path="lead" resourceType="geometrixx/components/lead"/>
                  <cq:include path="par" resourceType="foundation/components/parsys"/>
              </div>
              <div class="grid_4 right_container">
                  <cq:include path="rightpar" resourceType="foundation/components/parsys"/>
              </div>
              <div class="clear"></div>
          </div>
      </div>
      
      
      

       

       

      These are the errors that we are seeing.

       

      Caused by: (Wrapped) java.lang.NoClassDefFoundError: javax/naming/NamingException
       at com.tangosol.util.Base.ensureRuntimeException(Base.java:288)
       at com.tangosol.util.Base.ensureRuntimeException(Base.java:269)
       at com.tangosol.net.CacheFactory.getCluster(CacheFactory.java:392)
       at com.tangosol.net.CacheFactory.ensureCluster(CacheFactory.java:421)
       at org.apache.jsp.apps.geometrixx.components.homepage.content_jsp._jspService(content_jsp.java:169)
       at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
       at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:420)
       ... 126 more
      Caused by: java.lang.NoClassDefFoundError: javax/naming/NamingException
       at java.lang.Class.forName0(Native Method)
       at java.lang.Class.forName(Unknown Source)
       at com.tangosol.net.CacheFactory.<clinit>(CacheFactory.java:923)
       at org.apache.jsp.apps.geometrixx.components.homepage.content_jsp._jspService(content_jsp.java:171)
       ... 129 more
      Caused by: java.lang.ClassNotFoundException: javax.naming.NamingException not found by Coherence_vs [238]
       at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
       at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
       at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
       at java.lang.ClassLoader.loadClass(Unknown Source)
       ... 133 more
      
      

       

       

      The steps below given in the above thread cq5.4 & Coherence 3.7.1 don't seem to be valid in CQ5.5 anymore like for example -

      or

      • Place coherence.jar at <CQ_Install_Dir>/crx-quickstart/server/runtime/0/_/WEB-INF/lib/  (there is no such directory in the current CQ5.5 installation)

       

       

       

      Would really appreciate any help. Thank you in advance.

       

      VS

        • 1. Re: How to get Coherence 3.7.1 to work with CQ5.5 ?
          Sham HC Level 7

          You have two options:

           

          Option1:- 

          Instead of cq standalone application. Use application server and deploy cq war file. Then Build & Deploy Coherence war in same app server. This will be simple & neat.

           

          Option2:-

          Convert Coherence jar into osgi bundle. Which you might be trying, Looking at logs your bundle seems good.

          Couple of points to note on default Coherence implementation

              -      Uses schema definition & will be validated against it

              -    Uses Optional configuration override

          In case you are building the osgi bundle by embeding the jar you might face some challenge in reading those configuration files like schema location for coherence-operational-config, overide file eg:- tangosol-coherence-override-dev.xml    

           

          Anyhow To begin with you can disbale schema definition & a optional xml-override. Then add [1] into <cq_home>/crx-quickstart/conf/sling.properties and verify. Once it works you can modify the bundle to handle reading those configuration.

           

          [1]

          sling.bootdelegation.javax.xml.validation=javax.xml.validation

          sling.bootdelegation.javax.xml=javax.xml

          sling.bootdelegation.sun.rmi.server=sun.rmi.server

          sling.bootdelegation.javax.security.auth=javax.security.auth

          sling.bootdelegation.javax.xml.parsers=javax.xml.parsers

          sling.bootdelegation.javax.xml.transform.stream=javax.xml.transform.stream

          sling.bootdelegation.javax.management=javax.management

          sling.bootdelegation.javax.security.auth.callback=javax.security.auth.callback

          sling.bootdelegation.javax.xml.transform=javax.xml.transform

          sling.bootdelegation.javax.net.ssl=javax.net.ssl

          sling.bootdelegation.org.xml.sax=org.xml.sax

          sling.bootdelegation.javax.naming=javax.naming

          • 2. Re: How to get Coherence 3.7.1 to work with CQ5.5 ?
            adobe30022 Level 1

            Sham,

             

            Thank you for your response. I tried option 2 and it works fine.  How do I test option 1 on my local cq setup which I start by just running the CQ-author-....jar file?

             

             

            Thank you!

            1 person found this helpful
            • 3. Re: How to get Coherence 3.7.1 to work with CQ5.5 ?
              Sham HC Level 7

              For option 1 you need to Use application server & not possible directly.

              1 person found this helpful
              • 4. Re: How to get Coherence 3.7.1 to work with CQ5.5 ?
                adobe30022 Level 1

                Sham - Thank you very much for all your help.

                 

                Like I said in my earlier post option (2) of creating a OSGi bundle out of the coherence.jar worked for me. I tested it using the above mentioned geometrixx jsp content page and it worked fine.  But when I try to access the coherence api in another bundle CoherenceLoader so that I can fill up the cache with values I get errors.

                 

                Caused by: (Wrapped: Failed to load the factory) (Wrapped: Missing or inaccessible constructor "com.tangosol.net.DefaultConfigurableCacheFactory(String)"

                Caused by: (Wrapped: Failed to load cache configuration: coherence-cache-config.xml) java.io.IOException: The cache configuration is missing: "coherence-cache-config.xml", loader=null

                Caused by: java.io.IOException: The cache configuration is missing: "coherence-cache-config.xml", loader=null

                 

                Is there some configuration/ declaration in my coherence.jar bundle  that I need to modify so that it is accessible in another bundle? Or is there some configuration in my second bundle that I need to fix? I am using Eclipse in case there is any particular way to change plug-in configurations.

                 

                I would not like to do this but can I include the coherence.jar together with the my cache loader  plugin code - what is the way to do this in eclipse? ( just incase everything else fails)

                 

                Appreciate any help to figure this one out.

                 

                Thank you!!!

                 

                VS

                1 person found this helpful
                • 5. Re: How to get Coherence 3.7.1 to work with CQ5.5 ?
                  Sham HC Level 7

                  I am not sure how did you converted coherance.jar into OSGI bundle

                   

                  In the mainfest for  Include-Resource  have you mentioned all the xml files ?

                  • 6. Re: How to get Coherence 3.7.1 to work with CQ5.5 ?
                    adobe30022 Level 1

                    There was some quirky CQ behaviour and we resolved the issue, I do not have a good explanation of how it got resolved, Sorry!. 

                     

                    But to answer your question - I created the coherence.jar using the Eclipse --> New Project --> Plug-in from Existing JAR Archives. The manifest does not have Include-Resource tag and when I try to add it manually also it did not work. But if you are thinking coherence xml files were not included that is not right, they were present in the OSGi bundles that were created (even without the Include-Resource tag), I had selected the xml files to be included in the build configuration (eclipse interface for building the plugin from JAR archives)

                     

                    But we did see a different problem. After Coherence used to work for some time like it seems like it would crash, did not see any errors but it would just stop responding, have to investigate more for details.

                     

                    Thank you!