Java 11 support for Nginx Clojure

35 views
Skip to first unread message

jeet kaushik

unread,
May 13, 2019, 1:08:25 AM5/13/19
to Nginx-Clojure
Hi All,

        We are trying to move from Java 8 to Java11, as Java 8 reaches its end of life. currently we are using latest Ngnix-Clojure (V0.4.5). While moving to Java 11, we are facing below issues..

2019-05-10 10:10:31[error][61200][main]server unhandled exception!

java.lang.ClassCastException: class [B cannot be cast to class [C ([B and [C are in module java.base of loader 'bootstrap')

at nginx.clojure.NginxSimpleHandler.buildResponseStringBuf(NginxSimpleHandler.java:482)

at nginx.clojure.NginxSimpleHandler.buildResponseItemBuf(NginxSimpleHandler.java:609)

at nginx.clojure.NginxSimpleHandler.buildOutputChain(NginxSimpleHandler.java:377)

at nginx.clojure.NginxClojureRT.handleResponse(NginxClojureRT.java:1515)

at nginx.clojure.NginxSimpleHandler.execute(NginxSimpleHandler.java:125)

at nginx.clojure.NginxClojureRT.eval(NginxClojureRT.java:1133)

Exception in thread "main" java.lang.ClassCastException: class [B cannot be cast to class [C ([B and [C are in module java.base of loader 'bootstrap')

at nginx.clojure.HackUtils.encode(HackUtils.java:226)

at nginx.clojure.NginxClojureRT.pushString(NginxClojureRT.java:1043)

at nginx.clojure.NginxClojureRT.pushNGXString(NginxClojureRT.java:929)

at nginx.clojure.NginxSimpleHandler.prepareHeaders(NginxSimpleHandler.java:355)

at nginx.clojure.NginxClojureRT.handleResponse(NginxClojureRT.java:1518)

at nginx.clojure.NginxSimpleHandler.execute(NginxSimpleHandler.java:125)

at nginx.clojure.NginxClojureRT.eval(NginxClojureRT.java:1133)


Looks like current version of Nginx-Clojure is not compatible with Java 11, Please let us know if we are missing something, or if not supported, when we can expect Java 11 support.

We are eagerly waiting for reply, so we can plan things accordingly.


Thanks in Advance,
Jeet Kaushik
Technical Lead

jeet kaushik

unread,
May 13, 2019, 6:04:27 AM5/13/19
to Nginx-Clojure

Test Program to reproduce the same.
  1. download Nginx-Clojure V0.4.5.
  2. configure openjdk 11.       
  3. ##Within `server {` block in nginx.conf
        location /java {
           content_handler_type 'java';
           content_handler_name 'mytest.HelloService';
        }
    
  4.  	package mytest;
     	
     	import java.util.Map;
     	
     	import nginx.clojure.java.ArrayMap;
     	import nginx.clojure.java.NginxJavaRingHandler;
     	import static nginx.clojure.MiniConstants.*;
     	
     	public  class HelloService implements NginxJavaRingHandler {
     	
     		@Override
     		public Object[] invoke(Map<String, Object> request) {
     			return new Object[] { 
     					NGX_HTTP_OK, //http status 200
     					ArrayMap.create(CONTENT_TYPE, "text/plain"), //headers map
     					"Hello, Java & Nginx!"  //response body can be string, File or Array/Collection of string or File
     					};
     		}
     	}
  5. $ cd nginx-clojure-0.4.5
    $ ./nginx
  6. curl http://localhost:8080/java

zhang yx

unread,
Nov 25, 2019, 7:08:39 AM11/25/19
to Nginx-Clojure
0.5.0 fixed this.
Reply all
Reply to author
Forward
0 new messages