25 Replies Latest reply on May 4, 2017 4:53 AM by qngo RSS
    mkhalid Explorer

    PDFExport not working on Red Hat Linux

    I have installed the PDFExport extension on Thingworx 7.2.4 on my local machine (Windows 10, Tomcat 8), then it works perfectly.

     

    But when I installed on the our production server (Thingworx 7.2.4, Red Hat Linux, Tomcat 8), then createPDF service of the extension remain busy and never ends up ... there is no entry in Application log...

     

    I've created openings inward to the server on ports 10000-10007, but no effects.


    I've created my own extension to generate simple pdf, that extension works and generates pdf file and saves the file into a FileRepository. So there is no issue of creating files on the server.


    Could you help me to use the PDFExport extension on our production server?



      • Re: PDFExport not working on Red Hat Linux
        ttielebein Collaborator

        Do you see any errors in the Application logs when you try to export in your production server?

        • Re: PDFExport not working on Red Hat Linux
          vladimirros Creator

          Hi Mahboob,

           

          I am the creator of the PDF Extension, and I was just made aware of your issue.

          Could you help me by telling me if in your extension you used the getRootPath() method of the FileRepository in order to construct the path for the saved the generated PDF there?

           

          Main thing would be, as Tori asked, to understand if there are any errors in the Application Log - also you might want to check the Tomcat logs as well.

           

          Waiting for your answer on this.

           

          Thanks

          Vladi

            • Re: PDFExport not working on Red Hat Linux
              mkhalid Explorer

              Hi Vladimir,

               

              Thank you for your attention. We are using RHEL on our production server, Tomcat 8 and OpenJdk 8.

               

              I don't find any error line in Application log, because the service CreatePDF never completes (remains in executions).

               

              But I found some lines in Tomcat log, see below. It may indicate the problem..??  BTW, when I installed the PDFExtension in Thingworx on Windows 10. Then createPDF works and it can access to the same Mashup of production server.

               

              -------------------------------------------------------------------- Log lines of Tomcat on our production server -----------------------------------

               

               

               

              RHINO USAGE WARNING: Missed Context.javaToJS() conversion:

               

              Rhino runtime detected object {mgL=com.thingworx.types.primitives.IntegerPrimitive@3c316fad, TF_Water_PH=com.thingworx.types.primitives.NumberPrimitive@4ee34917, TF_Water_COND=com.thingworx.types.primitives.NumberPrimitive@7c384

              ea7, TF_Water_WT=com.thingworx.types.primitives.NumberPrimitive@66dfd097, fetchTimestamp=com.thingworx.types.primitives.DatetimePrimitive@51a497e6, TF_Water_DO=com.thingworx.types.primitives.NumberPrimitive@5dbc734, TF_Water_ORP

              =com.thingworx.types.primitives.NumberPrimitive@3b28ec5e} of class com.thingworx.types.collections.ValueCollection where it expected String, Number, Boolean or Scriptable instance. Please check your code for missing Context.java

              ToJS() call.

              [Port 10002] Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/webkit/network/CookieManager

              [Port 10002]    at com.machinepublishers.jbrowserdriver.JBrowserDriverServer.main(JBrowserDriverServer.java:70)

              [Port 10002] Caused by: java.lang.ClassNotFoundException: com.sun.webkit.network.CookieManager

              [Port 10002]    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

              [Port 10002]    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

              [Port 10002]    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)

              [Port 10002]    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

              [Port 10002]    ... 1 more

               

               

               

              RHINO USAGE WARNING: Missed Context.javaToJS() conversion:

               

              Rhino runtime detected object {Precipitation=com.thingworx.types.primitives.NumberPrimitive@106da9f3, mgL=com.thingworx.types.primitives.IntegerPrimitive@6e2289f7, TF_Water_PH=com.thingworx.types.primitives.NumberPrimitive@68404

              55c, Weather_Temperature=com.thingworx.types.primitives.NumberPrimitive@23cec989, Symbol=Sun, SymbolNumber=com.thingworx.types.primitives.NumberPrimitive@6bc455e4, TF_Water_WT=com.thingworx.types.primitives.NumberPrimitive@62ccd

              0b9, fetchTimestamp=com.thingworx.types.primitives.DatetimePrimitive@15953b02, TF_Water_DO=com.thingworx.types.primitives.NumberPrimitive@6f026576, TF_Water_ORP=com.thingworx.types.primitives.NumberPrimitive@582b76f} of class co

              m.thingworx.types.collections.ValueCollection where it expected String, Number, Boolean or Scriptable instance. Please check your code for missing Context.javaToJS() call.

              [Port 10003] Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/webkit/network/CookieManager

              [Port 10003]    at com.machinepublishers.jbrowserdriver.JBrowserDriverServer.main(JBrowserDriverServer.java:70)

              [Port 10003] Caused by: java.lang.ClassNotFoundException: com.sun.webkit.network.CookieManager

              [Port 10003]    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

              [Port 10003]    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

              [Port 10003]    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)

              [Port 10003]    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

              [Port 10003]    ... 1 more

               

               

               

               

              RHINO USAGE WARNING: Missed Context.javaToJS() conversion:

               

              Rhino runtime detected object {Precipitation=com.thingworx.types.primitives.NumberPrimitive@2cddc2c4, mgL=com.thingworx.types.primitives.IntegerPrimitive@54f42dfd, TF_Water_PH=com.thingworx.types.primitives.NumberPrimitive@57b52271, Weather_Temperature=com.thingworx.types.primitives.NumberPrimitive@45784ab7, Symbol=Sun, SymbolNumber=com.thingworx.types.primitives.NumberPrimitive@7d3e55ee, TF_Water_WT=com.thingworx.types.primitives.NumberPrimitive@5ecae326, fetchTimestamp=com.thingworx.types.primitives.DatetimePrimitive@6233fc6c, TF_Water_DO=com.thingworx.types.primitives.NumberPrimitive@17ddae12, TF_Water_ORP=com.thingworx.types.primitives.NumberPrimitive@6905a032} of class com.thingworx.types.collections.ValueCollection where it expected String, Number, Boolean or Scriptable instance. Please check your code for missing Context.javaToJS() call.

              [Port 10004] Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/webkit/network/CookieManager

              [Port 10004]    at com.machinepublishers.jbrowserdriver.JBrowserDriverServer.main(JBrowserDriverServer.java:70)

              [Port 10004] Caused by: java.lang.ClassNotFoundException: com.sun.webkit.network.CookieManager

              [Port 10004]    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

              [Port 10004]    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

              [Port 10004]    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)

              [Port 10004]    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

              [Port 10004]    ... 1 more

                • Re: PDFExport not working on Red Hat Linux
                  vladimirros Creator

                  Hi Mahboob,

                   

                  Can you see if you have you're using the openJDK - which is not compatible with ThingWorx - it's in the documentation. You should use the Oracle JVM

                   

                  BR,

                  Vladimir

                    • Re: PDFExport not working on Red Hat Linux
                      mkhalid Explorer

                      I have installed Oracle JDK 8 and set configuration in the server to use Oracle JDK and JRE_HOME in Tomcat. But there is no affect and same exception:

                       

                      [Port 10000] Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/webkit/network/CookieManager

                      [Port 10000]    at com.machinepublishers.jbrowserdriver.JBrowserDriverServer.main(JBrowserDriverServer.java:70)

                      [Port 10000] Caused by: java.lang.ClassNotFoundException: com.sun.webkit.network.CookieManager

                      [Port 10000]    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

                      [Port 10000]    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

                      [Port 10000]    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)

                      [Port 10000]    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

                      [Port 10000]    ... 1 more

                    • Re: PDFExport not working on Red Hat Linux
                      qngo Creator

                      Hi,

                       

                      by the way, about the error "RHINO USAGE WARNING: Missed Context.javaToJS() conversion", if the service concerned is called many time, the tomcat's logs size will increase constantly and fill the hard disk space. I had the catalina.out file that occupied ~30 GB !

                        • Re: PDFExport not working on Red Hat Linux
                          mkhalid Explorer

                          I also have noticed the same problem. catalina.out grows very quickly with thousands of the lines "RHINO USAGE WARNING: Missed Context.javaToJS() conversion"

                           

                          BTW, I am not using PDFExport anymore. I did create my own pdf export extension, it generates its own graph and tables, as required by the project.

                            • Re: PDFExport not working on Red Hat Linux
                              vladimirros Creator

                              Hi Mahboob,

                               

                              I am interested to find out how you actually approached this from the layout perspective:

                              -have you created manually (meaning in the extension) the PDF elements inside the PDF file based on some input data (perhaps an infotable)

                              -or have you used another "html page to pdf" library (I used jbrowserdriver, as you know). If yes, than what library did you use?

                               

                              Thanks,

                              Vladimir

                                • Re: PDFExport not working on Red Hat Linux
                                  mkhalid Explorer

                                  Hi Vladimir,

                                   

                                  I have you created manually (meaning in the extension) the PDF elements inside the PDF file based on some input data (perhaps an infotable).


                                  The PDFExport shows only data that fits in one page, but the InfoTable can contain 100 or more rows. The extension I have created can add more pages as the number of rows grow.


                                  Thanks,


                                  Mahboob

                              • Re: PDFExport not working on Red Hat Linux
                                qngo Creator

                                In my case, there's something like:

                                 

                                var data = new Object(); if (data) {...}

                                 

                                Changing the comparison of data solved my problem:

                                 

                                var data = new Object(); if (data != null) {...}

                                 

                                 

                                About the pdf export, I have a use case that I'd like to export a whole mashup (like a screenshot) or some parts in it, to image or pdf. Could you please give me some advices to create that kind of pdf/image export extension ?

                          • Re: PDFExport not working on Red Hat Linux
                            Ravi Upadhyay Communicator

                            We get a NoClassDefFound error when code is compiled with an incompatible version of the class found at runtime. The specific instance I recall is with the apache axis library. There were actually 2 versions on my runtime classpath and it was picking up the out of date and incompatible version and not the correct one, causing a NoClassDefFound error.

                             

                            There could be numerous other reasons , however from the explanation of the issue , it seems to be most appropriate.

                            • Re: PDFExport not working on Red Hat Linux
                              vladimirros Creator

                              Hey guys,

                               

                              Happy New Year!

                              I have seen that the Extension throws this error on the latest Java Runtime - it used to work in the past.

                              When there's any issue with a ThingWorx Labs extension, we can give the source code the extension so that whoever wants can debug/modify it.

                              That's was the original intention of the extensions, and while we mention the "no support" in the Author page for the extension, it doesn't clearly states we can deliver the source code.

                              Would this be ok for you?

                               

                              Best regards,

                              Vladimir

                                • Re: PDFExport not working on Red Hat Linux
                                  qngo Creator

                                  Hi Vladimir Rosu,

                                   

                                  I had the same problem with the new version of March 2017.

                                   

                                  When I execute the service CreatePDF from the Composer, there's an error:

                                  Unable to Invoke Service CreatePDF on PDFExport : Could not launch browser. Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43' System info: host: 'ubuntu', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-21-generic', java.version: '1.8.0_92' Driver info: driver.version: JBrowserDriver

                                   

                                   

                                  The error in Logs Application:

                                  [context: com.thingworx.webservices.context.HttpExecutionContext@75ac754e][message: Unable to Invoke Service CreatePDF on PDFExport : Could not launch browser.

                                   

                                   

                                  The error in Tomcat (catalina.out):

                                  java.lang.NoClassDefFoundError: com/sun/webkit/network/CookieManager

                                        at com.machinepublishers.jbrowserdriver.JBrowserDriverServer.main(JBrowserDriverServer.java:74)

                                  Caused by: java.lang.ClassNotFoundException: com.sun.webkit.network.CookieManager

                                        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

                                        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

                                        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)

                                        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

                                        ... 1 more

                                   

                                   

                                  Based on this issue (Linux: can not start the driver · Issue #186 · MachinePublishers/jBrowserDriver · GitHub), I tried to install the package "openjfx" but it doesn't resolve the problem.

                                   

                                  I tried to replace some .jar in the widget with new version ones but it doesn't work.

                                   

                                  Do you have an idea how I can resolve this issue ?

                                   

                                  Best regards,

                                  Quang-Dung

                                    • Re: PDFExport not working on Red Hat Linux
                                      vladimirros Creator

                                      Hi Quang-Dung,

                                       

                                      I've just tested this version on an CentOS 6.4 machine, with ThingWorx 7.4 and it worked ok with the standard install of the java runtime.

                                      As said before, we are open to give you the source code of the extension to have a starting point if you decide to debug it or to do any modifications to it.

                                      The usecase of the extension is that it saves a whole mashup in a PDF file. If you want to save parts of the mashup, then you can either modify the extension, or provide those areas as separate mashups or, of course, build your own extension.

                                       

                                      Later edit: on linux there's a single issue manifesting in the fact that the path separator that I use in the code is wrong, so the created file is "SystemRepository\\name.pdf".

                                      It still creates the file and it can be viewed.

                                       

                                      Best regards,

                                      Vladimir

                                      • Re: PDFExport not working on Red Hat Linux
                                        qngo Creator

                                        Thank you for your answer. On TWX 7.4 (Ubuntu), I have the same error. The service can't be executed.

                                         

                                        I think the error come from Ubuntu 16.04 (not supported by TWX), but I started installing and using it with help of a PTC consultant. On the readme page of jBrowserDriver, it says that I have to install "sudo apt-get install openjdk-8-jre openjfx" for Ubuntu Xenial 16.04 LTS. And again, "openjdk" is not supported by TWX.

                                         

                                        I wonder if I can do anything if you would share the source code. It's a shame that too many constraints of versions and dependencies prevent the use of this widget. I just need to print all the mashup like a screenshot.

                                          • Re: PDFExport not working on Red Hat Linux
                                            vladimirros Creator

                                            Hi Quang,

                                             

                                            That's an interesting thing regarding that component.

                                            I do think that there are some dependencies - but again, that's valid for any software piece out there.

                                            What I think it would be useful is to actually search for a component library who can (in any language, C, C#, Java) take a HTML page and then save it as a PDF. If you can find that then it would be great.

                                            I suggest another thing, though: please engage in discussions with the jbrowserdriver developer, who can advise on what would be the best course of action. When I developed the extension, in the beginning, I had a bug that he fixed and then my extension worked.

                                             

                                            Now that I think, can't you move to a non-Ubuntu based OS? Or at least test in a VM a cent-os before deciding to move?

                                            It should take a day max to test this...

                                        • Re: PDFExport not working on Red Hat Linux
                                          qngo Creator

                                          I added manually the "jfxrt.jar" from jdk1.8.0_131 to "/usr/lib/jvm/jdk1.8.0_92//jre/lib/ext/". After that, the service CreatePDF gives the error below in Tomcat and the service keeps running in the Composer:

                                           

                                          [2017-05-03T12:16:28.086][Instance 1][Port 44301] Graphics Device initialization failed for :  sw

                                          [2017-05-03T12:16:28.086][Instance 1][Port 44301] Error initializing QuantumRenderer: no suitable pipeline found

                                          [2017-05-03T12:16:28.086][Instance 1][Port 44301] java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found

                                          [2017-05-03T12:16:28.086][Instance 1][Port 44301]       at com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:280)

                                          [2017-05-03T12:16:28.086][Instance 1][Port 44301]       at com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:221)

                                          [2017-05-03T12:16:28.087][Instance 1][Port 44301]       at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:205)

                                          [2017-05-03T12:16:28.087][Instance 1][Port 44301]       at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:209)

                                          [2017-05-03T12:16:28.087][Instance 1][Port 44301]       at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)

                                          [2017-05-03T12:16:28.087][Instance 1][Port 44301]       at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:695)

                                          [2017-05-03T12:16:28.087][Instance 1][Port 44301]       at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)

                                          [2017-05-03T12:16:28.087][Instance 1][Port 44301]       at java.lang.Thread.run(Thread.java:745)

                                          [2017-05-03T12:16:28.087][Instance 1][Port 44301] Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found

                                          [2017-05-03T12:16:28.087][Instance 1][Port 44301]       at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:94)

                                          [2017-05-03T12:16:28.087][Instance 1][Port 44301]       at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)

                                          [2017-05-03T12:16:28.087][Instance 1][Port 44301]       ... 1 more

                                          [2017-05-03T12:16:28.088][Instance 1][Port 44301] java.lang.RuntimeException: No toolkit found

                                          [2017-05-03T12:16:28.088][Instance 1][Port 44301]       at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:217)

                                          [2017-05-03T12:16:28.088][Instance 1][Port 44301]       at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:209)

                                          [2017-05-03T12:16:28.088][Instance 1][Port 44301]       at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)

                                          [2017-05-03T12:16:28.088][Instance 1][Port 44301]       at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:695)

                                          [2017-05-03T12:16:28.088][Instance 1][Port 44301]       at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)

                                          [2017-05-03T12:16:28.088][Instance 1][Port 44301]       at java.lang.Thread.run(Thread.java:745)

                                          [2017-05-03T12:16:28.089][Instance 1][Port 44301]

                                          • Re: PDFExport not working on Red Hat Linux
                                            qngo Creator

                                            I can finally get it to work after installing:

                                            • last build of Orack jdk1.8.0_92 (that contains "jfxrt.jar")
                                            • gtk 2.0 (for JavaFX as required from Oracle)
                                            • openjfx (for jBrowserDriver)

                                             

                                            Now there's another problem. The pdf is created from the mashup re-loaded separately (with the credential giving when calling the service CreatePDF). It's not the same as the one that is already opened. And the user has to enter again the username and password.

                                             

                                            In addition, the mashup reloaded by the service doesn't have any logic of navigation with it. It's possible that the pdf generated contains only the layout of the mashup, without data.

                                              • Re: PDFExport not working on Red Hat Linux
                                                vladimirros Creator

                                                Hi Quang,

                                                The usecase for the extension is generally to save a Report as PDF. The mashups that you deliver as an input must have all their filtering in the URL, so please use URL parameters added to the Link.

                                                The purpose of the service is not to be used directly, as with any other service in ThingWorx (as a general best practice), but to be wrapped into another service where you set all the needed parameters and then execute.

                                                 

                                                BR,

                                                Vladimir

                                                • Re: PDFExport not working on Red Hat Linux
                                                  qngo Creator

                                                  Hi Vladimir,

                                                  I see, thank you for your answer. I will use the extension in that way.

                                                   

                                                  BR,

                                                  Quang-Dung