Search
Calendar
May 2025
S M T W T F S
« Apr    
 123
45678910
11121314151617
18192021222324
25262728293031
Archives

Posts Tagged ‘Coherence*Web’

PostHeaderIcon Failed to start Service “Cluster” (ServiceState=SERVICE_STOPPED, STATE_ANNOUNCE)

Case

I introduced an Oracle Coherence cache withing my application, which is deployed as a WAR within WebLogic  Server. In a first step, I used an instance of Oracle Coherence / Coherence Web already built in WebLogic. Then, for a couple a reasons, I detroyed the Coherence cluster. Deploying the application, the following error appeared:

java.lang.RuntimeException: Failed to start Service "Cluster" (ServiceState=SERVICE_STOPPED, STATE_ANNOUNCE)

Complete Stacktrace

java.lang.RuntimeException: Failed to start Service "Cluster" (ServiceState=SERVICE_STOPPED, STATE_ANNOUNCE)
at com.tangosol.coherence.component.util.daemon.queueProcessor.Service.start(Service.CDB:38)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.start(Grid.CDB:38)
at com.tangosol.coherence.component.net.Cluster.onStart(Cluster.CDB:366)
at com.tangosol.coherence.component.net.Cluster.start(Cluster.CDB:11)
at com.tangosol.coherence.component.util.SafeCluster.startCluster(SafeCluster.CDB:3)

Explanation and Fix

The Coherence cluster view available in WebLogic server is a view of the Tangosol configuration, available in the files tangosol-coherence*.xml of Coherence’s JAR. To fix the issue, create a file tangosol-coherence-override.xml, in your classpath. Fill the file with a minimum content, such as:

<?xml version='1.0'?>
<!DOCTYPE coherence SYSTEM "coherence.dtd">
<coherence>
    <cluster-config>
        <multicast-listener>
            <time-to-live system-property="tangosol.coherence.ttl">0</time-to-live>
            <join-timeout-milliseconds>3000</join-timeout-milliseconds>
        </multicast-listener>
        <unicast-listener>
            <address>127.0.0.1</address>
            <port>8088</port>
            <port-auto-adjust>true</port-auto-adjust>
            <priority>8</priority>
        </unicast-listener>
        <packet-publisher>
            <packet-delivery>
                <timeout-milliseconds>30000</timeout-milliseconds>
            </packet-delivery>
        </packet-publisher>
        <service-guardian>
            <timeout-milliseconds system-property="tangosol.coherence.guard.timeout">35000</timeout-milliseconds>
        </service-guardian>
    </cluster-config>
    <logging-config>
        <severity-level system-property="tangosol.coherence.log.level">5</severity-level>
        <character-limit system-property="tangosol.coherence.log.limit">0</character-limit>
    </logging-config>
</coherence>

Of course, you can amend and improve the file to match your requirements.
NB: in case your file is ignored by Coherence, override the property tangosol.coherence.override with value tangosol-coherence-override.xml.

PostHeaderIcon WebLogic: set a System property within a WAR

Case

You would like to set a System property within an application packaged as a WAR.
Of course, you may modify the launching scripts of your servers, to add an option -DmyPropertyName=myPropertyValue. Sometimes, you would like to avoid such a solution, because updating the property would require an update of the setEnv.* files and therefore a action of the exploitation team.

In my case, I had to set the property tangosol.coherence.cacheconfig, which hints at the configuration file used my Oracle Coherence / Coherence*Web

Fix

The first solution is to set the property in a startup class. For more detials, consult this page: WebLogic: use a startup and/or a shutdown class in a WAR.

Another mean to handle this problematic is to create a servlet, with a code similar to:

public class JonathanBootServlet extends HttpServlet {
    private static final Logger LOGGER = Logger.getLogger(JonathanBootServlet.class);
    private static final String SVN_ID = "$Id$";

    public JonathanBootServlet() {
        super();
        if (LOGGER.isDebugEnabled()){
            LOGGER.debug(SVN_ID);
        }
    }

    public void init(ServletConfig config) throws ServletException {
        if (LOGGER.isDebugEnabled()){
            LOGGER.debug("in init()");
        }
        System.setProperty("tangosol.coherence.cacheconfig", "jonathan-tangosol-coherence.xml");
        super.init(config);
    }
}

Then add the following block in your web.xml:

    <servlet>
        <servlet-name>JonathanBootServlet</servlet-name>
        <servlet-class>lalou.jonathan.weblogic.technical.JonathanBootServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

Ensure this servlet is run before all others (1).

PostHeaderIcon java.lang.NoClassDefFoundError: com/tangosol/run/component/EventDeathException

Case

You have an application which uses Oracle Coherence / Coherence*Web as cache manager. On redeploying the application, you get a stacktrace of which header is:

Exception in thread 'DistributedCache|SERVICE_STOPPED' java.lang.NoClassDefFoundError: com/tangosol/run/component/EventDeathException

Explanation

Indeed, an undeploy operation stops the services of your application. But Coherence is not launched as a service among the others: it should be considered as an independant one. Therefore, you have to stop it before undeploying your application ; otherwise, your classloader is in a confused state, and loses references to classes it had loaded before, but that should now be unloaded.

Fix

You have to stop Oracle Coherence on your application shutdown.

EAR

If your application is packaged as an EAR, then create a shutdown class with the following main():

public class JonathanLalouEARShutdown extends ApplicationLifecycleListener {
   public static void main(String[] args) {
   CacheFactory.shutdown();
   }
}

Add the following block in your weblogic-application.xml, hinting the shutdown class:

<shutdown>
    <shutdown-class>lalou.jonathan.weblogic.JonathanLalouEARShutdown </shutdown-class>
</shutdown>

WAR

If your application is packaged as a WAR, then create a class implementing ServletContextListener, and add the following block in your web.xml:

<listener>
    <listener-class>your.class.implementing.ServletContextListener</listener-class>
</listener>

The detailed procedure is described at this link: WebLogic: use a startup and/or a shutdown class in a WAR

PostHeaderIcon WebLogic: Unresolved Webapp Library references for … coherence-web-spi

Case

I have to integrate Oracle Coherence, or more accurately Coherence*Web, within an application deployed as a WAR in WebLogic 10.3.
Since Oracle bought both BEA and Tangosol, increasing their integration, using Coherence jars implicitely is allowed. Anyway I decided to add the following block in weblogic.xml

    <library-ref>
        <library-name>coherence-web-spi</library-name>
        <specification-version>1.0.0.0</specification-version>
        <implementation-version>1.0.0.0</implementation-version>
        <exact-match>false</exact-match>
    </library-ref>

Then I get this error:

Caused By: weblogic.management.DeploymentException: Error: Unresolved Webapp Library references for
""ServletContext@25681165[app:risklayer-web module:jonathan-lalou.war path:/jonathan-lalou spec-version:null]"", defined in weblogic.xml [Extension-Name: coherence-web-spi, Specification-Version: 1, Implementation-Version: 1.0.0.0, exact-match: false]

Fix

Indeed, I had to deploy Coherence*Web WAR in WebLogic, in the console:
Deployments > Install > select Coherence WAR, eg: C:\jonathan\bea\coherence_3.5\lib\coherence-web-spi.war > Next> Install this deployment as a library > Next > Target your server > Finish