• POI Bean Example Failing

    By Trevor J Denner 1 decade ago

    Service error

    Error while rendering service
    

    Stack trace

    com.ibm.domino.services.ServiceException: Error while rendering service
        at com.ibm.xsp.extlib.component.rest.CustomService$ScriptServiceEngine.renderService(CustomService.java:304)
        at com.ibm.domino.services.HttpServiceEngine.processRequest(HttpServiceEngine.java:167)
        at com.ibm.xsp.extlib.component.rest.UIBaseRestService._processAjaxRequest(UIBaseRestService.java:252)
        at com.ibm.xsp.extlib.component.rest.UIBaseRestService.processAjaxRequest(UIBaseRestService.java:229)
        at com.ibm.xsp.util.AjaxUtilEx.renderAjaxPartialLifecycle(AjaxUtilEx.java:206)
        at com.ibm.xsp.webapp.FacesServletEx.renderAjaxPartial(FacesServletEx.java:249)
        at com.ibm.xsp.webapp.FacesServletEx.serviceAjaxPartialView(FacesServletEx.java:200)
        at com.ibm.xsp.webapp.FacesServletEx.serviceAjaxPartialViewSync(FacesServletEx.java:169)
        at com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:155)
        at com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
        at com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
        at com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
        at com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576)
        at com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1315)
        at com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:853)
        at com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796)
        at com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565)
        at com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1299)
        at com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:662)
        at com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482)
        at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:350)
        at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:306)
        at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
    Caused by: com.ibm.xsp.exception.EvaluationExceptionEx: Error while executing JavaScript action expression
        at com.ibm.xsp.binding.javascript.JavaScriptMethodBinding.invoke(JavaScriptMethodBinding.java:126)
        at com.ibm.xsp.extlib.component.rest.CustomService$ScriptServiceEngine.renderServiceGet(CustomService.java:312)
        at com.ibm.xsp.extlib.component.rest.CustomService$ScriptServiceEngine.renderService(CustomService.java:263)
        ... 22 more
    Caused by: com.ibm.jscript.InterpretException: Script interpreter error, line=8, col=22: Java method 'processDocument2Stream(biz.webgate.dominoext.poi.component.data.ResourceTemplateSource, java.util.ArrayList)' on java class 'biz.webgate.dominoext.poi.beans.PoiBean' not found
        at com.ibm.jscript.types.JavaAccessObject.call(JavaAccessObject.java:360)
        at com.ibm.jscript.types.FBSObject.call(FBSObject.java:161)
        at com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197)
        at com.ibm.jscript.ASTTree.ASTVariableDecl.interpret(ASTVariableDecl.java:82)
        at com.ibm.jscript.ASTTree.ASTProgram.interpret(ASTProgram.java:119)
        at com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:139)
        at com.ibm.jscript.JSExpression._interpretExpression(JSExpression.java:435)
        at com.ibm.jscript.JSExpression.access$1(JSExpression.java:424)
        at com.ibm.jscript.JSExpression$2.run(JSExpression.java:414)
        at java.security.AccessController.doPrivileged(AccessController.java:310)
        at com.ibm.jscript.JSExpression.interpretExpression(JSExpression.java:410)
        at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:251)
        at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:234)
        at com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:222)
        at com.ibm.xsp.binding.javascript.JavaScriptMethodBinding.invoke(JavaScriptMethodBinding.java:111)
        ... 24 more
     

    Christian I have installed the latest version of POI4XPages and all of the examples work EXCEPT the docx - Word via poiBean which fails with the above "Error while Rendering Service".  I am not sure if this is an issue .. but in my environment I force all HTTP=>HTTPS.  Any help/ thoughts would be appreciated.

    • Outsch....

      By Christian Güdemann 1 decade ago

      .. and to our shame, I had to say, that it fails also in my installation. But the problem was very fast found. We have introduced some new capabilities to the document creation, like creation of tables in documents.

      So we had updated the API and forgotten to check the backwards compatibilty. This is now with version 1.2.5 fixed. Sorry...

      Best regards

      Christian.

      • Having Difficulties Creating "New" Bookmarks

        By Trevor J Denner 1 decade ago

        Christian

        I have the latest code installed (THANK YOU!!) .. I am probably doing something wrong .. but I am having difficulties creating Bookmarks with names other than the ones that you had in your example. 

        To test:

        • I took the SampleContract and copied the first row of your table and changed the name of the placeholder from "name" to "patientname".
        • I inserted a couple of extra paragraphs .. one with "" the other with ""

        updated version attached

        • I added the following line of code to the REST Service   

        lstBM.add(poiBean.buildDocumentBookmark("patientname", sessionScope.name)); 

        The result is that placeholders with the existing names work .. any new ones do not :-(

        Any thoughts/ help in tracking down what I am doing wrong would be appreciated.

         

         

         

         

         

        • Some Questions...

          By Christian Güdemann 1 decade ago

          1. The new placeholder has the same font/ style over all? Means <<......>> has to be in the same size, font and so on. It must be in the same "run" element.

          2. Have you spellchecking switched on? If so, please switch off, Word does something stupids, it writes the spellchecker result in the document and that makes the <<.....>> object unusable, because not in the same run element

          3. Be sure that it is only text, not a bookmark, no field. It's text because text works best.

           

          Hope that helps.

          Is your sampleContract.docx the one you test with? If so, I will double check on my server.

          • Answers

            By Trevor J Denner 1 decade ago

            Christian

            Thank you for your response

            - I have been playing with POI .. so understand it has to be in the same "run" ...

            - I thought I had made and checked that all fonts etc were the same BUT

            - Spellcheck was turned on .. so will try with that off

            - YES the uploaded sample is the one I have been using to test with

          • Placeholder is within a Single Run

            By Trevor J Denner 1 decade ago

            Christian

            I have checked everything in the document and all looks OK .. I also wrote a small agent to run the document through POI to check the paragraphs and runs .. (see attached output)  .. the <> is a single paragraph with a single run.

             

             

          • Placeholders working and have some pieces of the puzzle

            By Trevor J Denner 1 decade ago

            Christian

            I have managed to get new placeholders to work .. I am not sure if this makes sense to you .. and I plan to do some more research later to fully understand the underlying issues .. but so far I believe (using the latest version  of word):

            - Hiding Spellcheck is not enough .. you have to create a style with spellcheck turned off

            http://wordfaqs.mvps.org/MasterSpellCheck.htm#ExemptingText

            - Updating the placeholders also seems to make them unusable .. my presumption is that although I do not have "track changes" on .. somewhere under the covers MS Word is tracking changes .. so changing "name" -> "<>" even if you reset all styles and fonts seems to make the placeholder invalid

            My work around (until I can do more research) is to take the document I want to use .. select all .. copy into notepad .. create a new document with the default style set to not spell check .. and copy/ paste the text from notepad into the document .. save and use that

             

      • Follow on Question

        By Trevor J Denner 1 decade ago

        Christian

        Is there a way to point the BEAN to a file that is either on the file system "c:\test\samplecontract.docx" or to a URL reference "/test.nsf/(vwFiles)/samplecontract/$file/samplecontract.docx" 

        Thanks

        • No,but ther is something better :)

          By Christian Güdemann 1 decade ago

          You can use ITemplateSource its = poiBean.public AttachmentTemplateSource buildAttachmentTemplateSource(String strDB, String strView, String strKey, String strField)

           

          The attachment TemplateSource let you access the attachment in a document. Define the Datebase (server!!db.nsf), the View (lupAttachment), the key to access the document (first column sorted) and the field (body) where the attachment is.

           

          Best regards

           

          • Fantastic Just what I wanted

            By Trevor J Denner 1 decade ago

            Thank You

          • Having Trouble with buildAttachmentTemplateSource

            By Trevor J Denner 1 decade ago

            Christian

            I am having trouble using buildAttachmentTemplateSource .. below is my code .. if I use the line that is commented and a resource that is added to the database .. the code works .. however I cannot get the buildAttachmentTemplate to work.  The ID passed via the scope variable is valid (see results at the bottom of this message) .. I can access the document using the same document ID and view as passed to the poiBean and can retrieve a list of the placeholder fields that are in the document.  I plan to use this list to build the list of bookmarks.  The Word document is contained with a Rich Text field "rtfAttachment" within the document (see attached jpg).

            I have tried multiple variations of the database field .. with full server and database name .. without server (just database name) and without both (since the view is in the same database as the REST service) .. all give a null stream

            Any help/ thoughts/ suggestion as to what I am doing wrong would be appreciated.

            ====================== Code of REST Service

            try {
            //var template = poiBean.buildResourceTemplateSource(null,"IME_CONFIRMATION_LETTER3.docx");
                var strPOIDbName = @Name("[CN]", @Subset(@DbName(), 1)) + "!!" + applicationScope.dbNameEVT
                print ("POIDBName: " + strPOIDbName);
                var strDocId = sessionScope.DocId;
                print ("DocId: " + strDocId);
                var astrItems = DbLookupArray("", "", "session", "unique", "sort", "vwDocProById", strDocId,"txtDocFields_List","[FAILSILENT]");
                print("Items:" + astrItems[0]);
                var template = poiBean.buildAttachmentTemplateSource("","vwDocProById", strDocId,"rtfAttachment");
                var lstBM = new java.util.ArrayList();
                lstBM.add(poiBean.buildDocumentBookmark("dteCreated", "07-Dec-2013"));
                lstBM.add(poiBean.buildDocumentBookmark("name", "Trevor Denner"));
                lstBM.add(poiBean.buildDocumentBookmark("PatientName", "Trevor Denner"));
                lstBM.add(poiBean.buildDocumentBookmark("PatientAddress", "21383 Fultonham Circle"));
                lstBM.add(poiBean.buildDocumentBookmark("PatientCSZ", "Ashburn, VA 20147"));
                lstBM.add(poiBean.buildDocumentBookmark("Claim Number", "134579"));
                lstBM.add(poiBean.buildDocumentBookmark("PatientInjuryDate", "04-Aug-2012"));
                lstBM.add(poiBean.buildDocumentBookmark("PayorFirm", "Nationwide Insurance"));
                lstBM.add(poiBean.buildDocumentBookmark("ApptDate", "03-Jan-2014 2:15pm"));
                lstBM.add(poiBean.buildDocumentBookmark("DoctorName", "James DiTaranto"));
                lstBM.add(poiBean.buildDocumentBookmark("DoctorAddress", "Landsdown somewhere"));
                lstBM.add(poiBean.buildDocumentBookmark("DoctorCSZ", "Ashburn, VA 20147"));

                var result = poiBean.processDocument2Stream(template, lstBM);
                if (result == null) {
                    print("*** ERROR *** Stream Null");
                }
                return new java.io.ByteArrayInputStream(result.toByteArray());
                }
             catch (errRaised){
                 print (errRaised);
                }

            ======================= Console Output

            [40F4:000B-30F4] 12/09/2013 11:50:53 AM  HTTP JVM: DocId: DO08-9E7NB6
            [40F4:000B-30F4] 12/09/2013 11:50:53 AM  HTTP JVM: Items:dteCreated PatientName PatientAddress PatientCSZ ClaimNumber Pa
            tientInjuryDate PayorFirm ApptDate DoctorName DoctorAddress DoctorCSZ DoctorPhone PayorContact PayorFax AttorneyName Att
            orneyFax
            [40F4:000B-30F4] 12/09/2013 11:50:53 AM  HTTP JVM: *** ERROR *** Stream Null
            [40F4:000B-30F4] 12/09/2013 11:50:53 AM  HTTP JVM: com.ibm.jscript.InterpretException: Script interpreter error, line=30, col=56: 'result' is null>

             

            • error-log-0.xml

              By Christian Güdemann 1 decade ago

              Hello Trevor

              Interessting issue. Could you please do the following steps to generate a error-log-0.xml:

              • Restart your http task with (http quit/ lo http).
              • Login and generate the error
              • stop the http server
              • Post the error-log-0.xml

              I hope that I can find some details in the log, where the plugin code maybe fails.

              Best regards

              Christian

              • Error Log

                By Trevor J Denner 1 decade ago

                .. as requested

              • Do You Have Example of Working Code

                By Trevor J Denner 1 decade ago

                Christian

                I am not sure if you have had a chance to look at my problem .. but was wondering if you had an example of working code for buildAttachmentTemplateSource .. or can give me any suggests as to what I might try.

                Server is "AshSDom08/vworkgroup", Database is not in the root directory "mse\mse2012.nsf" .. should this matter? and do I need to escape the "\" .. ie "mse\\mse2012.nsf" .. from my code I know the View and Document Key work .. but the attachment is stored with a rich text field nameds "rtfAttachment" and not "body" .. should this matter?

                Thanks

                 

                 

                 

                • Sorry...

                  By Christian Güdemann 1 decade ago

                  Hi Trevor

                  Sorry I'm currently hard working on my IBM Connect content and the Christmas Edition of Essentials, but I hope that I can go into that Issue in a short time. Could you try in the mean time a "directory/database.nsf" with/ as directory separator?

                  Best regards

                  Christian

                  • We can reproduce

                    By Christian Güdemann 1 decade ago

                    Hi Trevor

                    Good News, Lena has reproduced your error and already isolate the problem.

                    Bad New, I've to fix it. I will post ASAP a new version and let you know.

                    Best Regards

                    Christian

                    • Fixed please use 1.2.6

                      By Christian Güdemann 1 decade ago

                      Hi Trevor

                       

                      Please use Version 1.2.6. This should fix the issue.

                       

                      Best regards

                      Christian

                      • Thank You

                        By Trevor J Denner 1 decade ago

                        Christian

                        Thank you for your quick response .. I am currently away from home visiting family for Christmas with limited access to internet.  I will implement latest version this coming weekend when I return home.

                         

                      • Success :-)

                        By Trevor J Denner 1 decade ago

                        Christian

                        Just loaded and tried the latest version .. this fixed the issue .. Thank You