Posts Tagged ‘Oracle Coherence’
com.tangosol.io.lh.LHIOException:… Primary file, Reading, Group XXX, Frame YYY: End of file reached
Case
Migrating a cache from EhCache to Tangosol / Oracle Coherence, I got the following error when the cache started to be filled:
[java]com.tangosol.io.lh.LHIOException:C:\DOCUME~1\JonathanLalou\LOCALS~1\Temp\jonathanLalouCache.store, Primary file, Reading, Group 880, Frame 880: End of file reached[/java]
Quick Fix
I could not fix the issue itself. The documentation is not abundant on the subject. I never enjoyed working on closed source libraries. Anyway, a quick fix consists in replacing the LH store with a Berkeley DB store, ie replacing:
[xml]<lh-file-manager><file-name>{cache-name}.store</file-name></lh-file-manager>[/xml]
with some kind of:
[xml]<bdb-store-manager></bdb-store-manager>[/xml]
Useful DTD
DTDs are useful when your XML editor take them in account: detecting errors, suggestions, complete statements… For instance, I save much time with IntelliJ IDEA automatic completion ; unlike, Eclipse amazingly does not implement this feature.
Here is a list of some widely used DTDs:
File | DTD |
---|---|
weblogic-application.xml |
[xml]<!DOCTYPE weblogic-application PUBLIC "-//BEA Systems, Inc.//DTD WebLogic Application 7.0.0//EN" "http://www.oracle.com/technology/weblogic/weblogic-application/1.1/weblogic-application.xsd">[/xml] |
weblogic-application.xml |
[xml]<!DOCTYPE weblogic-application PUBLIC "-//BEA Systems, Inc.//DTD WebLogic Application 7.0.0//EN" "http://www.oracle.com/technology/weblogic/weblogic-application/1.1/weblogic-application.xsd">[/xml] |
web.xml |
[xml]<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >[/xml] |
*.hbm.xml |
[xml]<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">[/xml] |
GWT modules |
[xml]<!DOCTYPE module SYSTEM "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">[/xml] |
GWT UI |
[xml]<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">[/xml] |
Tangosol / Oracle Coherence |
[xml]<!DOCTYPE coherence SYSTEM "coherence.dtd">[/xml] |
Log4J |
[xml]<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">[/xml] |
Tangosol and Log4J DTDs are included within their distribution JARs: you have to extract them or to give their path to IntelliJ IDEA.
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]java.lang.RuntimeException: Failed to start Service "Cluster" (ServiceState=SERVICE_STOPPED, STATE_ANNOUNCE)[/java]
Complete Stacktrace
[java]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)[/java]
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]<?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>
[/xml]
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
.
java.io.NotSerializableException: org.apache.log4j.Logger
Case
I use Oracle Coherence (Tangosol) as distributed cache for a given class. This class contains a non-static Log4J’s Logger
as field.
(what a Logger does in an “POJO” is not obvious and requires further development ; let’s say it is used during the development phase, but has nothing to do in a POJO and should be removed later).
When Tangosol tries to put the object in cache, I get this error:
[java]java.io.NotSerializableException: org.apache.log4j.Logger[/java]
Complete stacktrace
java.io.NotSerializableException: org.apache.log4j.Logger at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326) at com.tangosol.util.ExternalizableHelper.writeSerializable(ExternalizableHelper.java:2181) at com.tangosol.util.ExternalizableHelper.writeObjectInternal(ExternalizableHelper.java:2603) at com.tangosol.util.ExternalizableHelper.serializeInternal(ExternalizableHelper.java:2529) at com.tangosol.util.ExternalizableHelper.toBinary(ExternalizableHelper.java:206) at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.DistributedCache$ConverterValueToBinary.convert(DistributedCache.CDB:3) at com.tangosol.util.ConverterCollections$ConverterMap.put(ConverterCollections.java:1566) at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.DistributedCache$ViewMap.put(DistributedCache.CDB:1) at com.tangosol.coherence.component.util.SafeNamedCache.put(SafeNamedCache.CDB:1) at com.lalou.jonathan.business.cache.TypedEhCache.put(TypedEhCache.java:73) at com.lalou.jonathan.business.cache.TypedEhCache.setInCache(TypedEhCache.java:58) at com.lalou.jonathan.business.StringToRequestListTransformer.transform(JonathanTransformer.java:104) at org.mule.transformer.AbstractMessageAwareTransformer.doTransform(AbstractMessageAwareTransformer.java:68) at org.mule.transformer.AbstractTransformer.transform(AbstractTransformer.java:254) at org.mule.DefaultMuleMessage.applyAllTransformers(DefaultMuleMessage.java:621) at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:582) at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:575) at org.mule.DefaultMuleEvent.transformMessage(DefaultMuleEvent.java:326) at org.mule.DefaultMuleEvent.transformMessage(DefaultMuleEvent.java:321) at org.mule.component.simple.PassThroughComponent.doInvoke(PassThroughComponent.java:27) at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:133) at org.mule.component.AbstractComponent.invoke(AbstractComponent.java:161) at org.mule.service.AbstractService.invokeComponent(AbstractService.java:929) at org.mule.model.seda.SedaService.access$100(SedaService.java:56) at org.mule.model.seda.SedaService$ComponentStageWorker.run(SedaService.java:574) at org.mule.work.WorkerContext.run(WorkerContext.java:310) at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061) at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575) at java.lang.Thread.run(Thread.java:619)
Fix
Declare the Logger
as static
:
[java]private final Logger LOG = Logger.getLogger(CsvFileObject.class);[/java]
In my case, the issue was fixed. If it is not, try to declare the Logger
as static transient
, I assume it could help.
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:
[java]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);
}
}[/java]
Then add the following block in your web.xml:
[xml] <servlet>
<servlet-name>JonathanBootServlet</servlet-name>
<servlet-class>lalou.jonathan.weblogic.technical.JonathanBootServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>[/xml]
Ensure this servlet is run before all others (1
).
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:
[java]Exception in thread ‘DistributedCache|SERVICE_STOPPED’ java.lang.NoClassDefFoundError: com/tangosol/run/component/EventDeathException[/java]
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():
[java]public class JonathanLalouEARShutdown extends ApplicationLifecycleListener {
public static void main(String[] args) {
CacheFactory.shutdown();
}
}[/java]
Add the following block in your weblogic-application.xml
, hinting the shutdown class:
[xml]<shutdown>
<shutdown-class>lalou.jonathan.weblogic.JonathanLalouEARShutdown </shutdown-class>
</shutdown>[/xml]
WAR
If your application is packaged as a WAR, then create a class implementing ServletContextListener
, and add the following block in your web.xml
:
[xml]
<listener>
<listener-class>your.class.implementing.ServletContextListener</listener-class>
</listener>
[/xml]
The detailed procedure is described at this link: WebLogic: use a startup and/or a shutdown class in a WAR
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
[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>
[/xml]
Then I get this error:
[java]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][/java]
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