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:
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
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:
<lh-file-manager><file-name>{cache-name}.store</file-name></lh-file-manager>
with some kind of:
<bdb-store-manager></bdb-store-manager>
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 |
<!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"> |
weblogic-application.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"> |
web.xml |
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > |
*.hbm.xml |
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> |
GWT modules |
<!DOCTYPE module SYSTEM "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd"> |
GWT UI |
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> |
Tangosol / Oracle Coherence |
<!DOCTYPE coherence SYSTEM "coherence.dtd"> |
Log4J |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
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.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
.
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.io.NotSerializableException: org.apache.log4j.Logger
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
:
private final Logger LOG = Logger.getLogger(CsvFileObject.class);
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:
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
).