Windows下的Highcharts-Export Server 2.0.1错误

编辑:解决方案是将所有phatomJS相关脚本放入Scripts目录,并确保没有任何项目是Windows的只读。 我的脚本和phantomjs.exe都存在于此处: C:\jetty-distribution-9.0.0.M3\webapps\ROOT\Scripts\phantomjs

app.properties文件具有以下配置:

 # location of the phantomjs executable, could be for example /usr/local/bin/phantomjs exec = C:/jetty-distribution-9.0.0.M3/webapps/ROOT/Scripts/phantomjs/phantomjs.exe # location of convert script used by phantomjs, optional to leave the script property empty, than it's using the script located in: /WEB-INF/phantomjs/highcharts-convert.js. This is tested in TOMCAT, but specify a path if resource loading isn't working with the classloader (fe with Jetty server), script = a/path/to/my/phantomjs-script.js script = C:/jetty-distribution-9.0.0.M3/webapps/ROOT/Scripts/phantomjs/highcharts-convert.js 

我现在可以通过这里加载的示例导出http://localhost:8080/highcharts-export/demo并通过我们的网站使用url: 'http://localhost:8080/highcharts-export/'调用它url: 'http://localhost:8080/highcharts-export/'

编辑: 有没有人有一个工作的app.properties文件在Windows和Jetty下工作?

我通过对app.properties进行此修改来解决下面列出的一些问题:

 # location of the phantomjs executable, could be for example /usr/local/bin/phantomjs exec = "C:\\jetty-distribution-9.0.0.M3\\webapps\\ROOT\\Scripts\\phantomjs\\phantomjs.exe" # location of convert script used by phantomjs, optional to leave the script property empty, than it's using the script located in: /WEB-INF/phantomjs/highcharts-convert.js. This is tested in TOMCAT, but specify a path if resource loading isn't working with the classloader (fe with Jetty server), script = a/path/to/my/phantomjs-script.js script = /WEB-INF/phantomjs/highcharts-convert.js 

exec值的其他变体具有相同的结果:

 C:\\jetty-distribution-9.0.0.M3\\webapps\\ROOT\\Scripts\\phantomjs\\phantomjs.exe C:/jetty-distribution-9.0.0.M3/webapps/ROOT/Scripts/phantomjs/phantomjs.exe C:\jetty-distribution-9.0.0.M3\webapps\ROOT\Scripts\phantomjs\phantomjs.exe 

我现在可以在http://localhost:8080/highcharts-export/demo但是看看jetty的输出我充斥着类似的东西:

  [ERROR] [pool-1-thread-1 02:55:19] (TaskUtils.java:handleError:95) Unexpected error occurred in sche duled task. java.lang.RuntimeException: Error, PhantomJS couldnot start at com.highcharts.export.server.Server.(Server.java:56) at com.highcharts.export.pool.ServerObjectFactory.create(ServerObjectFactory.java:36) at com.highcharts.export.pool.ServerObjectFactory.create(ServerObjectFactory.java:14) at com.highcharts.export.pool.AbstractPool.createObject(AbstractPool.java:26) at com.highcharts.export.pool.AbstractPool.poolCleaner(AbstractPool.java:66) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnabl e.java:64) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErro rHandlingRunnable.java:53) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source) at java.util.concurrent.FutureTask.runAndReset(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown S ource) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 

下面的原始问题:这是对这个问题的跟进。 我现在可以成功(至少根据maven)构建最新的highcharts-export服务器。 我只修改了app.properties文件,如下所示:

 # location of the phantomjs executable, could be for example /usr/local/bin/phantomjs exec = C:/jetty-distribution-9.0.0.M3/webapps/ROOT/Scripts/phantomjs 

无论phatomjs的位置配置如何,我都会收到下面列出的错误。

