Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
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?
Do you see any errors in the Application logs when you try to export in your production server?
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
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 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 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 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
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
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
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 !
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.
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
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
I got it. Just be aware that there's a Data Exporter Extension which is doing just that (it can save Excel, PDF and another format).
So to summarize, there are 2 usecases:
-saving to PDF infotables with large amounts of rows that fit in more than one page (your extension and the Data Exporter Extension)
-saving to PDF mashups, useful for single page reports; this uses the HTML layout engine that TW produces.
BR,
Vladimir
Thanks for your advise.
The extension I had created, also generates graphs using JFreeChart api. The Data Export Extension was launched later
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 ?
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.
I have updated Oracle JDK and it has ext/jfxrt.jar. Now I get the following error:
Unable to Invoke Service CreatePDF on PDFExport : Not on FX application thread; currentThread = RMI TCP Connection(2)-10.39.21.4
Even I have created log4j.properties file in lib directory, but I see the following lines in catalina.out file
------------- In catalina.out ------------------
[Port 10000] log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
[Port 10000] log4j:WARN Please initialize the log4j system properly.
[Port 10000] log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Hello, I'm trying the new version of PDFExport (March 2017) and I have the same error. Could you get it to work ?
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
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
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
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.
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...
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]
Hi Quang, I think it's best to speak with the guy who created the component I'm using, jbrowserdriver.
All the errors that you're experiencing are related to this component (and specifically its dependencies).
The project page is available at GitHub - MachinePublishers/jBrowserDriver: A programmable, embeddable web browser driver compatible with the Selenium We…
Again I must ask: is it possible to change the OS for that machine? If you consider the time aspect, it might be a way better solution than trying 2-3 days to make the extension work in your OS.
Best regards,
Vladimir
Hi
I had a similar error on Ubuntu 14 regarding the jar's, but in my case the actual issue is "Graphics Device initialization failed for : sw". I found some information that the following packages should be added "sudo apt-get install libgtk2.0-bin libXtst6 libxslt1.1". I think the reason being that I'm running ThingWorx in a virtual container without a GUI. After installing the above mentioned packages on Ubuntu, the PDF's are now created.
I do however still have the issue mentioned earlier in the thread regarding "\" as the path seperator. So it creates the PDF with the following file name: "SystemRepository\Test.pdf" in the "/ThingworxStorage/repository" folder. This is causing issues as the next action I need to do is to merge multipe PDF's.
Does anybody have a suggestion how I can work around this?
Hi Johan,
I have just tested and it seemed that on ubuntu 14.04 it created the file ok. Can you check and tell me what extension version are you using?
On the other hand, I have just modified slightly the extension, so it should be able to work with self generated certificates, if you're using those for test instances. I will submit it to the marketplace shortly.
I confirm that after running the following command line I was able to generate PDF files in Ubuntu 14.04 properly, without installing Openjfx or OpenJDK. There's a last package I added just to be sure, as a result of a comment on the jbrowserdriver page.
sudo apt-get install libgtk2.0 libxtst6 libxslt1.1 fonts-freefont-ttf libwebkit2gtk-3.0-25
Later edit: updated the PDFExtension.zip to fix wrong filename created in the MergePDF service.
Hi Vladimir
I was using the latest version for the Marketplace. The issue I had was regarding saving the into the repository with the correct file name and location.
I will test the new version and give you feedback.
Regards
Johan
Hi Vladimir
I tested your version and I still have the "Graphics Device initialization failed for : sw" issue. It definitly looks like Ubuntu container items that are missing from Ubuntu running in a virtual container. This is not a problem for me as I now know what to install on Ubuntu to get it working.
I also made some changes & additions to the source code you provided to me. Attached is the updated version. If you would like the source code for it, I can also share that with you.
Regards
Johan
I'm writing up this as an interim solution for whoever would want to use the extension in a RedHat instance.
During a recent test run, I discovered that RedHat requires specific packages to be installed for the extension to work. These are libwebkit2gtk fontconfig freetype.
I'm attaching a new version of the extension, custom built for this situation. It has a specific parameter called „DebugUsefontconfig” in the CreatePDF service. Customers should set to false in case of Redhat instances (I’m mentioning this because the default is true).
Disclaimer: the solution is not elegant; the extension should autodetect this situation but the third party component I’m using does not have this autodetect feature.
Hello
I tried this pach 3.0.2 on Linux Ubuntu 14 LTS & THX 7.4 but i got this exception :
[2018-05-14T14:30:33.200][Instance 1][Port 35315] mai 14, 2018 4:30:33 PM com.sun.webkit.network.URLLoader doRun [2018-05-14T14:30:33.200][Instance 1][Port 35315] AVERTISSEMENT: Unexpected error [2018-05-14T14:30:33.201][Instance 1][Port 35315] java.io.IOException: null: https://192.168.1.180/Thingworx/Runtime/index.html#mashup=M2WineDashboardMashup [2018-05-14T14:30:33.201][Instance 1][Port 35315] at com.machinepublishers.jbrowserdriver.StreamConnection.connect(StreamConnection.java:313) [2018-05-14T14:30:33.201][Instance 1][Port 35315] at com.sun.webkit.network.URLLoader.sendRequest(URLLoader.java:353) [2018-05-14T14:30:33.202][Instance 1][Port 35315] at com.sun.webkit.network.URLLoader.doRun(URLLoader.java:162) [2018-05-14T14:30:33.202][Instance 1][Port 35315] at com.sun.webkit.network.URLLoader.lambda$run$93(URLLoader.java:128) [2018-05-14T14:30:33.202][Instance 1][Port 35315] at java.security.AccessController.doPrivileged(Native Method) [2018-05-14T14:30:33.202][Instance 1][Port 35315] at com.sun.webkit.network.URLLoader.run(URLLoader.java:127) [2018-05-14T14:30:33.203][Instance 1][Port 35315] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [2018-05-14T14:30:33.203][Instance 1][Port 35315] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [2018-05-14T14:30:33.203][Instance 1][Port 35315] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [2018-05-14T14:30:33.203][Instance 1][Port 35315] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [2018-05-14T14:30:33.203][Instance 1][Port 35315] at java.lang.Thread.run(Thread.java:745) [2018-05-14T14:30:33.203][Instance 1][Port 35315] Caused by: java.lang.NullPointerException [2018-05-14T14:30:33.203][Instance 1][Port 35315] at com.machinepublishers.jbrowserdriver.StreamConnection.processHeaders(StreamConnection.java:221) [2018-05-14T14:30:33.203][Instance 1][Port 35315] at com.machinepublishers.jbrowserdriver.StreamConnection.connect(StreamConnection.java:296) [2018-05-14T14:30:33.203][Instance 1][Port 35315] ... 10 more [2018-05-14T14:30:33.203][Instance 1][Port 35315]
Questions :
1/ should I install some graphical packages such as mentionned in some thread even with the option DebugUsefontconfig set to false (it is the default for me). My server is without any graphical interface.
2/ do I need to pass the appkey to the URL even when using the service once logged in ?
Thanks