1 Reply Latest reply: Jan 28, 2008 11:48 AM by 598534 RSS

    Recieving the error ORACLE.FDK.SessionNotConnected

    545598
      Hi there, i wrote a sample code to using Content Service SDK, as follows
      /*
      * ContentSDK.java
      *
      * Created on September 17, 2007, 1:05 PM
      *
      * To change this template, choose Tools | Template Manager
      * and open the template in the editor.
      */

      package org.dr.contentdb;

      import java.net.MalformedURLException;
      import java.net.URL;
      import java.rmi.RemoteException;
      import javax.xml.rpc.ServiceException;
      import oracle.ifs.fdk.Attributes;
      import oracle.ifs.fdk.ContainerManager;
      import oracle.ifs.fdk.ContainerManagerServiceLocator;
      import oracle.ifs.fdk.DomainManager;
      import oracle.ifs.fdk.DomainManagerServiceLocator;
      import oracle.ifs.fdk.FdkConstants;
      import oracle.ifs.fdk.FileManager;
      import oracle.ifs.fdk.FileManagerServiceLocator;
      import oracle.ifs.fdk.Item;
      import oracle.ifs.fdk.NamedValueSet;
      import oracle.ifs.fdk.SecurityManagerServiceLocator;
      import oracle.ifs.fdk.SecurityManager;
      import oracle.ifs.fdk.SessionManager;
      import oracle.ifs.fdk.SessionManagerServiceLocator;
      import oracle.ifs.fdk.UserManagerServiceLocator;
      import org.apache.axis.client.Stub;
      import oracle.ifs.fdk.NamedValue;
      import oracle.ifs.fdk.RemoteLoginManager;
      import oracle.ifs.fdk.RemoteLoginManagerServiceLocator;
      import oracle.ifs.fdk.UserManager;
      import org.apache.axis.transport.http.HTTPConstants;

      /**
      *
      * @author dilip.gowda
      */
      public class ContentSDK {
         
          RemoteLoginManagerServiceLocator rlmsl;
          ContainerManagerServiceLocator cmsl;
          DomainManagerServiceLocator dmsl;
          SessionManagerServiceLocator smsl;
          UserManagerServiceLocator umsl;
          SecurityManagerServiceLocator secsl;
          FileManagerServiceLocator fmsl;
          FileManager fm;
          RemoteLoginManager rlm;
          ContainerManager cm;
          DomainManager dm;
          SessionManager sm;
          UserManager um;
          SecurityManager secm;
          String cookie;
          /** Creates a new instance of ContentSDK */
          public ContentSDK() {
              rlmsl = new RemoteLoginManagerServiceLocator();
              rlmsl.setMaintainSession(true);
              cmsl = new ContainerManagerServiceLocator();
              cmsl.setMaintainSession(true);
              dmsl = new DomainManagerServiceLocator();
              dmsl.setMaintainSession(true);
              smsl = new SessionManagerServiceLocator();
              smsl.setMaintainSession(true);
              umsl = new UserManagerServiceLocator();
              smsl.setMaintainSession(true);
              secsl = new SecurityManagerServiceLocator();
              secsl.setMaintainSession(true);
              fmsl = new FileManagerServiceLocator();
              fmsl.setMaintainSession(true);
          }
         
          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              ContentSDK content = new ContentSDK();
              content.connectContent();
              NamedValue[] grantAtts = content.prepareGrants();
              content.addGrants("/qsoftindia/TestContainer",grantAtts);
              content.logout();
          }
         
          private void connectContent() {
              boolean success;
              rlm = null;
              NamedValue[] attributes = null;
              try {
                  rlm = rlmsl.getRemoteLoginManager(new URL("http://ocs.qsoftindia.com/content/ws/RemoteLoginManager"));
                  rlm.login("orcladmin","<password>",null,null);
                  cookie = (String) ((Stub)rlm)._getCall().getMessageContext().getProperty(HTTPConstants.HEADER_COOKIE);
                  System.out.println(cookie);
                  cm = cmsl.getContainerManager(new URL("http://ocs.qsoftindia.com/content/ws/ContainerManager"));
                  ((Stub)cm)._setProperty(HTTPConstants.HEADER_COOKIE,cookie);
                  dm = dmsl.getDomainManager(new URL("http://ocs.qsoftindia.com/content/ws/DomainManager"));
                  ((Stub)dm)._setProperty(HTTPConstants.HEADER_COOKIE,cookie);
                  sm = smsl.getSessionManager(new URL("http://ocs.qsoftindia.com/content/ws/SessionManager"));
                  ((Stub)sm)._setProperty(HTTPConstants.HEADER_COOKIE,cookie);
                  sm.setSessionMode(FdkConstants.SESSION_MODE_DOMAIN_ADMINISTRATION,null);
                  sm.keepAlive();
                  System.out.println(cookie);
                  um = umsl.getUserManager(new URL("http://ocs.qsoftindia.com/content/ws/UserManager"));
                  ((Stub)um)._setProperty(HTTPConstants.HEADER_COOKIE,cookie);
                  secm = secsl.getSecurityManager(new URL("http://ocs.qsoftindia.com/content/ws/SecurityManager"));
                  ((Stub)secm)._setProperty(HTTPConstants.HEADER_COOKIE,cookie);
                  fm = fmsl.getFileManager(new URL("http://ocs.qsoftindia.com/content/ws/FileManager"));
                  ((Stub)fm)._setProperty(HTTPConstants.HEADER_COOKIE,cookie);
                  fm.resolvePath("/qsoftindia/TestContainer",null);
              } catch (MalformedURLException ex) {
                  System.out.println("failed");
                  ex.printStackTrace();
                  logout();
              } catch (ServiceException ex) {
                  ex.printStackTrace();
                  System.out.println("failed");
                  logout();
              } catch (RemoteException ex) {
                  ex.printStackTrace();
                  System.out.println("failed");
                  logout();
              } catch (Exception ex) {
                  ex.printStackTrace();
                  System.out.println("failed");
                  logout();
              }
             
             
          }
         
          public NamedValue[] newNamedValueArray(Object[][] namevalues) {
              NamedValue[] attributes = new NamedValue[namevalues.length];
              for(int i=0; i<namevalues.length; i++) {
                  NamedValue tmpNamedValue = new NamedValue();
                  tmpNamedValue.setName((String)namevalues[0]);
      tmpNamedValue.setValue(namevalues[i][1]);
      attributes[i] = tmpNamedValue;
      }
      return attributes;
      }



      public void addGrants(String path, NamedValue[] grants) {
      try {
      Item mycontainer = fm.resolvePath(path,null);
      Long id = new Long(mycontainer.getId());
      secm.addGrants(id,grants,null);

      } catch (RemoteException ex) {
      ex.printStackTrace();
      logout();
      } catch (Exception ex) {
      ex.printStackTrace();
      logout();
      }

      }

      public void logout() {
      try {
      rlm.logout();
      } catch (RemoteException ex) {
      ex.printStackTrace();
      }
      }

      private NamedValue[] prepareGrants() {
      NamedValue[] attributes = null;
      NamedValue[] roles1 = null;
      NamedValue[] roles2 = null;
      Item user1 = null;
      Item user2 = null;
      Item libAdminRole;
      Item quotaAdminRole;
      Item secAdminRole;
      try {
      sm.keepAlive();
      user2 = um.getUser("karthik.rajashekar",null);
      user1 = um.getUser("test.user1",null);
      libAdminRole = secm.getRoleByName("WorkspaceAdministrator",null);
      quotaAdminRole = secm.getRoleByName("QuotaAdministrator",null);
      roles1 = newNamedValueArray(new Object[][]{
      {Attributes.GRANTEE,new Long(user1.getId())},
      {Attributes.ROLES,new Long[]{new Long(libAdminRole.getId()),new Long(quotaAdminRole.getId())}}});
      secAdminRole = secm.getRoleByName("SecurityAdministrator",null);
      roles2 = newNamedValueArray(new Object[][]{
      {Attributes.GRANTEE,new Long(user2.getId())},
      {Attributes.ROLES,new Long[]{
      new Long(secAdminRole.getId())
      }}
      });
      NamedValueSet[] secConfig = new NamedValueSet[]{newNamedValueSet(roles1),newNamedValueSet(roles2)};
      attributes = newNamedValueArray(new Object[][]{
      {Attributes.GRANTS,secConfig}
      });
      } catch (RemoteException ex) {
      ex.printStackTrace();
      logout();
      }
      return attributes;
      }

      private NamedValueSet newNamedValueSet(NamedValue[] namedValues) {
      NamedValueSet tmp = new NamedValueSet();
      tmp.setNamedValues(namedValues);
      return tmp;
      }
      }



      When i run it i receive the following exception,
      AxisFault
      faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
      faultSubcode:
      faultString: ORACLE.FDK.SessionError:ORACLE.FDK.SessionNotConnected
      faultActor:
      faultNode:
      faultDetail:
              {http://xmlns.oracle.com/content/ws}fault:<detailedErrorCode xsi:type="xsd:string">ORACLE.FDK.SessionNotConnected</detailedErrorCode><errorCode xsi:type="xsd:string">ORACLE.FDK.SessionError</errorCode><exceptionEntries xsi:type="ns1:ArrayOfFdkExceptionEntry" xsi:nil="true"/><info xsi:type="ns1:ArrayOfNamedValue" xsi:nil="true"/><serverStackTraceId xsi:type="xsd:string"/>
              {http://xml.apache.org/axis/}hostname:ocs.qsoftindia.com

      ORACLE.FDK.SessionError:ORACLE.FDK.SessionNotConnected
              at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
              at java.lang.Class.newInstance0(Class.java:355)
              at java.lang.Class.newInstance(Class.java:308)
              at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:104)
              at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:90)
              at oracle.ifs.fdk.FdkException.getDeserializer(FdkException.java:270)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.apache.axis.encoding.ser.BaseDeserializerFactory.getSpecialized(BaseDeserializerFactory.java:154)
              at org.apache.axis.encoding.ser.BaseDeserializerFactory.getDeserializerAs(BaseDeserializerFactory.java:84)
              at org.apache.axis.encoding.DeserializationContext.getDeserializer(DeserializationContext.java:464)
              at org.apache.axis.encoding.DeserializationContext.getDeserializerForType(DeserializationContext.java:547)
              at org.apache.axis.message.SOAPFaultDetailsBuilder.onStartChild(SOAPFaultDetailsBuilder.java:157)
              at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
              at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1227)
              at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:314)
              at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:281)
              at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:196)
              at oracle.xml.jaxp.JXSAXParser.parse(JXSAXParser.java:288)
              at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
              at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
              at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
              at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
              at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
              at org.apache.axis.client.Call.invokeEngine(Call.java:2765)
              at org.apache.axis.client.Call.invoke(Call.java:2748)
              at org.apache.axis.client.Call.invoke(Call.java:2424)
              at org.apache.axis.client.Call.invoke(Call.java:2347)
              at org.apache.axis.client.Call.invoke(Call.java:1804)
              at oracle.ifs.fdk.UserManagerSoapBindingStub.getUser(UserManagerSoapBindingStub.java:693)
              at org.dr.contentdb.ContentSDK.prepareGrants(ContentSDK.java:196)
              at org.dr.contentdb.ContentSDK.main(ContentSDK.java:83)
      can any help me out with this?