但是,当我将它加载到jetty时,我收到以下错误,无法解决此问题。

 C:\hc-exporter>mvn jetty:run [INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for com.highcharts.expor t:highcharts-export:war:2.0.1 [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-eclipse-plugin is missin g. @ line 150, column 12 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed pro jects. [WARNING] [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building highcharts-export 2.0.1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] >>> jetty-maven-plugin:8.1.2.v20120308:run (default-cli) @ highcharts-export >>> [INFO] [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ highcharts-export --- [debug] execute contextualize [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 2 resources [INFO] [INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ highcharts-export --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ highcharts-export --- [debug] execute contextualize [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory C:\hc-exporter\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ highcharts-export --- [INFO] No sources to compile [INFO] [INFO] <<< jetty-maven-plugin:8.1.2.v20120308:run (default-cli) @ highcharts-export <<< [INFO] [INFO] --- jetty-maven-plugin:8.1.2.v20120308:run (default-cli) @ highcharts-export --- [INFO] Configuring Jetty for project: highcharts-export [INFO] webAppSourceDirectory C:\hc-exporter\src\main\webapp does not exist. Defaulting to C:\hc-expo rter\src\main\webapp [INFO] Reload Mechanic: manual [INFO] Classes = C:\hc-exporter\target\classes [INFO] Added extra scan target:C:\hc-exporter\src\main\webapp\WEB-INF\pages [INFO] Added extra scan target:C:\hc-exporter\src\main\webapp\resources [INFO] Context path = /export [INFO] Tmp directory = C:\hc-exporter\target\tmp [INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml [INFO] Web overrides = none [INFO] web.xml file = file:/C:/hc-exporter/src/main/webapp/WEB-INF/web.xml [INFO] Webapp directory = C:\hc-exporter\src\main\webapp 2013-05-21 09:00:07.656:INFO:oejs.Server:jetty-8.1.2.v20120308 2013-05-21 09:00:07.987:INFO:oejpw.PlusConfiguration:No Transaction manager found - if your webapp r equires one, please configure one. 2013-05-21 09:00:09.162:INFO:/export:No Spring WebApplicationInitializer types detected on classpath 2013-05-21 09:00:09.477:INFO:oejsh.ContextHandler:started omjpJettyWebAppContext{/export,file:/C :/hc-exporter/src/main/webapp/},file:/C:/hc-exporter/src/main/webapp/ 2013-05-21 09:00:09.478:INFO:oejsh.ContextHandler:started omjpJettyWebAppContext{/export,file:/C :/hc-exporter/src/main/webapp/},file:/C:/hc-exporter/src/main/webapp/ 2013-05-21 09:00:09.482:INFO:oejsh.ContextHandler:started omjpJettyWebAppContext{/export,file:/C :/hc-exporter/src/main/webapp/},file:/C:/hc-exporter/src/main/webapp/ 2013-05-21 09:00:09.532:INFO:/export:Initializing Spring root WebApplicationContext [ERROR] [main 09:00:10] (ContextLoader.java:initWebApplicationContext:307) Context initialization fa iled org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverObject Factory': Invocation of init method failed; nested exception is java.lang.NullPointerException at... 

您将获得Beancreationexception,因为@PostConstruct afterBeanInit方法失败。

当您将app.properties文件中的’script’属性保留为空时,它会尝试使用ClassLoader加载highcharts-convert文件。 看到这里 。

如app.properties文件中所述,这仅在Tomcat中进行测试。 显然,Jetty的开箱即用。 也许,因为ClassLoader是不同的,或者你可能必须将应用程序部署为爆炸战争?

但最简单的方法是在app.properties文件中指定’script’属性。 请注意,highcharts-convert.js脚本使用的必备文件也必须存在于同一文件夹中。

代码示例属性文件,由我在带有Jetty的Windows下使用。

 #### phantomjs properties #### # the host and port phantomjs listens to host = 127.0.0.1 port = 7777 # location of the phantomjs executable, could be for example /usr/local/bin/phantomjs exec = phantomjs # location of convert script used by phantomjs, optional to leave the script property empty, than it's using the script located in: /WEB-INF/phantomjs/highcharts-convert.js. This is tested in TOMCAT, but specify a path if resource loading isn't working with the classloader (fe with Jetty server), script = a/path/to/my/phantomjs-script.js script = C:/Users/gert/SRC/highcharts.com/exporting-server/java/highcharts-export/target/highcharts-export/WEB-INF/phantomjs/highcharts-convert.js 

在我更改app.properties文件后,我用mvn clean package构建了war

并将war文件复制到Jetty webapps文件夹。 它工作。

上面的第一个示例表明您正在配置指向jetty 9.0.0.M3(9.0.3.v20130506是最新的),但您的第二个示例显示您使用jetty-maven-plugin 8.1.2(8.1.10.v20130312是最新的)没有使用任何docker分布,它使用了一个嵌入式docker实例,它连线并通过maven插件启动。

您需要决定如何通过分发(您的第一个示例)或通过maven插件来决定如何运行jetty(org.eclipse.jetty:jetty-maven-plugin:9.0.3.v20130506可能是您应该使用的并相应地配置’exec =’属性。