Hi all,
Can anyone figure out why this exception is getting triggered.

com.marklogic.xcc.exceptions.ServerConnectionException: An existing
connection was forcibly closed by the remote host 




I have two methods with similar logic one for adding new document
another for checking in already existing document the methods are listed
below respecitively.


public String addDocument(String strSourceName, String
strSourceLocation, String strTargetLocation)
                        throws FileAlreadyExistException,
FolderNotFoundException,
                        FileNotFoundException {
                try
                { 
                        System.out.println("before new session content
insertion");
                        
                        File file =  new File(strSourceLocation);
                        strTargetLocation += file.getName();
                        
                        Content content =
ContentFactory.newContent(strTargetLocation,file,ContentCreateOptions.ne
wBinaryInstance()); 
                        session.insertContent(content);
                        
                        System.out.println("after new session content
insertion");
                        
                        session = contentSource.newSession();
        
// the below code is for versioning..............

                        String query = cmsModule + "\n"
+"cms:create('"+file.getName()+"',
doc('"+strTargetLocation+"'),'testuser2')";//removed "/*" from
"cms:create('"+strSourceName+"', doc('/root/"+strSourceName+"')/*)" for
versioning documents other than xml
        
                        AdhocQuery req = session.newAdhocQuery(query);//
Provide the cq-query as a parameter 
                        ResultSequence rs = session.submitRequest(req); 
                        rs.close();
                        session.close();
                        
                        
           }
           catch(Exception e)
           {
                        e.printStackTrace();
           }
           
           return strTargetLocation; 
        }
This method is working fine.............

Now the check in method.......

public boolean checkInDocument(String strFileName, String
strSourceFilePath, String strTargetFilePath)
                        throws InvalidOperationException {
                 ResultSequence rs = null;
                try
                {
                        System.out.println("Before insertion in checkin
method");
                        File file =  new File(strSourceFilePath);
                        strTargetFilePath += file.getName();
                        
                        Content content =
ContentFactory.newContent(strTargetFilePath,file,ContentCreateOptions.ne
wBinaryInstance()); 
                        session.insertContent(content);
                        
                        System.out.println("After insertion in checkin
method");
                        
                        session = contentSource.newSession();

                        String query= cmsModule + "\n" +
"cms:check-in('"+file.getName()+"','testuser')";
                   

                    AdhocQuery req = session.newAdhocQuery(query);  
                    rs = session.submitRequest(req);
                        

                        
                }
                catch(Exception e)
                {
                        e.printStackTrace();
                        return false;
                }finally{
                        rs.close();
                        session.close(); 
                }

                return true;
        }

Here im getting the exception can anyone figure whats the simple mistake
im doing..............

Regards
Venkatesh M S
mob-+91 9980096470
 
When you decide to stand still in life.
You mark the beginning of your end.
 
 








-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ron
Hitchens
Sent: Saturday, January 06, 2007 3:30 AM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] External file uploadinto
marklogicdatabase


    Make sure you're running MarkLogic Server
version 3.1-3 or newer (3.1-4 is the latest).
There was a bug fixed in 3.1-3 where an XCC
request for binary mode was not honored unless
the URI ended in a suffix known to be a binary
file type.

    If you're loading PDF files you definitely
want to load them as binary, not as text.  The
exception you're getting indicates that the
data being sent is not a valid UTF-8 stream.
In the current release all content, except
binary, must be UTF-8 encoded for insertion.

On Jan 5, 2007, at 1:23 AM, Jason Hunter wrote:

> You're telling the server the file is a "TextInstance" but it's a  
> PDF or Word document so it should be expecting binary.  Your  
> comments say you tried binary, but when you did what happened?  I  
> can't imagine it was the same UTF8 error.
>
> -jh-
>
> [EMAIL PROTECTED] wrote:
>> Hi all,
>> As per the below discussion  I made the following change in my code
>> {
>> System.out.println("before new session content insertion");
>>                      
>>              File file =  new File(strSourceLocation);//
>> strSourceLocation==c:/temp/strutsvalidatorframework.pdf
>>              strTargetLocation += file.getName();//
>> strTargetLocation==  /root/strutsvalidatorframework.pdf === marklogic
>> uri
>>                      
>>              Content content =
>> ntentFactory.newContent 
>> (strTargetLocation,file,ContentCreateOptions.newT
>> extInstance()); //tried ContentCreateOptions.newBinaryInstance()
>> instance also.............
>>              session.insertContent(content);
>>                      
>>              System.out.println("after new session content
>> insertion"); }
>> Im getting the below exception.......
>> com.marklogic.xcc.exceptions.XQueryException: XDMP-DOCUTF8SEQ:  
>> Invalid
>> UTF-8 esc
>> ape sequence at /root/Integ-Struts-JSF.doc line 1 -- document is not
>> UTF-8 encod
>> ed
>> in /insert
>> JH can u throw some input regarding this.............
>> Regards
>> Venkatesh M S
>> mob-+91 9980096470
>>  When you decide to stand still in life.
>> You mark the beginning of your end.
>>   -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On Behalf Of Jason
>> Hunter
>> Sent: Thursday, January 04, 2007 12:20 PM
>> To: General Mark Logic Developer Discussion
>> Subject: Re: [MarkLogic Dev General] External file uploadinto
>> marklogicdatabase
>> Happy to help.
>> To insert a document to MarkLogic using XCC does not involve any  
>> XQuery,
>> only Java.  You'll need to call Session.insertContent() as  
>> documented at
>> http://developer.marklogic.com/pubs/3.1/javadoc/com/marklogic/xcc/ 
>> Sessio
>> n.html#insertContent(com.marklogic.xcc.Content)
>> The XCC Developer's Guide (http://developer.marklogic.com/pubs/3.1/ 
>> default.xqy) will give you an overview of XCC, how to make  
>> sessions, pointers to some examples, and all that.
>> -jh-
>> [EMAIL PROTECTED] wrote:
>>>  Hi JH,
>>>
>>> Very Thrilled by your reply.
>>>
>>> Infact we are using XCC APIs!!!!!!!!!!!!!!!!!!!!!
>>>
>>> Below is the detailed explanation.
>>>
>>> Im using struts DynaActionForm to upload File  below is my form and
>>> form bean.
>>>
>>> <form id="form1" name="form1" method="post" action=""
>>> enctype="multipart/form-data">
>>>      <tr>
>>>             <td valign="top" class="bodytxt_bld">Attachment:</td>
>>>                                        <td valign="top"  
>>> class="bodytxt_bld">
>>>                                                       <input  
>>> type="file" name="uploadFile" /></td>
>>>                       <td width="24%" align="left"
>>> class="bodytxt"></td>
>>>                                                     </tr>
>>> </form>
>>>
>>>
>>>
>>>
>>> <form-bean
>>>            name="fileUploadForm"
>>>        type="org.apache.struts.action.DynaActionForm">
>>>                <form-property
>>>         name="uploadFile"
>>>         type="org.apache.struts.upload.FormFile"/>
>>> </form-bean>
>>> Below is my action method code.
>>>
>>>
>>> public ActionForward uploadFile(ActionMapping mapping, ActionForm
>> form,
>>> HttpServletRequest request, HttpServletResponse response) throws
>>> Exception {
>>>
>>>             HttpSession session=request.getSession(false);
>>>             DynaActionForm fileUploadForm=(DynaActionForm)form;
>>>             FileUtil fileUtil=null;
>>>             String uri=null;
>>>             //String strFileName=null;
>>>             String strFileType=null;
>>>             String strFileCategory=null;
>>>             ArrayList fileArray=null;
>>>              int publicationElementInstanceId = 0;
>>>
>>>             try{
>>>                      System.out.println("Inside Publication Upload
>>> Action");
>>>                     FormFile myFile =
>>> (FormFile)fileUploadForm.get("uploadFile");
>>>             String contentType = myFile.getContentType();
>>>             String fileName    = myFile.getFileName();
>>>             //int fileSize       = myFile.getFileSize();
>>>             byte[] fileData    = myFile.getFileData();
>>>
>>>         System.out.println("contentType: " + contentType);
>>>         System.out.println("File Name: " + fileName);
>>>         HierarchyService service = getHierarchyService();
>>>         uri=service.addDocument(fileName,fileData);
>>>         fileUtil=new FileUtil();
>>>         strFileType=fileUtil.getFileType(fileName);
>>>         strFileCategory=fileUtil.getFileCategory(strFileType);
>>>
>>>     
>>>
>> publicationElementInstanceId=Integer.parseInt(request.getParameter 
>> ("publ
>>> icationElementInstanceId"));
>>>     
>>>
>> service.createFile 
>> (uri,strFileType,strFileCategory,publicationElementIns
>>> tanceId);
>>>
>>>     
>>> fileArray=listFileDetails(publicationElementInstanceId,service);
>>>             //req.setAttribute(IPPConstants.FILE_ARRAY,fileArray);
>>>
>>>             }
>>>             catch(Exception e)
>>>             {
>>>                     e.printStackTrace();
>>>                     log.error(e.getMessage());
>>>             }
>>>             System.out.println("fileArray"+fileArray);
>>>             return new
>>>
>> ActionForward("/PublicationElementInstanceAction.do? 
>> action=editPublicati
>>> onElementInstance&nodeID="+publicationElementInstanceId);
>>>     }
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Below is my service method.
>>>
>>> public String addDocument(String fileName,byte[] fileData) throws
>>> Exception {
>>>             String uri = null;
>>>             try{
>>>                     
>>>                     String
>>> destPath=versionControl.getTempFolder()+"\\"+fileName;
>>>             System.out.println("destPath"+destPath);
>>>             FileOutputStream destStr = new FileOutputStream(new
>>> File(destPath));
>>>             InputStream in = new ByteArrayInputStream(fileData);
>>>             int i;
>>>             while((i=in.read()) != -1)
>>>             {
>>>                     destStr.write(i);
>>>             }
>>>                     destStr.close();
>>>                     System.out.println("    here");
>>>                     versionControl.setSession();
>>>                     
>>>                     uri=versionControl.addDocument(fileName,
>>> destPath, null);
>>>                     
>>>                     
>>>             }catch(Exception e)
>>>             {
>>>                     log.error(e.getMessage());      
>>>             }
>>>             return uri;
>>>             
>>>     }
>>>
>>> versionControl is a DAO for marklogic database
>>> Below is the xcc code written to insert File
>>>
>>> public String addDocument(String strSourceName, String
>>> strSourceLocation, String strTargetLocation)
>>>                     throws FileAlreadyExistException,
>>> FolderNotFoundException,
>>>                     FileNotFoundException {
>>>             try
>>>             {                       String modPath = tempFolder +
"/" +
>>> strSourceName;
>>>                     String
>>> query="xdmp:document-load('"+modPath+"',\n <options
>>> xmlns='xdmp:document-load'>\n <uri>" + rootFolder +
>>> "/"+strSourceName+"</uri>\n <repair>full</repair>\n
>>> <permissions>{xdmp:default-permissions()}</permissions>\n
>> </options>)";
>>>     
>>>                     AdhocQuery req = session.newAdhocQuery(query);//
>>> Provide the cq-query as a parameter
>>>                     ResultSequence rs = session.submitRequest(req);
>>>                     rs.close();
>>>                     session.close();
>>>     
>>>                     session = contentSource.newSession();
>>>     
>>>                     query= cmsModule + "\n" +
>>>     
>>> "cms:create('"+strSourceName+"', doc('" + rootFolder +
>>> "/"+strSourceName+"'))";//removed "/*" from
>>> "cms:create('"+strSourceName+"', doc('/root/"+strSourceName+"')/*)"
>> for
>>> versioning documents other than xml
>>>     
>>>                     req = session.newAdhocQuery(query);
>>>                     rs = session.submitRequest(req);
>>>                     rs.close();
>>>                     session.close();
>>>                     
>>>                     
>>>        }
>>>        catch(Exception e)
>>>        {
>>>                     e.printStackTrace();
>>>        }
>>>                return rootFolder+"/"+strSourceName;
>>>     }
>>>
>>>
>>> Im getting the below XCCException
>>>
>>> com.marklogic.xcc.exceptions.XQueryException: SVC-FILOPN:
>>> xdmp:document-load("c:
>>> /temp/WhitePaper.zip", /options) -- File open error: open
>>> 'c:/temp/WhitePaper.zi
>>> p': No such file or directory
>>>
>>> The file is getting uploaded into the Jboss server till that point I
>>> don't face any problem, but when I try to insert the uploaded file
>> into
>>> marklogic database
>>>
>>> Regards
>>> Venkatesh M S
>>> mob-+91 9980096470
>>>  When you decide to stand still in life.
>>> You mark the beginning of your end.
>>>
>>>
>>>
>>> -----Original Message-----
>>> From: [EMAIL PROTECTED]
>>> [mailto:[EMAIL PROTECTED] On Behalf Of Jason
>>> Hunter
>>> Sent: Thursday, January 04, 2007 11:18 AM
>>> To: General Mark Logic Developer Discussion
>>> Subject: Re: [MarkLogic Dev General] External file upload into
>>> marklogicdatabase
>>>
>>> Hi Venkatesh,
>>>
>>> If you simply need to load a file from a client machine and can  
>>> put software on the client machine, then the XCC library is your  
>>> best bet.
>>> It lets you stream a file across the net into MarkLogic.  It is  
>>> to MarkLogic what JDBC is for a relational database.  There are  
>>> Java and .NET versions available at developer.marklogic.com.
>>>
>>> If you're wanting to handle a web browser file upload (RFC 1867)  
>>> then you'll need something on the server that understands the  
>>> special file format with which a browser uploads the file.  If  
>>> you have a Java
>> front
>>> end (aka JBoss), there are lots of Java libraries that can do  
>>> this (Apache has one, and I wrote one myself at http:// 
>>> servlets.com/cos). Tthe Java layer can catch the file(s) and use  
>>> XCC to insert them into MarkLogic (or you could just save them on  
>>> the filesystem and do an xdmp:load() for a dirt simple approach).
>>>
>>> Or if your server is pure XQuery you could write an RFC 1867  
>>> parser in
>>> XQuery or maybe someone on the list has already written one in  
>>> XQuery and would be willing to share.
>>>
>>> If you have another kind of situation, let us know more.
>>>
>>> -jh-
>>>
>>> [EMAIL PROTECTED] wrote:
>>>> hi all,
>>>>  we run our web server(JBOSS) and Marklogic server in two different
>>> machines.
>>>>  i have a requirement where im supposed to upload a file (non-xml)
>> into
>>>> marklogic from client machine(user).
>>>>  xdmp:load("sourcepath","targetpath");
>>>>  i cant use the above function since the sourcepath doesnt
>>> exist........
>>>>  plz give some inputs regarding this.
>>>>  thanks in advance.
>>>>  Regards
>>>> Venkatesh M S
>>>> mob-+91 9980096470
>>>>  When you decide to stand still in life.
>>>> You mark the beginning of your end.
>>>>
>>>> The information contained in this electronic message and any
>>> attachments
>>>> to this message are intended for the exclusive use of the
>> addressee(s)
>>>> and may contain proprietary, confidential or privileged  
>>>> information.
>>> If
>>>> you are not the intended recipient, you should not disseminate,  
>>>> distribute or copy this e-mail. Please notify the sender  
>>>> immediately
>>> and
>>>> destroy all copies of this message and any attachments.
>>>>
>>>> WARNING: Computer viruses can be transmitted via email. The  
>>>> recipient
>>>> should check this email and any attachments for the presence of
>>> viruses.
>>>> The company accepts no liability for any damage caused by any  
>>>> virus transmitted by this email.
>>>>
>>>> www.wipro.com
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------

>> ---
>>>> _______________________________________________
>>>> General mailing list
>>>> [email protected]
>>>> http://xqzone.com/mailman/listinfo/general
>>> _______________________________________________
>>> General mailing list
>>> [email protected]
>>> http://xqzone.com/mailman/listinfo/general
>>>
>>>
>>> The information contained in this electronic message and any
>> attachments to this message are intended for the exclusive use of the
>> addressee(s) and may contain proprietary, confidential or privileged
>> information. If you are not the intended recipient, you should not
>> disseminate, distribute or copy this e-mail. Please notify the sender
>> immediately and destroy all copies of this message and any  
>> attachments.
>>> WARNING: Computer viruses can be transmitted via email. The  
>>> recipient
>> should check this email and any attachments for the presence of  
>> viruses.
>> The company accepts no liability for any damage caused by any virus
>> transmitted by this email.
>>>  www.wipro.com
>>> _______________________________________________
>>> General mailing list
>>> [email protected]
>>> http://xqzone.com/mailman/listinfo/general
>>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://xqzone.com/mailman/listinfo/general
>> The information contained in this electronic message and any  
>> attachments to this message are intended for the exclusive use of  
>> the addressee(s) and may contain proprietary, confidential or  
>> privileged information. If you are not the intended recipient, you  
>> should not disseminate, distribute or copy this e-mail. Please  
>> notify the sender immediately and destroy all copies of this  
>> message and any attachments. WARNING: Computer viruses can be  
>> transmitted via email. The recipient should check this email and  
>> any attachments for the presence of viruses. The company accepts  
>> no liability for any damage caused by any virus transmitted by  
>> this email.
>>  www.wipro.com
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://xqzone.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general

---
Ron Hitchens [EMAIL PROTECTED]  650-655-2351




_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general


The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.
 
www.wipro.com
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to