Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

With ArcEngine 9.3.1 in java (but I suppose, it's the same in .NET), I'm developping an application which loads a mxd file. This file contains about 20 layers with shapefile, JPG's, TIFF's files. This file is located on a remote server but accessible through windows share.

After instantiating a MapBean, I try to access some information on this object but I get an Exception "Argument is not a com object : null".

Here an extract of my code:

//some code initializing the engine

mapBean = new MapBean();  
mapBean.setDocumentFilename("myMXD.mxd");  
add("Center",mapBean); //adding into javax.swing.JComponent

//some Intructions
int count=mapBean.getLayerCount();

//count is 0 but after some time, it becomes the right value !!

So I tried to wait for some thread having finished their jobs in such way:

Thread thread;  
Thread[] threadArray = new Thread[100];  
int threadCount = Thread.enumerate(threadArray);  
for (int threadIndex = 0; threadIndex < threadCount; threadIndex++) 
{  
    try {  
        thread = threadArray[threadIndex];  
        if (thread.getName().startsWith("RetrieveThread")
                || thread.getName().startsWith("Image Fetcher") )  
        {  
            thread.join();  
            threadIndex = 0;  
            threadCount=Thread.enumerate(threadArray);                                  
       }  
            } catch (Exception ex) {  
                ex.printStackTrace();  
            }  
        }

But it doesn't really help.

Has someone an idea how to know when the MapBean is really ready with all his information ?

Thanks in advance,

Fabien

share|improve this question
1  
Have you tried using LoadMxFile instead of setDocumentFilename? From edndoc.esri.com/arcobjects/9.2/java/api/arcobjects/com/esri/…. –  Michael Todd Mar 15 '11 at 15:45
    
Fabien -- is it possible that the map bean is needing a full path name? –  Luke Mar 15 '11 at 16:23
    
Thanks for your reply but it doesn't help.My map is shown correctly (after a random time) with the setDocumentFilename.I get this: Exception in thread "main" java.lang.IllegalArgumentException: Argument is not a COM object: null at com.esri.arcgis.interop.Dispatch.<init>(Unknown Source) at com.esri.arcgis.carto.ILayerProxy.<init>(Unknown Source) at com.esri.arcgis.carto.IFeatureLayerProxy.<init>(Unknown Source) at com.esri.arcgis.carto.FeatureLayer.<init>(Unknown Source).Is it possible that it comes from a mix Swing component, AWT and Esri's one ? –  Fabien Krzewinski Mar 16 '11 at 14:56
    
I've never used the controls in Java so I'm shooting in the dark here, but have you looked at Loading Map Documents in this set of samples? It mentions that "[w]hen the document is loaded into the pageLayout bean, an onPageLayoutReplaced event is generated". Perhaps you can monitor that event and then perform further processing only after the map has actually been loaded. –  Michael Todd Mar 17 '11 at 16:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.