8 Replies Latest reply: Mar 10, 2010 5:20 PM by 666879 RSS

    failed to createDocumentDefinition

    591796
      I'm working with content db sample code. There is a problem when I upload a document.
      I have set "IFS.DOMAIN.WS.CleartextAuthenticationRequiresHttps" to "false".

      The error is from following code:
      Item docDef = fileM.createDocumentDefinition(...);

      The detail of exception is:

      Exception in thread "main" java.lang.RuntimeException: HTTP Error: Code = 401; Reason = Unauthorized; Original URI = http://localhost/content/dav/?docid=40437; Final URI = http://localhost/content/dav/?docid=40437; Dump:
      HTTP/1.1 401 Unauthorized
      Content-Type: text/html
      Date: Tue, 07 Aug 2007 03:30:12 GMT
      WWW-Authenticate: Basic realm="Oracle Content DB"
      Content-Length: 95
      Server: Oracle-Application-Server-10g/10.1.3.1.0 Oracle-HTTP-Server

           at oracle.ifs.fdk.client.impl.BaseProxy.checkHttpError(BaseProxy.java:79)
           at oracle.ifs.fdk.client.impl.FileManagerProxy.createDocumentDefinitions(FileManagerProxy.java:459)
           at oracle.ifs.fdk.client.impl.FileManagerProxy.createDocumentDefinition(FileManagerProxy.java:346)
           at oracle.contentdb.test.Test.upload(Test.java:141)
           at oracle.contentdb.test.Test.upload(Test.java:174)
           at oracle.contentdb.test.Test.upload(Test.java:132)
           at oracle.contentdb.test.Test.main(Test.java:44)

      Thanks for any help.

      Arming Chen
        • 1. Re: failed to createDocumentDefinition
          Simon B.
          I had similar error:
          Check if you specified Options.CONTENTSTREAM with document definition. This can not be used with webservice API:
          Documentation:
          Note: Options.CONTENTSTREAM is only available for in-process clients (such as EventHandler implementations); it is not available for remote clients (over web services).
          • 2. Re: failed to createDocumentDefinition
            mshannon
            The CDB Java and C# development kits actually ship a special (proxy) FileManager class that intercepts the Options.CONTENTSTREAM option for createDocument(s) and createDocumentDefinition(s) and performs behind-the-scenes a standard HTTP DAV PUT call.

            See the FAQ at the following location :-

            http://www.oracle.com/technology/products/contentdb/dev/devfaq.html

            cheers

            Matt.
            • 3. Re: failed to createDocumentDefinition
              Simon B.
              Thanks for info Matt.

              The problem however remains- what could be the reason for 401 Unathorized Error (parameters like IFS.DOMAIN.WS.CleartextAuthenticationRequiresHttps" are set, no proxies used, everything on the same machine). Any hints welcome

              Message was edited by:
              Simon B.
              • 4. Re: failed to createDocumentDefinition
                mshannon
                Are you leveraging Content DB 10.2 production?

                Or are you using the embedded Web Center release of Content DB?

                The CDB java/C# devkit is only certified against 10.2 production CDB. There are API differences between CDB 10.2 and 10.1.3 embedded, and also the DAV server path is different (/content/dav versus /content/npdav).

                This could possibly explain the error.

                There is an undocumented mechanism to switch the CDB java devkit to use the Web Center Content DB dav end-point "npdav" (instead of the default Content DB 10.2 "dav" end-point). This is :-

                Map config = new HashMap();
                config.put(ManagersFactory.CONFIG_SERVER_VERSION, "10.1.3");
                ManagersFactory session = ManagersFactory.login(credential, s_Config.getCDBUrl(), config);

                However, as noted above there are API differences between 10.2 and 10.1.3 (as can be seen in the javadoc)!!! The CDB devkit ships proxies designed only for 10.2 (and not the 10.1.3 release!!!).

                If you want to perform a file upload against 10.1.3 Web Center embedded Content DB, you would need to extract the session cookie obtained from the web service stubs (after authenticating), then supply this to a http client to perform the DAV PUT. When performing the DAV PUT, you need to ensure the DAV url is /content/npdav.

                cheers

                Matt.
                • 5. Re: failed to createDocumentDefinition
                  Simon B.
                  Hi Matt,

                  Thanks for additional info - that pretty much explains encountered problems. I'm using WebCenter edition. As you explained - the problem lies in PUT call.

                  Your solution with that extra setting solved the problem with download. For some reason Upload still throws the 401!!!

                  Alternative that I choose : setting only cookie (session) didnt work (probably did something wrong). But if I authenticated the http connection with username/password everything worked ok. (In my case - basic authentication is used)

                  Here is the relevant code part:

                  ..
                  String userPassword = "USERNAME" + ":" + "PASSWORD";
                  String encoding = new sun.misc.BASE64Encoder().encode (userPassword.getBytes());

                  HttpURLConnection con = (HttpURLConnection)new URL(putUrl).openConnection();
                  con.setRequestProperty ("Authorization", "Basic " + encoding);
                  con.setRequestMethod("PUT");
                  ...
                  // the rest is usual HTTP Put


                  Thanks again for Your help.
                  Best regards
                  Simon

                  null

                  Message was edited by:
                  Simon B.
                  • 6. Re: failed to createDocumentDefinition
                    422463
                    Hello,

                    We have content db 10.2.0.0.1 and we receive the same error on upload when running the provided sample (C# .net developer kit):

                    "
                    System.Exception was caught
                    Message="HTTP Error: Code = 401; Reason = Unauthorized; URI = http://admedi01.consilium.eu.int/content/dav/?docid=279403; Dump:\nSystem.Net.HttpWebResponse"
                    Source="cdbdotnetdevkit"
                    StackTrace:
                    at oracle.ifs.fdk.impl.AbstractManager.CheckHttpError(HttpWebResponse resp)
                    at oracle.ifs.fdk.impl.FileManagerImpl.createDocumentDefinitions(NamedValueSet[] defs, AttributeRequest[] attributes)
                    at oracle.ifs.fdk.impl.FileManagerImpl.createDocumentDefinition(NamedValue[] def, AttributeRequest[] attributes)
                    at oracle.ifs.examples.api.UploadDownload.Main(String[] args) in D:\cdb_dotnetdevkit\cdb\src\oracle\ifs\examples\api\UploadDownload.cs:line 106
                    "

                    except this on the following link (http://www.oracle.com/technology/products/contentdb/dev/devfaq.html#dev-docdef) we found the following:

                    "
                    // Next, retrieve the URL from the returned document definition.
                    // Use a regular HTTP client to perform the HTTP PUT to the destination
                    // URL supplying the source document stream to upload the actual content.
                    // Note: Java clients using the Content DB Development Kit could have supplied
                    // the content stream inline using an Options.CONTENTSTREAM NamedValue.
                    "

                    should we do it in C# by using an HTTP client for PUT?

                    tryed with something like this:

                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://admedi01/content/dav/?docid="+docDef.getId() );
                    request.Method = "PUT";
                    request.ContentLength = data.Length ;
                    request.Credentials = new NetworkCredential("X", "Y");
                    request.ContentType = "text/plain";
                    request.KeepAlive = false;
                    request.ProtocolVersion = HttpVersion.Version10;
                    using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
                    {

                    writer.WriteLine(data );
                    }

                    but I received :

                    "
                    System.Net.WebException was caught
                    Message="The request was aborted: The request was canceled."
                    Source="System"
                    StackTrace:
                    at System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean aborting)
                    at System.Net.ConnectStream.System.Net.ICloseEx.CloseEx(CloseExState closeState)
                    at System.Net.ConnectStream.Dispose(Boolean disposing)
                    at System.IO.Stream.Close()
                    at System.IO.StreamWriter.Dispose(Boolean disposing)
                    at System.IO.TextWriter.Dispose()
                    at oracle.ifs.examples.api.UploadDownload.Main(String[] args) in D:\cdb_dotnetdevkit\cdb\src\oracle\ifs\examples\api\UploadDownload.cs:line 125
                    "


                    how should we do the upload when using the provided WS in C# ? are there any differences between the java dev kit and c# dev kit as suggested in the above link (http://www.oracle.com/technology/products/contentdb/dev/devfaq.html#dev-docdef) ?

                    thanks

                    Edited by: Florin on Sep 24, 2008 10:48 AM
                    • 7. Re: failed to createDocumentDefinition
                      666879
                      I am getting the same exception but my http error code is 404. What is the real cause of this error/exception? Did anyone figure this out?
                      • 8. Re: failed to createDocumentDefinition
                        666879
                        and now I am getting error 500. For the url I am using https. The exception in the application log has the following

                        10/03/10 17:50:31 content: Servlet error
                        javax.servlet.ServletException: internal error: required attributes missing
                        at oracle.ifs.protocols.dav.ecm.EcmDavServlet.doDocumentGetOrHead(EcmDavServlet.java:2405)
                        at oracle.ifs.protocols.dav.ecm.EcmDavServlet.doGetOrHead(EcmDavServlet.java:2287)
                        at oracle.ifs.protocols.dav.ecm.EcmDavServlet.doGet(EcmDavServlet.java:1187)
                        at oracle.ifs.protocols.dav.DavServlet.processRequest(DavServlet.java:2614)
                        at oracle.ifs.protocols.dav.ecm.EcmDavServlet.processRequest(EcmDavServlet.java:3616)
                        at oracle.ifs.protocols.dav.DavServlet.processRequest(DavServlet.java:2396)
                        at oracle.ifs.protocols.dav.DavServlet.service(DavServlet.java:2361)
                        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                        at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.3.0)].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
                        at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
                        at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.3.0)].server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
                        at oracle.ifs.fdk.http.HttpServerManager.doFilter(HttpServerManager.java:103)
                        at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.3.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:670)
                        at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.3.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:341)
                        at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.3.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:816)
                        at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.3.0)].server.http.AJPRequestHandler.run(AJPRequestHandler.java:231)
                        at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.3.0)].server.http.AJPRequestHandler.run(AJPRequestHandler.java:136)
                        at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.3.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
                        at java.lang.Thread.run(Thread.java:534)