Thread safety bug in XPS Serializer or FixedDocument sequence? "calling thread cannot access this object..."

Every once in a while (500 iterations or more) I'm getting an exception in the static method below stating "calling thread cannot access this object because a different thread owns it".  Thing is, this method references no external objects
and performs no special threading operations.  All of the WPF objects are created and consumed in this method.  The only aspect that is multi-threaded is that this method can get called concurrently on different threads in the same app domain (the
project is a Windows service). That said the fileToDecollate parameter will be unique every time, so there is no "collision" as far as that goes.
Any ideas?   This is maddening and in theory it should not be possible to blow this error.
Exception Information------------------------------------------
System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.
   at System.Windows.Threading.Dispatcher.VerifyAccess()
   at System.Windows.DependencyObject.GetLocalValueEnumerator()
   at System.Windows.Xps.Serialization.SerializersCacheManager.GetTypeDependencyPropertiesCacheItem(Object serializableObject)
   at System.Windows.Xps.Serialization.SerializersCacheManager.GetSerializableDependencyProperties(Object serializableObject)
   at System.Windows.Xps.Serialization.SerializablePropertyCollection.InitializeSerializableDependencyProperties()
   at System.Windows.Xps.Serialization.SerializablePropertyCollection.Initialize(PackageSerializationManager serializationManager, Object targetObject)
   at System.Windows.Xps.Serialization.SerializableObjectContext.CreateContext(PackageSerializationManager serializationManager, Object serializableObject, SerializableObjectContext serializableObjectParentContext, SerializablePropertyContext serializablePropertyContext)
   at System.Windows.Xps.Serialization.ReachSerializer.DiscoverObjectData(Object serializedObject, SerializablePropertyContext serializedProperty)
   at System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(Object serializedObject)
   at System.Windows.Xps.Serialization.FixedDocumentSerializer.SerializeObject(Object serializedObject)
   at System.Windows.Xps.Serialization.ReachDocumentReferenceSerializer.PersistObjectData(SerializableObjectContext serializableObjectContext)
   at System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(Object serializedObject)
   at System.Windows.Xps.Serialization.ReachDocumentReferenceCollectionSerializer.SerializeDocumentReference(Object documentReference)
   at System.Windows.Xps.Serialization.ReachDocumentReferenceCollectionSerializer.SerializeDocumentReferences(SerializableObjectContext serializableObjectContext)
   at System.Windows.Xps.Serialization.ReachDocumentReferenceCollectionSerializer.PersistObjectData(SerializableObjectContext serializableObjectContext)
   at System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(SerializablePropertyContext serializedProperty)
   at System.Windows.Xps.Serialization.ReachSerializer.SerializeProperty(SerializablePropertyContext serializablePropertyContext)
   at System.Windows.Xps.Serialization.ReachSerializer.SerializeProperties(SerializableObjectContext serializableObjectContext)
   at System.Windows.Xps.Serialization.ReachSerializer.SerializeObjectCore(SerializableObjectContext serializableObjectContext)
   at System.Windows.Xps.Serialization.DocumentSequenceSerializer.PersistObjectData(SerializableObjectContext serializableObjectContext)
   at System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(Object serializedObject)
   at System.Windows.Xps.Serialization.XpsSerializationManager.SaveAsXaml(Object serializedObject)
   at System.Windows.Xps.XpsDocumentWriter.SaveAsXaml(Object serializedObject, Boolean isSync)
   at System.Windows.Xps.XpsDocumentWriter.Write(FixedDocumentSequence fixedDocumentSequence)
   at MyCompany.Utilities.Document.XPSDocument.Decollate(String fileToDecollate, String outputPath) in E:\Projects\MyCompany\Utilities\MyCompany.Utilities.Document\XPSDocument.cs:line 358
   at MyCompany.Services.ERM.XPSCapture.Decollate(String fileToDecollate, String outputPath) in E:\Projects\MyCompany\Services\MyCompany.Services.ERM\XPSCapture.cs:line 210
   at MyCompany.Services.ERM.ERMFileProcessor.decollateERMFile(String tempERMFile, IFileCapture fileCapture) in E:\Projects\MyCompany\Services\MyCompany.Services.ERM\ERMFileProcessor.cs:line 1257
   at MyCompany.Services.ERM.ERMFileProcessor.process() in E:\Projects\doc-link\MyCompany\Services\Altec.Services.ERM\ERMFileProcessor.cs:line 354
   at MyCompany.Services.ERM.ERMFileProcessor.Process(ProcessingCompleteCallback callback) in E:\Projects\MyCompany\Services\MyCompany.Services.ERM\ERMFileProcessor.cs:line 90
