You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Shields, John (HQP)" <Jo...@rhi.com> on 2004/02/28 01:50:34 UTC

NullPointerException Running JAX-RPC wscompile/wsdeploy Ant Tasks

Hello,

I keep receiving the following error when trying to run the JAX-RPC ant
tasks from within Maven. I just cannot seem to find the problem. I have a
suspicion that I'm in ClassLoader hell, but I'm not sure. I'm using JDK
1.4.2_03, Maven-1.0-rc1, and JWSDP-1.3.

The strangest thing is that if I change my maven.xml file to execute the
JWSDP-1.3 command line tools directly then everything works. However, I
would like to not have a dependency on the JWSDP tools if at all possible
(jar files are OK, of course). Another project at my company is using the
ant tasks successfully from ant, but they haven't tried it from Maven.

Here is the pertinent part of the output from Maven with the "--debug
--exception" flags set:

    [wsdeploy] [DEBUG] Finding class com.sun.xml.rpc.util.JavaCompilerHelper
    [wsdeploy] [DEBUG] Class com.sun.xml.rpc.util.JavaCompilerHelper loaded
from ant loader
    [wsdeploy] [DEBUG] Class java.lang.NoSuchMethodException loaded from
parent loader
    [wsdeploy] [DEBUG] Class java.lang.reflect.InvocationTargetException
loaded from parent loader
    [wsdeploy] [DEBUG] Class java.io.PrintWriter loaded from parent loader
    [wsdeploy] [DEBUG] Class java.lang.Thread loaded from parent loader
    [wsdeploy] error: java.lang.NullPointerException
    [wsdeploy] java.lang.NullPointerException
    [wsdeploy] 	at
com.sun.xml.rpc.util.JavaCompilerHelper.internalCompile(JavaCompilerHelper.j
ava:45)
    [wsdeploy] 	at
com.sun.xml.rpc.util.JavaCompilerHelper.compile(JavaCompilerHelper.java:32)
    [wsdeploy] 	at
com.sun.xml.rpc.tools.wscompile.CompileTool.compileGeneratedClasses(CompileT
ool.java:876)
    [wsdeploy] 	at
com.sun.xml.rpc.tools.wscompile.CompileTool.run(CompileTool.java:578)
    [wsdeploy] 	at
com.sun.xml.rpc.tools.wsdeploy.DeployTool.process(DeployTool.java:303)
    [wsdeploy] 	at
com.sun.xml.rpc.tools.wsdeploy.DeployTool.run(DeployTool.java:213)
    [wsdeploy] 	at com.sun.xml.rpc.util.ToolBase.run(ToolBase.java:40)
    [wsdeploy] 	at
com.sun.xml.rpc.tools.ant.Wsdeploy.execute(Wsdeploy.java:351)
    [wsdeploy] 	at org.apache.tools.ant.Task.perform(Task.java:341)
    [wsdeploy] 	at
org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:232)

>From the source code provided for the JWSDP on http://www.java.net/ I
believe that the offending code is somewhere in here (I don't think the line
numbers match up exactly between the released source and the 1.3 binaries):


		ClassLoader cl =
Thread.currentThread().getContextClassLoader();
		Class comSunToolsJavacMainClass = null;
		try {
			/* try to use the new compiler */
			comSunToolsJavacMainClass =
				cl.loadClass("com.sun.tools.javac.Main");
			try {
				Method compileMethod =
					comSunToolsJavacMainClass.getMethod(
						"compile",
						compile141MethodSignature);
				try {
					Object result =
						compileMethod.invoke(
							null,
							new Object[] { args,
new PrintWriter(out)});
					if (!(result instanceof Integer)) {
						return false;
					}
					return ((Integer) result).intValue()
== 0;
				} catch (IllegalAccessException e3) {
					return false;
				} catch (IllegalArgumentException e3) {
					return false;
				} catch (InvocationTargetException e3) {
					return false;
				}
			} catch (NoSuchMethodException e2) {
				//tryout 1.3.1 signature
				return internalCompilePre141(args);
	
//onError(getMessage("javacompiler.nosuchmethod.error",
"getMethod(\"compile\", compile141MethodSignature)"));
				//return false;
			}
		} catch (ClassNotFoundException e) {
			onError(
				getMessage(
					"javacompiler.classpath.error",
					"com.sun.tools.javac.Main"));
			return false;
		} catch (SecurityException e) {
			return false;
		}

"tools.jar" is explicitly added to the classpath using "${tools.jar}" so
"com.sun.tools.javac.Main" should be there.

Attached are maven.xml and a strange *.h file that appeared in my working
directory.

I've been grappling with this all day (!!) and would greatly appreciate some
help. I feel like it's something simple that I'm missing, but who knows...

Thanks!

John