在Windows 10上使用Clojure / Java的NginX - 无法启动

时间:2016-12-27 03:45:17

标签: java windows nginx clojure webserver

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

prompt

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

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!" 
                            })
          ';
       }       
    }
}

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

以下是.log文件的快照:

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>

以下是@dscastro评论后的error.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)

1 个答案:

答案 0 :(得分:3)

这很简单......它找不到类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/*;";

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