Additonal Info------------------------------------------
ExceptionManager.MachineName: BTP-30-DEV
ExceptionManager.WindowsIdentity: XXXXX-WA\Bradley
ExceptionManager.FullName: WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
ExceptionManager.AppDomainName: MyCompany.XXXXXXServiceHost.exe
ExceptionManager.ProcessInfo: PID=7392, ThreadID=7816, Managed ThreadID=36, Name=MyCompany.XXXXXXServiceHost, Uptime=00:02:12.2548416
ExceptionManager.ProcessResourceUsage: Working Set=265188 KB, Peak Working Set=525940 KB, Virtual Memory Size=530264 KB, Peak VM Size=809832 KB, Handles=631
ExceptionManager.SystemMemory: Load=81%, Total Physical=3168748 KB, Free Physical=586736 KB, Total PageFile=5213700
publicstaticList<string>
Decollate(stringfileToDecollate,
stringoutputPath)
  // iterate fixed documents and fixed pages, create new XPS files
List<string>
xpsDecFiles = newList<string>();
  using(XpsDocumentxpsSourceDocument
= newXpsDocument(fileToDecollate,
FileAccess.Read))
    FixedDocumentSequencefixedDocSeq
= xpsSourceDocument.GetFixedDocumentSequence();
    intpageNumber = 0;
    foreach(DocumentReferencedocReference
infixedDocSeq.References)
      FixedDocumentsourceFixedDoc
= docReference.GetDocument(false);
      foreach(PageContentpage
insourceFixedDoc.Pages)
        pageNumber++;
        // prepare new fixed doc sequence
FixedDocumentSequencenewFixedDocSeq
= new
FixedDocumentSequence();
DocumentReferencenewDocReference
= new
DocumentReference();
FixedDocumentnewFdoc
= new
FixedDocument();
newDocReference.SetDocument(newFdoc);
// copy the page
PageContentnewPage =
new
PageContent();
newPage.Source = page.Source;
(newPage asIUriContext).BaseUri
= ((IUriContext)page).BaseUri;
// tickle this method... presumably just to load the FixedPage data.
FixedPagenewFixedPage
= newPage.GetPageRoot(false);
// Add page to fixed doc sequence.
newFdoc.Pages.Add(newPage);
// Always do this last: add document reference to fixed doc sequence. 
newFixedDocSeq.References.Add(newDocReference);
// create and save new XPS doc                   
stringdecFileName =
Path.Combine(outputPath,
Path.GetFileNameWithoutExtension(fileToDecollate)
+ "~"+ (pageNumber).ToString()
+ FileExtensions.XPS);
if(File.Exists(decFileName))
File.Delete(decFileName);
XpsDocumentnewXPSDoc
= new
XpsDocument(decFileName,
FileAccess.ReadWrite);
// testing.  thread IDs should be the same.
//Debug.Assert(System.Windows.Threading.Dispatcher.CurrentDispatcher.Thread.ManagedThreadId == newFixedDocSeq.Dispatcher.Thread.ManagedThreadId);
XpsDocument.CreateXpsDocumentWriter(newXPSDoc).Write(newFixedDocSeq);
newXPSDoc.Close();
// add file to list
xpsDecFiles.Add(decFileName);
  returnxpsDecFiles;

I have opened a support case with Microsoft through my employer.  I'm convinced there is some .NET framework code that is not thread safe.  I did put together a test harness app that demonstrates the problem (within 30 seconds or so after
you start it) and I sent that to MS support.  They're looking into it. Anyone else who is curious can download the sample project here:
https://skydrive.live.com/redir?resid=5CBB4B55BCCB2D67!443&authkey=!AGEnR3CKrXUU6E0
Bradley
Bradley P.

