There are 3 options which is described below. The steps may slightly vary based on cq & Oracle Coherence version. The details mentioned below are for cq5.4 & Coherence 3.7.1
- Option 1:- Oracle recommended way
* Create a basic Web application directory
* jar -cvf hello.war *
* Deploy the hello.war file by going to cq servlet engine at http://<host>:<port>/admin
* Access your sample with http://<host>:<port>/<contextroot>/Sample.jsp
- Option 2:- Combination of Option 1 & Option 3
* Stop the cq
* Place coherence.jar at <CQ_Install_Dir>/crx-quickstart/server/runtime/0/_/WEB-INF/lib/
* Place tangosol-coherence-override.xml and all additional xml files at <CQ_Install_Dir>/crx-quickstart/server/runtime/0/_/WEB-INF/classes/
* Modify <CQ_Install_Dir>/crx-quickstart/launchpad/sling.properties to add below properties
* Start the cq
* Verify jsp script etc... by putting into cache.. Same thing like
String key = "k2";
String value = "Hello World from cq!";
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
ClassLoader newLoader = com.tangosol.net.CacheFactory.class.getClassLoader();
NamedCache cache = CacheFactory.getCache("hello-example");
- Option 3 :- The one you are trying by creating an OSGi bundle jar from coherence.jar & prefeerd approach also. I haven't tried this approach but just throughing some thaughts.
* From some of oracle seminors I remembered oracle had a plans to have OSGi jar for Coherence. Try to get that instead of building the one ourself.
* If it is not available then Looking at your problem as a workaround i can think of is try with putting the XML file in the repository & load xml in java class something like as
Thanks Sham for taking the time to put together three options! I tried all three and had the best successful with Option 2. My guess is that registering Coherence with Sling was important. I do occassionally get a "can't start up DistributedCache service" exception which is requiring me to restart CQ5 but hopefully we'll figure out what's causing this by playing around some more.
I am having to make changes to the manifest in the coherence.jar that was manually created to be an OSGi bundle. I really hope that Oracle will spend the time to create an official OSGi compliant jar because this will probably be a lot more stable than what we're creating with our manual efforts.
I'll keep updating this thread with our findings so that it can hopefully help others who are interested in running Coherence in CQ5.
I am new to CQ5.5 so please pardon my ignorance. What exactly does "My guess is that registering Coherence with Sling was important" mean? Can someone please explain how to register Coherence with Sling in CQ5.5