Connect to Arcgis server 10.1 through arcobjects

4495
10
Jump to solution
07-07-2013 06:11 AM
MiraHindawi
New Contributor
Hi
   I used to have an arcobjects JSP page, hosted under sun one, that connects to an 9.3.1 Arcgis server through arcobjects. I have upgraded the server to 10.1, and upgraded the arcobjects jar file to 10.1 too. The page compiled properly but when i execute the code, I got an AutomationException: 0x5 - Access is denied. in 'Invoke' error. I restarted the server and now I am getting a new error: AutomationException: 0x80040154 - Class not registered. The same code used to work on 9.3.1 normally. I've been stuck here for two days now. Any help is highly appreciated. Below is the code that is generating the error:

//------- initialize connection to the server
try
{
  new ServerInitializer().initializeServer(GISServerName, GISServerUserName, GISServerPwd);
  con = new ServerConnection();
  con.connect(GISServerName);
}
catch (Exception err)
{
  out.println("<AnalysisResults>");
  out.println("<err>"+err.toString()+"</err>");
  out.println("</AnalysisResults>");
  return;
  
}//end

Full Error trace as generated by sun one application server:

AutomationException: 0x80040154 - Class not registered
com.esri.arcgis.server.ServerConnection.connect(Unknown Source)
org.apache.jsp.General.NetworkGeo_jsp._jspService(NetworkGeo_jsp.java:265)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:297)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:247)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
sun.reflect.GeneratedMethodAccessor53.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
0 Kudos
1 Solution

Accepted Solutions
LeoDonahue
Occasional Contributor III
Just had a nice talk with ESRI customer service.  Local connections to ArcGIS Server are gone as of 10.1  The online help has not been updated to reflect this yet.

You need to move your business logic to a SOE and hope it's not very painful to change your application to work with your SOE.  SOE's cannot make local connections to the ArcGIS Server either.

You should notice that the way that you access FeatureClasses from msd maps is also different than before.

The exmaples show you can do the following:
FeatureClass fc = new FeatureClass(mapServerDataAccess.getDataSource(mapName,     layerId));

whereas before you had to create this in a server context.

View solution in original post

0 Kudos
10 Replies
MiraHindawi
New Contributor
I just discovered some additional givens.

1- The user that I am currently using to connect to 10.1 arcgis server is named "arcgis". 
2- I still have agsadmin and agsusers groups from the old arcgis 9.3.1 server.

"arcgis" user was not initially in the agsadmin group and i was receiving the "access in invoke" error. If i add the "arcgis" user to either agsadmin or agsusers group, I receive the "class not registered exception". If I remove the user, the "access in invoke" takes place again.

I tried to install arcgis server 10.1 on a different machine, where no previous versions of arcgis for server was installed. I tried the code and the same "access in invoke" error appeared. I checked the groups and there are neither "agsadmin", nor "agsusers" groups available.

I am totally lost. Thanks in advance for any help you can provide.
0 Kudos
RichardWatson
Frequent Contributor
"Class not registered" is likely related to the licensing changes which came in version 10.