Similar Messages

  • Thread cannot access the class variables.

    Hi
    I have below code snippet : (Only section of which I have copied below)
    public class ProcessAppendAction extends HttpServlet implements Runnable{
         public ProcessAppendAction ()
    MI_OS_APPEND port ;
    protected void doGet(
              HttpServletRequest request,
              HttpServletResponse response)
              throws ServletException, IOException {
              //TODO : Implement
    port =
                        (MI_OS_APPEND) obj.getLogicalPort(
                             "MI_OS_APPENDPort",
                             MI_OS_APPEND.class);
    Thread[] threads = new Thread[noOfThreads];
    ProcessAppendAction run = new ProcessAppendAction(req);
                                            Thread th = new Thread(run);
                                            threads[no] = th;          
                                  threads[no].start();
                                  threads[no].join();
    public ProcessAppendAction(DT_REQUEST_APPEND req) {
              this.requestObj = req;
              // TODO Auto-generated constructor stub
    public void run()
              try
                   DT_RESPONSE res = this.port.MI_OS_APPEND(requestObj);
                                  catch(Exception e)
                                       int ch=0;
                                       ch++;
              }     In above code I am successfully creating an object in line :
    port =
                        (MI_OS_APPEND) obj.getLogicalPort(
                             "MI_OS_APPENDPort",
                             MI_OS_APPEND.class);But when I am trying to access this port variable in run method it is giving null.
    Port in my code is a class variable.
    Is it the case that thread cannot access class variable !!

    money321 wrote:
    ok, I have removed join() from just after start().So that now the Servlet can return before the new Thread has finished. Is this what you want?
    First I did invoked all threads and then in second loop i invoked Join on all threads.I don't understand. Why do you need to join() all the threads since you only start one thread in this request. What am I missing?
    >
    Now, my problem.
    It was solved when I substituted the line
    ProcessAppendAction run = new ProcessAppendAction(req)
    with
    ProcessAppendAction run = new ProcessAppendAction(req,port);Of course. Instance variables in Servlet instances are a no-no so passing the 'port' though an instance variable is just wrong.
    >
    That is passes port alongwith req while creating thread object.
    But still if class variables are not thread safe, then it means if I pass object 1 to thread 1.
    And then try to pass object 2 to thread 2, it might be possibility that object 1 of thread 1 might be replaced by object 2.
    So, thread 1 will get an updated value object 2.Yep - that is why you should not use instance variables in Servlets and why they are not thread safe.
    >
    Which is not what I intend to do...:-)

  • Two Threads Sharing the Same Object

    I am learning Java multithreading recently and I really hit the wall when I came to synchronizing data using the synchronized keyword. According to the explanation, synchronized will only work when 2 or more threads are accessing the same object. If there are accessing 2 different objects, they can run the synchronized method in parallel.
    My question now is how to make sure for synchronized method to work, I am actually working with the same and only one object??
    Imagine this:
    Two person with the same account number are trying to access the very ONE account at the same time.
    I suppose the logic will be:
    Two different socket objects will be created. When it comes to the login or authentication class or method, how can I make sure in term of object that the login/authentication class or method will return them only ONE object (because they share the same account), so that they will be qualified for using the synchronized method further down the road?
    Thanks in advance!

    Actually your understanding is wrong. Consider:
    public class MyClass {
      private int someInt;
      private float someFloat;
      private synchronized void someMethod(final int value) {
        if (value > 2000) someInt = 2000;
      private synchronized void someOtherMethod(final float value) {
        if (value > 2.0) someFloat = 1.999f;
    }YOu might think that two different threads can enter this code, one can enter in someOtherMethod() while one is in someMethod(). That is wrong. The fact is that synchronization works by obtaining synchronization locks on a target object. In this case by putting it on the method declaration you are asking for the lock on the 'this' object. This means that only one of these methods may enter at a time. This code would be better written like so ...
    public class MyClass {
      private int someInt;
      private float someFloat;
      private void someMethod(final int value) {�
        synchronized(someInt) {
          if (value > 2000) someInt = 2000;
      private void someOtherMethod(final float value) {
        synchronized(someFloat) {
          if (value > 2.0) someFloat = 1.999f;
    }In this manner you are only locking on the pertinent objects to the method and not on 'this'. This means that both methods can be entered simultaneously by two different threads. However watch out for one little problem.
    public class MyClass {
      private int someInt;
      private float someFloat;
      private void someMethod(final int value) {�
        synchronized(someInt) {
          if (value > 2000) {
            someInt = 2000;
            synchronized (someFloat) {
              someFloat = 0.0f;
      private void someOtherMethod(final float value) {
        synchronized(someFloat) {
          if (value > 2.0) {
            someFloat = 1.99999f;
            synchronized (someInt) {
              someInt = 0;
    }In this case you can have a deadlock. If two threads enter one of these methods at the same time one would be waiting on the lock for someInt and the other on the lock for someFloat. Neither would proceed. The solution to the problem is simple. Acquire all locks in alphabetical order before you use the first.
    public class MyClass {
      private int someInt;
      private float someFloat;
      private void someMethod(final int value) {�
        synchronized (someFloat) {
          synchronized(someInt) {
            if (value > 2000) {
              someInt = 2000;
              someFloat = 0.0f;
      private void someOtherMethod(final float value) {
        synchronized(someFloat) {
          if (value > 2.0) {
            someFloat = 1.99999f;
            synchronized (someInt) {
              someInt = 0;
    }In this manner one thread will block waiting on someFloat and there can be no deadlock.

  • Bug jdev 10.1.3 production: sequences showing up as tables

    Hello,
    A bug I have found: when I generate a script to create database objects (tables & sequences) and choose in the wizard to execute against the DB connection, the sequences are showing up under the "tables" folder in the connection browser (Oracle DB). After I disconnect and re-browse, they are in the correct "sequences" folder.
    Regards,
    John

    Hi John,
    Could you provide more detailed steps to reproduce?
    Thanks,
    Lisa
    JDev QA

  • Ruby threads cannot be used in RubyCocoa without patches to the Ruby interp

    Hi,
    We are getting an error message while running the iTunes U work flow. We get this each time ithe work flow runs it seems. The error message is in the Podcast Producer error log. Here is the error message. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/ge ms/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run': Ruby threads cannot be used in RubyCocoa without patches to the Ruby interpreter
    How can I do this update or fix this problem please?
    Thank you,
    Chip

    Do this:
    http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard/
    You may have to compile ruby...(/usr/local/bin/*) like I did. This worked for me.
    If you already did this, everything will be groovy. Then if you are having trouble with mysql see this: http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/

  • Ruby threads cannot be used in RubyCocoa without patches to the Ruby inter

    I updated a working Podcast Server recently and now it doesn't work.
    I'm getting:
    Ruby threads cannot be used in RubyCocoa without patches to the Ruby interpreter
    Any thoughts on how to fix it.

    You can safely ignore the "Ruby threads cannot be used in RubyCocoa without patches to the Ruby interpreter" message, it has nothing to do with the problems you are having.
    Can you give us more details? Can you not start recordings, are recordings not beings processed, etc?

  • "there were not enough threads in the threadpool object to complete the operation" exception

    Post Author: crystalmatrix
    CA Forum: .NET
    I have a WinForm application using a Crystal Report Viewer control that in turn connects to a CR web service to display report. The client side application runs on WinXP SP1 with .Net framework 1.1, and the server is Win2k with ASP.Net 1.1. I am using CR XI out of the box.
    Users would periodically get "there were not enough threads in the threadpool object to complete the operation." exception when trying to launch the report viewer connected to the web service. The web service is a standard example implementation derived from CrystalDecisions.Web.Services.ReportServiceBase class. The problem usually happens when the user tries to open multiple report viewer forms, but once they get the error, it would continue to happen even after the user shuts down all viewer forms and then tries to launch a new one.
    There are some posts on the web regarding multiple asynchronous HttpWebRequest draining threadpool when running simultaneously and each one taking a long time to complete. However, our reports all run pretty quickly and results are usually returned before the next report starts to run. So my question is: does Crystal Report Viewer control has a problem with web service in that it may hold the HttpWebRequest thread even after the report is returned, or any other problem that may prevents the asynchronous thread being released back to the Threadpool? Anyone has experienced similar problems and has a workaround?
    Any advice is appreciated.

    Find your serial number quickly

  • Bug SDK-17114  flex.effects.Rotate - Selection Glow Is Rotated For All Objects (Not Just Effect.Target)

    Re: Bug SDK-17114 flex.effects.Rotate - Selection Glow Is
    Rotated For All Objects (Not Just Effect.Target) at
    http://bugs.adobe.com/jira/browse/SDK-17114.
    Looks like this bug was fixed as of yesterday - I'd like to know
    when there will be a patch available to users. I bought Flex 3 just
    in the last few weeks, so it would be nice if I could get a free
    patch. However, my main concern is how to do a workaround. I can't
    deliver my application with this problem, and if the patch is not
    available, I don't have an alternative. Is there a way to access
    the selection rectangle object and set its rotation
    explicitly?

    Thanks, Michel.
    I forgot to mention one point about copying shape layers into one shape layer:  when you initially use the Shape Selection tool to select a shape for cutting, make sure the option for the Shape Selection tool is set to "Add to Selection".
    MichelBParis wrote:
    The problem with Elements+ is that it has so many features you soon forget what it can give you !
    Truer words were never spoken! 
    Ken

  • [svn:bz-4.0.0_fixes] 20451: backporting bug fix BLZ-570/ BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error  : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError .

    Revision: 20451
    Revision: 20451
    Author:   [email protected]
    Date:     2011-02-24 08:33:31 -0800 (Thu, 24 Feb 2011)
    Log Message:
    backporting bug fix BLZ-570/BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml. This needs documentation.  Checkintests pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-570
        http://bugs.adobe.com/jira/browse/BLZ-620
    Modified Paths:
        blazeds/branches/4.0.0_fixes/modules/common/src/flex/messaging/errors.properties
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.j ava
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/SerializationContext.java
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/Amf0Input.java
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/Amf3Input.java
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/AmfIO.java

    Dear Pallavi,
    Very useful post!
    I am looking for similar accelerators for
    Software Inventory Accelerator
    Hardware Inventory Accelerator
    Interfaces Inventory
    Customization Assessment Accelerator
    Sizing Tool
    Which helps us to come up with the relevant Bill of Matetials for every area mentioned above, and the ones which I dont know...
    Request help on such accelerators... Any clues?
    Any reply, help is highly appreciated.
    Regards
    Manish Madhav

  • [svn:bz-3.x] 20443: back porting bug fix BLZ-570/ BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error  : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError .

    Revision: 20443
    Revision: 20443
    Author:   [email protected]
    Date:     2011-02-23 21:19:22 -0800 (Wed, 23 Feb 2011)
    Log Message:
    back porting bug fix BLZ-570/BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml. This needs documentation.  Checkintests pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-570
        http://bugs.adobe.com/jira/browse/BLZ-620
    Modified Paths:
        blazeds/branches/3.x/modules/common/src/java/flex/messaging/errors.properties
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/endpoints/AbstractEndpoint.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/SerializationContext.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/Amf0Input.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/Amf3Input.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/AmfIO.java

  • Assertion failed: poll() is a blocking call and cannot be called on the Service thread

    Hi
    We are getting a strange issue, the application successfully joins the cluster but after start failing with following exception.
    The cluster have three nodes storage disabled web-logic and two standalone coherence JVM's, we are using distributed cache with Local scheme
    <Error> (thread=DistributedCache, member=4): Assertion failed: poll() is a blocking call and cannot be called on the Service thread
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.poll(Grid.CDB:5)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.poll(Grid.CDB:11)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$BinaryMap.get(PartitionedCache.CDB:26)
    at com.tangosol.util.ConverterCollections$ConverterMap.get(ConverterCollections.java:1655)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ViewMap.get(PartitionedCache.CDB:1)
    at com.tangosol.coherence.component.util.SafeNamedCache.get(SafeNamedCache.CDB:1)
    at com.thehartford.pi.core.referencedata.dao.cachedaoimpl.ReferenceCacheDAOImpl.getReferenceData(Unknown Source)
    at com.thehartford.pi.core.caching.cachestore.ReferenceCacheStore.load(Unknown Source)
    at com.tangosol.net.cache.ReadWriteBackingMap$CacheLoaderCacheStore.load(ReadWriteBackingMap.java:6132)
    at com.tangosol.net.cache.ReadWriteBackingMap$CacheStoreWrapper.loadInternal(ReadWriteBackingMap.java:5616)
    at com.tangosol.net.cache.ReadWriteBackingMap$StoreWrapper.load(ReadWriteBackingMap.java:4698)
    at com.tangosol.net.cache.ReadWriteBackingMap.get(ReadWriteBackingMap.java:717)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$Storage.get(PartitionedCache.CDB:10)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onGetRequest(PartitionedCache.CDB:23)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$GetRequest.run(PartitionedCache.CDB:1)
    at com.tangosol.coherence.component.net.message.requestMessage.DistributedCacheKeyRequest.onReceived(DistributedCacheKeyRequest.CDB:12)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onMessage(Grid.CDB:34)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onNotify(Grid.CDB:33)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService.onNotify(PartitionedService.CDB:3)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onNotify(PartitionedCache.CDB:3)
    at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:42)
    at java.lang.Thread.run(Thread.java:722)
    ERROR 2013-09-20 09:06:42,515    :  [2013-09-20 09:06:42.515/8740.228 Oracle Coherence GE 3.7.1.0 <Error> (thread=DistributedCache, member=4): Assertion failed: poll() is a blocking call and cannot be called on the Service thread
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.poll(Grid.CDB:5)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.poll(Grid.CDB:11)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$BinaryMap.get(PartitionedCache.CDB:26)
    at com.tangosol.util.ConverterCollections$ConverterMap.get(ConverterCollections.java:1655)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ViewMap.get(PartitionedCache.CDB:1)
    at com.tangosol.coherence.component.util.SafeNamedCache.get(SafeNamedCache.CDB:1)
    at com.thehartford.pi.core.referencedata.dao.cachedaoimpl.ReferenceCacheDAOImpl.getReferenceData(Unknown Source)
    at com.thehartford.pi.core.caching.cachestore.ReferenceCacheStore.load(Unknown Source)
    at com.tangosol.net.cache.ReadWriteBackingMap$CacheLoaderCacheStore.load(ReadWriteBackingMap.java:6132)
    at com.tangosol.net.cache.ReadWriteBackingMap$CacheStoreWrapper.loadInternal(ReadWriteBackingMap.java:5616)
    at com.tangosol.net.cache.ReadWriteBackingMap$StoreWrapper.load(ReadWriteBackingMap.java:4698)
    at com.tangosol.net.cache.ReadWriteBackingMap.get(ReadWriteBackingMap.java:717)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$Storage.get(PartitionedCache.CDB:10)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onGetRequest(PartitionedCache.CDB:23)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$GetRequest.run(PartitionedCache.CDB:1)
    at com.tangosol.coherence.component.net.message.requestMessage.DistributedCacheKeyRequest.onReceived(DistributedCacheKeyRequest.CDB:12)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onMessage(Grid.CDB:34)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onNotify(Grid.CDB:33)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService.onNotify(PartitionedService.CDB:3)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onNotify(PartitionedCache.CDB:3)
              at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:42)

    Hi
    The problem is that you are making a re-entrant call back into a cache service from the service thread or worker thread of a cache service. This is a bad thing to do as you risk deadlocking your cluster by consuming all of the threads in the service. From the stack trace it looks like you are doing a get on a cache which is calling through to a cache store which is then doing a get on another cache.
    For example, you have done a "get" on a cache, that has now consumed a worker thread (call it Thread-1), that thread is calling the cache store which is doing a get on another cache in the same cache service so will now consume another thread (call it Thread-2) so you now have two threads in use, Thread-1 will not return until Thread-2 completes. Now say you had 2 worker threads on your cache service and two "get" calls came in at the same time, Get-1 and Get-2. Both worker threads are now in use so when Get-1 calls the cache store to do a get on the other cache then it has to wait for a worker thread to become free to process the get. The same applies to Get-2, it is calling the cache store and waiting for a thread to become free. The problem is no threads will become free as they are all waiting. Hopefully that is a clear enough explanation of why you get the warning.
    Read this Constraints on Re-entrant Calls - 12c (12.1.2) This is for 12.1.2 but the same applies for any Coherence version.
    JK

  • Interrupting a Thread in a Remote Object?

    HI,
    I am trying to get some thread synchronization to happen between a client and a remote RMI object. Essentially what I am trying to accomplish, is that if I interrupt a call on a blocking method in the remote object, I want the thread to throw the InterruptException. For example, the following code represents what I am trying to accomplish:
    package bca.test.rmi;
    import java.rmi.Naming;
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    import java.rmi.server.UnicastRemoteObject;
    public class InterruptThreadApp {
    RemoteBlockingObjectInt remote = null;
    public static void main(String[] args) throws Exception {
    //Create the remote object
    RemoteBlockingObject obj = new RemoteBlockingObject();
    //bind it to the registry
    Naming.rebind("rmi://localhost/blocking", obj);
    //start the client, or the thread which will access the blocking call remotely
    InterruptThreadApp app = new InterruptThreadApp();
    Thread blocking = null;
    //wait for the thread to start
    synchronized ( app ) {
    blocking = app.startClient();
    app.wait();
    Thread.sleep(2000);
    //now interrupt the thread (note: the remote object should be blocking in
    //the blockingMethod().. this should produce an InterruptException?
    blocking.interrupt();
    public Thread startClient() {
    Thread t = new Thread("Client") {
    public void run() {
    try {
    //get a handle to the stub
    remote = (RemoteBlockingObjectInt) Naming.lookup("rmi://localhost/blocking");
    //now make a call to the blocking method, but first wake up the client
    synchronized ( InterruptThreadApp.this ) {
    InterruptThreadApp.this.notify();
    //now make the blocking call
    remote.blockingMethod();
    catch (InterruptedException e) {
    System.out.println("WooHoo! This is what we want! But it never gets thrown :(");
    catch (Exception e) {
    e.printStackTrace();
    t.start();
    return t;
    package bca.test.rmi;
    import java.rmi.server.UnicastRemoteObject;
    import java.rmi.RemoteException;
    import java.rmi.Remote;
    public class RemoteBlockingObject extends UnicastRemoteObject implements RemoteBlockingObjectInt {
    Object obj = new Object();
    public RemoteBlockingObject() throws RemoteException {
    super();
    public void blockingMethod() throws RemoteException, InterruptedException {
    synchronized (obj) {
    System.out.println("About to block.. so we can be interrupted later");
    obj.wait();
    interface RemoteBlockingObjectInt extends Remote {
    public void blockingMethod() throws RemoteException, InterruptedException;
    When I make a call to "remote.blockingMethod()", it blocks in the remote object (buy just "wait" ing). I want to interrupt this thread, by issuing an Thread.interrupt(). When I do so (I call "blocking.interrupt()"), nothing happens... no exception is thrown.. it just silently fails.
    Ok, so I suppose that we can not interrupt a remote thread.. that is fine. But what if I want to interrupt the RMI thread making the remote call? I don't want it to block forever. How can I "cancel" the remote call?
    Ideally, I would like the remote.blockingMethod() call to throw an InterruptException when I issue an "interrupt()" on the blocking thread. Any suggestions on how I might accomplish this?
    Thanks,
    Bryan

    While you can interrupt the RMI call, you cannot stop the active processing. That is, you cannot force a thread to stop (see the Java API documentation on Thread.stop().)
    Since the Client RMI call is a waiting thread, you need another Client thread to do a secondary RMI call. The trick is to have the new RMI endpoint connection thread on the RMI Server interrupt the original RMI endpoint connection thread.
    The only way you can interrupt an RMI call is to have the endpoint connection thread that runs on the RMI Server be aware that the user may wish to interrupt it.
    The best means of interruption is for the endpoint connection thread to use "worker threads". The endpoint connection thread waits for the workers to finish and is interruptible by both the workers and other endpoint connection threads.
    Another means of interruption is for the endpoint connection thread to segment the task into units of work and check for an interruption between those units of work.
    There are two ways I've done RMI call interruption.
    One is for the Client to pass a unique id (UID -- that uniquely identifies the request) to the Server with the original call. When the Client wishes to interrupt the original call, using the separate thread, it does a new RMI call to the Server passing the UID.
    The new endpoint connection thread, using the UID, interrupts the original endpoint connection thread.
    The major problem with this is the unique id. It absolutely, positively must be unique. Otherwise you run the risk of Client_A purging Client_B's request.
    The second method requires callback. If your Client is behind a firewall then RMI callback is near impossible. In such a case you must come up with a way for the Server to call the Client that is secure (the firewall problem.)
    The Client must export a remote object and pass that remote object to the Server with the original call.
    The endpoint connection thread recognizes the remote object and does a call back to the Client passing information that uniquely identifies itself (UID). Since the Server generates the UID, it can guarantee uniqueness.
    The Client callback implementation runs as a separate thread since the Client is in fact an RMI Server itself (when it did the export.) The Client must save the UID. The Client must start a new thread for the interrupt procedure or inform a waiting thread that the Server called back.
    Just like method one, above, when the Client wishes to interrupt the original call, using the separate thread, it does a new RMI call to the Server passing the UID.
    The new endpoint connection thread, using the UID, interrupts the original endpoint connection thread. Simple.
    For an academic example using call back go over to Jini.org. They have an example called "Cancellation" at:
    http://starterkit-examples.jini.org/
    For a professional, open source implementation of both these methods go over to CoopSoft.com. The Tymeac (Java) projects support canceling both waiting and autonomous requests at:
    http://www.coopsoft.com/JavaProduct.html

  • Make sure 2 threads share the same object

    I have been thinking about this for quite some time. However, I really couldn't figure it out due lack of experience and knowledge.
    I just needed to know how can I make sure that 2 or more threads (after certain checkings that they should share a same common object) will really share the same object.
    For example (to UlrikaJ if you are reading this):
    How can I achieve the following?? Thanks!
    "When James and Ada separately want to access their shared account,two transactions are started that accesses the object associated with that account number."

    Thanks for the answer. You are welcome :-)
    public class Account
       public Account getAccount(String userInput)
         // Some processes to verify the userInput go here.
         return account;
    }//End of Account class
    public UserThread implements Runnable
       private String name;
       private Semaphore s;
       private Account userAccount; //Reference for the Account class
       public UserThread(String name, Semaphore s)
          this.name = name;
          this.s = s;
       }//End of constructor
       public void run()
          for(;;)
              getUserInput(); //Ofcourse the implementation will depend on what you are doing
              s.lock(); //obtain a lock on Semaphore object
              //Entering critical section of the code
              this.userAccount = accountObject.getAccount(userInput);
              //End of critical section of the code.
              s.signal(); //Release the lock so that other thread
              //can access the getAccount() method...irrespective of the
              //variable or the object being used or referred to.
          }//End of for() loop
       }//End of run() method
    } //End of UserThread class
    public class AccountApplication
       public static void main(String args[])
          Semaphore sem = new Semaphore(0);
          //Always initialize the Semaphore with 0 when you create it.
          UserThread user1 = new UserThread("User Number 1",sem);
          UserThread user2 = new UserThread("User Number 2",sem);
          //All threads share the same Semaphore object
          Thread userThread1 = new Thread(user1);
          Thread userThread2 = new Thread(user2);
          userThread1.start();
          userThread2.start();
       }//End of main() method
    }//End of classWell, I have given the outline of the code. I have not compiled or run the program so it might have errors in its syntax.
    Obviously, you will definitely have to change it to suit your requirements. I have just shown you how to protect yur codes' critical section.
    Hope this clears your doubts.
    Vijay :-)

  • A bug! -1120 Ref count for this object is higher then 0

    Hello experts!
    the following code makes an error -1120 Ref count for this object is higher then 0
    but the next code doesn't ...
    who is attentively enough, can find the difference. (is commened out)
    please fix the bug.
    static class Program
            static void Main()
                SAPbouiCOM.SboGuiApi SboGuiApi;
                string sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";
                SboGuiApi = new SAPbouiCOM.SboGuiApi();
                SboGuiApi.Connect(sConnectionString);
               SAPbouiCOM.Application app = SboGuiApi.GetApplication(-1);
                SAPbobsCOM.Company comp = app.Company.GetDICompany() as SAPbobsCOM.Company;
               rs = comp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset) as SAPbobsCOM.Recordset;
               SAPbobsCOM.UserTablesMD userTable = comp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables) as SAPbobsCOM.UserTablesMD;
                userTable.TableName = "MSB_SL";
                userTable.TableDescription = "TableName";
                userTable.TableType = SAPbobsCOM.BoUTBTableType.bott_MasterData;
                int i = userTable.Add();
                Application.Run();
    static class Program
            static void Main()
                SAPbouiCOM.SboGuiApi SboGuiApi;
                string sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";
                SboGuiApi = new SAPbouiCOM.SboGuiApi();
                SboGuiApi.Connect(sConnectionString);
               SAPbouiCOM.Application app = SboGuiApi.GetApplication(-1);
                SAPbobsCOM.Company comp = app.Company.GetDICompany() as SAPbobsCOM.Company;
        // // // rs = comp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset) as SAPbobsCOM.Recordset;
               SAPbobsCOM.UserTablesMD userTable = comp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables) as SAPbobsCOM.UserTablesMD;
                userTable.TableName = "MSB_SL";
                userTable.TableDescription = "TableName";
                userTable.TableType = SAPbobsCOM.BoUTBTableType.bott_MasterData;
                int i = userTable.Add();
                Application.Run();
    Best Regards,
    Alexander Friesen

    Hello
    Remove the following line:
    rs = comp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset) as SAPbobsCOM.Recordset;
    You have created the rs object from ocompany. You would like to execute a query maybe over a table which will be added later on (in your code in the next lines), so who would handle this?
    Remember, the SAP B1 Gui is reconnects (re-reads) when you creating an UDF/UDT/UDO on a database where multiple users logged in.
    Not a bug, 2007 version working like this:
    So always the 1st step is the creation of Tables
    If a table has been created, you must reconnect the DI API !
    Then, every other operation, declaration, object values could come.
    Older versions of SAP B1 was working in a different way: way enabling the creation of UDT/UDO/UDFs in One rutin. I was caused a lot's of problems.
    Regards
    J.
    Edited by: János Nagy on Jun 1, 2010 4:26 PM

  • Cannot stop this thread...

    Hello, I have the following code:boolean kill = false;
    public void go() {
       while (!kill) {
            sleep(3000);
            //do stuff.
    public void stopThread() {
        kill = true;
    }This code doesn't stop it. I cannot seem to stop this thread with the boolean variable. I think its because I have the thread asleep but I'm not sure. How can you stop a thread that sleeps for a period of time?
    Thanks.

    Here's my code: class CreateGui {
    Vector<Thread> threads = new Vector<Thread>();
    //lots of stuff here...
    public void start() {
         Runnable runner;
    runner = new RunThreads();
         Thread t = new Thread(runner);
         t.setName(_code);
         t.start();
         threads.add(t);
    public void stop() {
         RunThreads r = new RunThreads();     
         r.stopThread();     
    class RunThreads implements Runnable {     
         boolean kill = false; 
    public void run() {
         go();
    public void go() {
       while (!kill) {
         try {
         Thread.sleep(3000); .
         } //try          
         catch (InterruptedException ex) {
         ex.printStackTrace(); }
             //do stuff here...     
              } //while
    } //method go
    public void stopThread() {
         kill = true;
    }The user clicks a button to start a thread, and then clicks another button to stop the thread. With this program I am supposed to have up to 26 threads running at once. I know I may not be doing things totally correctly, but that is what I'm trying to accomplish. I can take the harshest criticism: )

Maybe you are looking for

  • Moving a design from Photoshop to DW [was: Now What??]

    Hi All Well I finally was able to design my home page in Photoshop, slice the image, save it as HTML and open it up in Dreamweaver. http://homesalescfl.com/test/index When it comes to adding new pages I am a little confused about a couple of things:

  • How to change the baudrate for NI-USB 8473

    There is a problem about my NI-USB 8473, High speed CAN device. I have a excuted file to operate this CAN, programmed by CVI, but i dont have the source code. It works all fine when i want to change the baudrate. But i have to develop a new prj for t

  • Flash mx v.s flash

    hey guys, i have a simple question. What is the difference between flash pro version 8 and flash mx pro 2004 version 7 i have the flash mx pro 2004 v.7 , but i heard the flash "no mx" pro v.8 is better. is that thru ? and can i do same thing with v8

  • How to produce image map with java servlet?

    Hello, I know the way to produce an image map from a static image. And I also know how to use ServeltOutputStream to generate an image on the fly. But I don't know how to use the dynamically generated image to produce an image map. Can anyone help me

  • VAT on Service Tax + Base Price

    Dear Expert, We have set our tax calculation as VAT on base price but some vendors are charging VAT on Base price+Service tax price, Please advice what changes we have to do to get solution for this. Thanks