gpt4 book ai didi

java - 在 Windows 10 上使用 Clojure/Java 的 NginX - 未启动

转载 作者:可可西里 更新时间:2023-11-01 09:23:10 33 4
gpt4 key购买 nike

我遇到了 Nginx 没有启动的问题。按照步骤 - 在 link 中也提到了-->我下载了包含 nginx-clojure-0.4.4 的 .zip 文件,并将其解压缩到 C:\nginx。我的 .conf 文件如下所示:

daemon  off;

#master_process off;
#user nobody;
worker_processes 1;
error_log logs/error.log;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#jvm_path auto;
jvm_path 'C:/Program Files/Java/jdk1.8.0_91/jre/bin/server/jvm.dll';
jvm_var my_other_jars 'C:/nginx-clojure-0.4.4/jars';
jvm_classpath "#{my_other_jars}/*.jar;libs/*";
#jvm_options "-Djava.class.path=jars/nginx-clojure-0.4.0.jar;#{my_other_jars}";
jvm_options "-Xms1024m";
jvm_options "-Xmx1024m";
server {
#listen 8080;
listen 9091;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location /java {
content_handler_type 'java';
content_handler_name 'mytest.HelloService';
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

location /clojure {
handler_type 'clojure';
handler_code '
(fn[req]
{
:status 200,
:headers {"content-type" "text/plain"},
:body "Hello Clojure & Nginx!"
})
';
}
}
}

现在我运行 nginx-win64.exe 如下:

Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS C:\WINDOWS\system32> cd c:\nginx
PS C:\nginx> .\nginx-win64.exe
PS C:\nginx>

当我转到 localhost:9091 时,页面没有加载,这意味着 nginx 没有启动。

这是 .log 文件的快照:

java.lang.NoClassDefFoundError: nginx/clojure/MiniConstants
Caused by: java.lang.ClassNotFoundException: nginx.clojure.MiniConstants
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)
2016/12/26 20:27:48 [error] 8400#4396: can not initialize jvm memory util
2016/12/26 20:27:48 [error] 8400#4396: jvm start times 1
Exception in thread "main" 2016/12/26 20:27:48 [error] 8408#2548: jvm may be mad for wrong options! See hs_err_pid****.log for detail! restarted 2
2016/12/26 20:27:48 [error] 8408#2548: we try quit master now!
2016/12/26 20:27:48 [crit] 8408#2548: ngx_http_clojure_quit_master, file ("C:\nginx\nginx-win64.exe"), arg (""C:\nginx\nginx-win64.exe" -s stop")
2016/12/26 20:27:48 [error] 8584#8808: jvm may be mad for wrong options! See hs_err_pid****.log for detail! restarted 3
2016/12/26 20:27:48 [error] 8584#8808: we try quit master now!
2016/12/26 20:27:48 [crit] 8584#8808: ngx_http_clojure_quit_master, file ("C:\nginx\nginx-win64.exe"), arg (""C:\nginx\nginx-win64.exe" -s stop")
2016/12/26 20:27:48 [error] 2580#8744: CreateFile() "C:\nginx/logs/nginx.pid" failed (2: The system cannot find the file specified)

@dscastro评论后的error.log文件如下:

2017/01/03 14:24:58 [error] 2552#5560: invalid java content_handler code : mytest.HelloService
Exception in thread "main" 2017/01/03 14:24:59 [error] 3304#4676: jvm may be mad for wrong options! See hs_err_pid****.log for detail! restarted 2
2017/01/03 14:24:59 [error] 3304#4676: we try quit master now!
2017/01/03 14:24:59 [crit] 3304#4676: ngx_http_clojure_quit_master, file ("C:\nginx\nginx-win64.exe"), arg (""C:\nginx\nginx-win64.exe" -s stop")
2017/01/03 14:24:59 [error] 4584#5632: jvm may be mad for wrong options! See hs_err_pid****.log for detail! restarted 3
2017/01/03 14:24:59 [error] 4584#5632: we try quit master now!
2017/01/03 14:24:59 [crit] 4584#5632: ngx_http_clojure_quit_master, file ("C:\nginx\nginx-win64.exe"), arg (""C:\nginx\nginx-win64.exe" -s stop")
2017/01/03 14:24:59 [error] 7172#5508: CreateFile() "C:\nginx/logs/nginx.pid" failed (2: The system cannot find the file specified)

最佳答案

很简单...它找不到类 nginx.clojure.MiniConstants 因为它不在你的类路径中。

这个类放在 nginx-clojure-0.4.4.jar 中,所以将 jvm_classpath 更改为:

jvm_classpath "jars/nginx-clojure-0.4.4.jar;#{my_other_jars}/*.jar;libs/*;";

...错误应该消失了。 :)

关于java - 在 Windows 10 上使用 Clojure/Java 的 NginX - 未启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41338738/

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