gpt4 book ai didi

java - Highcharts-Export Server 2.0.1 Windows 下错误

转载 作者:行者123 更新时间:2023-12-01 17:23:40 27 4
gpt4 key购买 nike

编辑:解决方案是将所有 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 (f.e. 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/'

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

我通过对 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 (f.e. 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.<init>(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)

原始问题如下:这是 this 的后续内容问题。我现在可以成功(至少根据 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 o.m.j.p.JettyWebAppContext{/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 o.m.j.p.JettyWebAppContext{/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 o.m.j.p.JettyWebAppContext{/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...

最佳答案

您收到 Beancreation 异常,因为 @PostConstruct afterBeanInit 方法失败。

当您将 app.properties 文件中的“script”属性留空时,它会尝试使用 ClassLoader 加载 highcharts-convert 文件。 See here

如 app.properties 文件中所述,这仅在 Tomcat 中进行了测试。显然,这对于 Jetty 来说并不是开箱即用的。也许,因为类加载器不同,或者也许您必须将应用程序部署为爆炸 war ?

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

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

#### 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 (f.e. 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 文件夹中。它起作用了。

关于java - Highcharts-Export Server 2.0.1 Windows 下错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16670730/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com