You need to run the code using a JDK, not a JRE. The NPE is happening in the following bit of CXF'sCompiler
class
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
compiler
is null if you run in a JRE(java/jre not java/jdk/jre).
在eclipse中执行代码,默认使用eclipse中指定的jre。若指定的jre不在jdk中,无法找到jdk/bin下的编译器,返回null。CXF'sCompiler
中即会出现null pointer exception。