本文介绍了Windows 10上具有Clojure/Java的NginX-无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正面临Nginx无法启动的问题.遵循了步骤-在链接->中也提到了我下载了包含nginx-clojure-0.4.4的.zip文件,并将其解压缩到C:\ nginx中.我的.conf文件如下所示:

I am facing the issue that Nginx is not starting up. Followed the steps - also mentioned in link --> I downloaded the .zip file containing nginx-clojure-0.4.4, and unzipped it in C:\nginx. My .conf file looks like as below:

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:

Now I run the nginx-win64.exe as follows:

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没有启动.

When I go to localhost:9091, the page does not load meaning nginx is not started.

这是.log文件的快照:

Here is the snapshot of .log file:

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文件:

Following is the error.log file after @dscastro comment:

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,因为它不在您的类路径中.

It's simple... It cannot find class nginx.clojure.MiniConstants because it is not in your classpath.

此类已放置在nginx-clojure-0.4.4.jar中,因此请将您的jvm_classpath更改为:

This class is placed into nginx-clojure-0.4.4.jar, so change your jvm_classpath to:

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

...,错误应消失. :)

... and the error should disappear. :)

这篇关于Windows 10上具有Clojure/Java的NginX-无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 06:13