SVGGenerator + phantomjs


I’m trying to use SVGGenerator in my Eclipse project (on windows), following this link explanation:

What I don’t understand is this piece of text:
“After installation, PhantomJS should be in your system path. If not, you can set the phantom.exec system property for the JRE to point to the PhantomJS binary.”

I’ve download the executable phantomjs.exe (it’s not necessary installation), and I set this file into WEB-INF folder of my project, and in MyProject > Run As > Run Configuration… > Tomcat v7.0 Server at localhost > Arguments > VM Arguments , I added: -Dphantom.exec=“C:\Users\alfag\Desktop\myproject\eclipsekeplerworkspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\SVGProject\WEB-INF\phantomjs.exe”

But the svg image only have lines, not the whole chart. What is wrong? How can I reference the phantomjs.exe to my project? If I export my project to production .war, what will I have to do?

Thanks for all.

Vaadin Charts uses PhantomJS in the SVGGenerator so it should be available when it’s running. It should be installed in the development machine and also in the production environment.
If it’s in the system path then SVGGenerator should be able to use it without defining phantom.exec property, just like if you type phantomjs in command line.
If it’s not in the system path then phantom.exec should be defined in the execution environment to point to the binary. The packaging of your project shouldn’t change, it should be the same WAR as before, only the property should be set.

Regarding the SVG image having only lines I would create a separate forum thread and add some extra detail about the chart configuration.

Hope this helps,


Thanks for your reply.

I proved the first one, set system path (My computer > Properties > Advanced > Environment Variables > System Variables > Path and edit and add ‘C:\phantomjs’, the path where phantomjs.exe is) but the execution continues throwing the exception: oct 20, 2016 4:55:27 PM com.vaadin.server.DefaultErrorHandler doDefault GRAVE: java.lang.RuntimeException: Cannot run program "phantomjs": CreateProcess error=2, El sistema no puede encontrar el archivo especificado at com.vaadin.addon.charts.util.SVGGenerator.startPhantomJS( at com.vaadin.addon.charts.util.SVGGenerator.getInstance( I proved with cmd, and I can execute phantomjs with no problem:

phantomjs> phantom.exit(0)

[/code]So, I don’t know what is happening :frowning:

I would like to do like above, but for this:

If it's not in the system path then phantom.exec should be defined in the execution environment to point to the binary. what do I have to do? Please, explain step by step because I’m not used to do those things.

Thanks for all. Best regards.

I solved my problem using the second solution in localhost:

  1. Select the project > Right click > Run As > Run Configurations…
  2. Apache Tomcat > Tomcat v7.0 Server at localhost
  3. Arguments Tab > VM arguments > add this: -Dphantom.exec=“C:\phantomjs\phantomjs.exe”

It works fine, and I expect it works setting it in Java tab in Tomcat interface.

I would also like to get the first solution, because I edited the PATH system variable but it doesn’t work.

I want to comment that I solved the problem of only lines in svg file. It happens because svg format doesn’t accept special symbols and characters like º and ñ .

I have deployed my web application that includes SVGGenerator using phantom JS in Linux 64-bit.
Downloaded phantomjs-2.1.1-linux-x86_64.tar.bz2 and extract the content at “/opt/tomcat/webapps/myapp”

Follwing is that how I set the system property in my java code:
System.setProperty(“phantom.exec”, “opt/tomcat/webapps/myapp/phantomjs-2.1.1-linux-x86_64/bin/phantomjs”);
What should I have to do?

Thanks all.

I got this error as below:

java.lang.NullPointerException: null at com.vaadin.addon.charts.util.SVGGenerator.startPhantomJS( ~[vaadin-charts-4.2.0.jar:4.2.0]

at com.vaadin.addon.charts.util.SVGGenerator.getInstance( ~[vaadin-charts-4.2.0.jar:4.2.0

I put phantomjs (binary) in the WEB-INF folder.
I set the system property to path ‘./Web-inf’. The war is deploy in Sap Scp.
I got this error :
java.lang.NullPointerException: null at…

Any idea?

Thanks all