This topic has been discussed many times on the forum and elsewhere.  Google on "arcgis 10 bind license".
0 Kudos
MiraHindawi
New Contributor
Carrying on further research, I fell on an article that was written for access denied errors from arcobjects to arcgis server 9.x and not 10.1. The article has instructions of granting proper premissions to arcgis server user on SOC and SOM component services. (http://support.esri.com/en/knowledgebase/techarticles/detail/29516). I followed the article's instructions on both machines that I mentioned above, and the "access denied in invoke" error disappeared. However, the "Class not registered" exception is showing now on both machines. Any ideas?
0 Kudos
MiraHindawi
New Contributor
"Class not registered" is likely related to the licensing changes which came in version 10.

This topic has been discussed many times on the forum and elsewhere.  Google on "arcgis 10 bind license".


Thanks rlwatson for your reply. Excuse my limited experience in development with arcobjects, but I did some research on what you suggested and apparently, this applies when developing with Desktop and Engine only. However, I am developing with Server, by simply adding the JAR file to my WEB-INF folder and trying to connect to arcgis server. I already have an advanced enterprise licensed arcgis for server, with no additional licensed extensions. Do I need any further licensing in the scenario that I have at hand?
0 Kudos
RichardWatson
Frequent Contributor
It applies to server as well.

To be clear, you do not need to purchase something else.

In version 10.0, ESRI changed their logic such that additional steps are now required.
0 Kudos
MiraHindawi
New Contributor
I think that i can no longer use my code in arcgis server 10.1 according to the following quote from esri ArcGIS resources:

"ArcGIS Server versions prior to 10.1 supported both DCOM (ArcGIS Server Local) and HTTP (ArcGIS Server Internet) connections. Version 10.1 no longer supports DCOM connections, and existing applications that use the ArcGIS Server Local connection type will not be able to use services you publish with 10.1. You need to refactor these applications to use HTTP connections before upgrading to 10.1. If you used DCOM connections for the purpose of accessing ArcObjects, you need to remove your ArcObjects code or wrap it in a server object extension."

As far as I know, ArcObjects from JSP pages under sunone use DCOM connections to the server. Therefore, I will have to remove all my ArcObjects codes and develop SOE's (Server Object Extension) instead. Is my understanding right?

Thanks again...
0 Kudos
LeoDonahue
Occasional Contributor III
Unfortunately, ESRI is not very clear on this topic.  I believe when they say local connections to the Server are no longer supported, they are referring to the Web ADF API, not ArcObjects, I could be wrong here.

If you can no longer use the code you posted, then there is no way to connect to a SOE either, because it uses the same approach with ServerInitializer and ServerConnection.

I feel your pain.  Server code that worked in 10.0 no longer works in 10.2 either. 

I have tried the arcgis account, the siteadmin account, added accounts to the map service using manager and then tried using those accounts in the code also.

Supplying a domain name gives me:
AutomationException: 0x5 - Access is denied. in 'Invoke'
    at com.esri.arcgis.server.ServerConnection.connect(Unknown Source)

Removing the domain name gives me:
AutomationException: 0x80040154 - Class not registered
    at com.esri.arcgis.server.ServerConnection.connect(Unknown Source)

import com.esri.arcgis.carto.Map;
import com.esri.arcgis.carto.MapServer;
import com.esri.arcgis.interop.AutomationException;
import com.esri.arcgis.server.IServerContext;
import com.esri.arcgis.server.IServerObjectManager;
import com.esri.arcgis.server.ServerConnection;
import com.esri.arcgis.system.ServerInitializer;
import java.io.IOException;

public class AGSConnection {
    
    private ServerInitializer serverinitializer;
    private ServerConnection connection;
    private IServerObjectManager som;
    private IServerContext context;
    private MapServer mapserver;
    private Map map;

    public AGSConnection(){
        // Initialize server with impersonation information.  <domain> <user name> <password>...
        serverinitializer = new ServerInitializer();
        serverinitializer.initializeServer("", "arcgis", "arcgispassword");

        try {
            // Open a connection to server.
            connection = new ServerConnection();
            connection.connect("arcgis 10.2 server name");

            // Get reference to ServerObjectManager class.
            som = connection.getServerObjectManager();

            // Create a server context... <configName>,<typeName>
            context = som.createServerContext("mapservicefolder/mapservicename", "MapServer");

            // Get a MapServer object from the server context
            mapserver = (MapServer) context.getServerObject();

            // Get the Map from the MapServer object specified by the map (DataFrame) name
            map = (Map) mapserver.getMap("Layers");

        } catch (AutomationException ae) {
            ae.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public ServerInitializer getServerinitializer() {
        return serverinitializer;
    }

    public ServerConnection getConnection() {
        return connection;
    }

    public IServerObjectManager getSom() {
        return som;
    }

    public IServerContext getContext() {
        return context;
    }

    public MapServer getMapserver() {
        return mapserver;
    }

    public Map getMap() {
        return map;
    }

}
0 Kudos
LeoDonahue
Occasional Contributor III
Just had a nice talk with ESRI customer service.  Local connections to ArcGIS Server are gone as of 10.1  The online help has not been updated to reflect this yet.

You need to move your business logic to a SOE and hope it's not very painful to change your application to work with your SOE.  SOE's cannot make local connections to the ArcGIS Server either.

You should notice that the way that you access FeatureClasses from msd maps is also different than before.

The exmaples show you can do the following:
FeatureClass fc = new FeatureClass(mapServerDataAccess.getDataSource(mapName,     layerId));

whereas before you had to create this in a server context.
0 Kudos
MichaelKohler
Occasional Contributor II
Just had a nice talk with ESRI customer service.  Local connections to ArcGIS Server are gone as of 10.1  The online help has not been updated to reflect this yet.


I have spent most of the morning either on the phone with ESRI or looking through these forums for help. I think your saying that I can't do what I need to do using the same methods I used to use. Upgraded from 10.0 to 10.2. Just did the server last weekend. Got an email from my nightly scripts that they failed last night! I'm trying to get an answer and a push in the right direction for a task that went like this for console apps in VB.NET ran nightly


  1. windows task scheduler executes the nightly.exe

  2. app opens

  3. connects to server

  4. stops services

  5. delete data from server

  6. copy data to server

  7. start services


From what I'm gathering... this isn't going to be too easy to do from a single application task running nightly?


Edit:
I was pointed in this direction:
http://resources.arcgis.com/en/help/main/10.2/index.html#/Scripting_ArcGIS_Server_administration/015...
0 Kudos